This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit b85a5ed30691957e29a2c9e9f19cade7a9891187
Author: raiden00pl <raide...@railab.me>
AuthorDate: Sat Oct 12 17:38:50 2024 +0200

    examples/foc: ignore error for align and ident routines when motor 
controller disabled
    
    CONFIG_EXAMPLES_FOC_RUN_DISABLE option is used for tests and benchmarks, so 
we don't
    care about wrong results for motor identification and sensor alignment 
routines
---
 examples/foc/foc_motor_b16.c | 18 ++++++++++++++++++
 examples/foc/foc_motor_f32.c | 18 ++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/examples/foc/foc_motor_b16.c b/examples/foc/foc_motor_b16.c
index 543f44933..a67230fac 100644
--- a/examples/foc/foc_motor_b16.c
+++ b/examples/foc/foc_motor_b16.c
@@ -1613,8 +1613,17 @@ int foc_motor_init(FAR struct foc_motor_b16_s *motor,
   ret = foc_routine_cfg_b16(&motor->align, &align_cfg);
   if (ret < 0)
     {
+#  ifndef CONFIG_EXAMPLES_FOC_RUN_DISABLE
       PRINTFV("ERROR: foc_routine_cfg_b16 failed %d!\n", ret);
       goto errout;
+#  else
+      /* When motor controller is disabled, most likely we don't care about
+       * align routine failure
+       */
+
+      PRINTFV("ignore align routine failure\n", ret);
+      ret = OK;
+#  endif
     }
 #endif
 
@@ -1647,8 +1656,17 @@ int foc_motor_init(FAR struct foc_motor_b16_s *motor,
   ret = foc_routine_cfg_b16(&motor->ident, &ident_cfg);
   if (ret < 0)
     {
+#  ifndef CONFIG_EXAMPLES_FOC_RUN_DISABLE
       PRINTFV("ERROR: foc_ident_cfg_b16 failed %d!\n", ret);
       goto errout;
+#  else
+      /* When motor controller is disabled, most likely we don't care about
+       * ident routine failure
+       */
+
+      PRINTFV("ident align routine failure\n", ret);
+      ret = OK;
+#  endif
     }
 #endif
 
diff --git a/examples/foc/foc_motor_f32.c b/examples/foc/foc_motor_f32.c
index f39949536..5feedf5db 100644
--- a/examples/foc/foc_motor_f32.c
+++ b/examples/foc/foc_motor_f32.c
@@ -1600,8 +1600,17 @@ int foc_motor_init(FAR struct foc_motor_f32_s *motor,
   ret = foc_routine_cfg_f32(&motor->align, &align_cfg);
   if (ret < 0)
     {
+#  ifndef CONFIG_EXAMPLES_FOC_RUN_DISABLE
       PRINTFV("ERROR: foc_routine_cfg_f32 failed %d!\n", ret);
       goto errout;
+#  else
+      /* When motor controller is disabled, most likely we don't care about
+       * align routine failure
+       */
+
+      PRINTFV("ignore align routine failure\n", ret);
+      ret = OK;
+#  endif
     }
 #endif
 
@@ -1631,8 +1640,17 @@ int foc_motor_init(FAR struct foc_motor_f32_s *motor,
   ret = foc_routine_cfg_f32(&motor->ident, &ident_cfg);
   if (ret < 0)
     {
+#  ifndef CONFIG_EXAMPLES_FOC_RUN_DISABLE
       PRINTFV("ERROR: foc_ident_cfg_f32 failed %d!\n", ret);
       goto errout;
+#  else
+      /* When motor controller is disabled, most likely we don't care about
+       * ident routine failure
+       */
+
+      PRINTFV("ident align routine failure\n", ret);
+      ret = OK;
+#  endif
     }
 #endif
 

Reply via email to