Dynamixel_Servo and ArduinoMenu confilict?

Have a project using
Arduino Menu

and
Dynamixel Serial

and some other bits like LiquidCrystal, ClickEncoder and timer library

They all work fine standalone. But if I put Dynamixel serial and Arduino Menu together, then heaps of compile error.

Anyone has the same issue before?

thanks

When you encounter an error you’ll see a button on the right side of the orange bar “Copy error messages”. Click that button. Paste the error in a message here USING CODE TAGS (</> button on the toolbar).

thanks for the info.

Looks like the problem is in macro MENU_OUTPUTS()
if I add code
MENU_OUTPUTS(out, MAX_DEPTH, LIQUIDCRYSTAL_OUT(lcd, {0, 0, 16, 2}), NONE);
or
MENU_OUTPUTS(out,MAX_DEPTH ,SERIAL_OUT(Serial) ,NONE);
errors turn up.
if I comment it off, no problem.

Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Uno"

In file included from C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/menuBase.h:28:0,

                 from C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/menu.h:20,

                 from E:\sketch_nov27a\sketch_nov27a.ino:5:

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/macros.h:77:34: error: expected constructor, destructor, or type conversion before '(' token

 #define LIQUIDCRYSTAL_OUT(...) ON(LIQUIDCRYSTAL_OUT,__COUNTER__,__VA_ARGS__)

                                  ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/macros.h:73:31: note: in definition of macro 'CALL__'

 #define CALL__(a,b,...) a##_##b(__VA_ARGS__)

                               ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/macros.h:67:19: note: in expansion of macro 'CALL_'

 #define CALL(a,b) CALL_(HEAD_##a,HEAD_##b,TAIL_##a,TAIL_##b)

                   ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/baseMacros.h:58:3: note: in expansion of macro 'CALL'

   what(params,x)\

   ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/baseMacros.h:7:35: note: in expansion of macro 'XFOR_EACH_2'

 #define CONCATENATE2(arg1, arg2)  arg1##arg2

                                   ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/baseMacros.h:112:42: note: in expansion of macro 'XFOR_EACH_'

 #define XFOR_EACH(what, params , x, ...) XFOR_EACH_(FOR_EACH_NARG(x, __VA_ARGS__), what, params, x, __VA_ARGS__)

                                          ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/macros.h:159:2: note: in expansion of macro 'XFOR_EACH'

  XFOR_EACH(CALL,WITH(VAR,id,maxDepth),__VA_ARGS__)\

  ^

E:\sketch_nov27a\sketch_nov27a.ino:154:1: note: in expansion of macro 'MENU_OUTPUTS'

 MENU_OUTPUTS(out, MAX_DEPTH, LIQUIDCRYSTAL_OUT(lcd, {0, 0, 16, 2}), NONE);

 ^

E:\sketch_nov27a\sketch_nov27a.ino:154:30: note: in expansion of macro 'LIQUIDCRYSTAL_OUT'

 MENU_OUTPUTS(out, MAX_DEPTH, LIQUIDCRYSTAL_OUT(lcd, {0, 0, 16, 2}), NONE);

                              ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/macros.h:77:76: error: expected unqualified-id before ')' token

 #define LIQUIDCRYSTAL_OUT(...) ON(LIQUIDCRYSTAL_OUT,__COUNTER__,__VA_ARGS__)

                                                                            ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/macros.h:73:31: note: in definition of macro 'CALL__'

 #define CALL__(a,b,...) a##_##b(__VA_ARGS__)

                               ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/macros.h:67:19: note: in expansion of macro 'CALL_'

 #define CALL(a,b) CALL_(HEAD_##a,HEAD_##b,TAIL_##a,TAIL_##b)

                   ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/baseMacros.h:58:3: note: in expansion of macro 'CALL'

   what(params,x)\

   ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/baseMacros.h:7:35: note: in expansion of macro 'XFOR_EACH_2'

 #define CONCATENATE2(arg1, arg2)  arg1##arg2

                                   ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/baseMacros.h:112:42: note: in expansion of macro 'XFOR_EACH_'

 #define XFOR_EACH(what, params , x, ...) XFOR_EACH_(FOR_EACH_NARG(x, __VA_ARGS__), what, params, x, __VA_ARGS__)

                                          ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/macros.h:159:2: note: in expansion of macro 'XFOR_EACH'

  XFOR_EACH(CALL,WITH(VAR,id,maxDepth),__VA_ARGS__)\

  ^

E:\sketch_nov27a\sketch_nov27a.ino:154:1: note: in expansion of macro 'MENU_OUTPUTS'

 MENU_OUTPUTS(out, MAX_DEPTH, LIQUIDCRYSTAL_OUT(lcd, {0, 0, 16, 2}), NONE);

 ^

E:\sketch_nov27a\sketch_nov27a.ino:154:30: note: in expansion of macro 'LIQUIDCRYSTAL_OUT'

 MENU_OUTPUTS(out, MAX_DEPTH, LIQUIDCRYSTAL_OUT(lcd, {0, 0, 16, 2}), NONE);

                              ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/macros.h:77:76: error: expected unqualified-id before ')' token

 #define LIQUIDCRYSTAL_OUT(...) ON(LIQUIDCRYSTAL_OUT,__COUNTER__,__VA_ARGS__)

                                                                            ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/macros.h:73:33: note: in definition of macro 'CALL__'

 #define CALL__(a,b,...) a##_##b(__VA_ARGS__)

                                 ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/macros.h:67:19: note: in expansion of macro 'CALL_'

 #define CALL(a,b) CALL_(HEAD_##a,HEAD_##b,TAIL_##a,TAIL_##b)

                   ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/baseMacros.h:58:3: note: in expansion of macro 'CALL'

   what(params,x)\

   ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/baseMacros.h:7:35: note: in expansion of macro 'XFOR_EACH_2'

 #define CONCATENATE2(arg1, arg2)  arg1##arg2

                                   ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/baseMacros.h:112:42: note: in expansion of macro 'XFOR_EACH_'

 #define XFOR_EACH(what, params , x, ...) XFOR_EACH_(FOR_EACH_NARG(x, __VA_ARGS__), what, params, x, __VA_ARGS__)

                                          ^

C:\Users\xxxx\Documents\Arduino\libraries\ArduinoMenu_library\src/macros.h:159:2: note: in expansion of macro 'XFOR_EACH'

  XFOR_EACH(CALL,WITH(VAR,id,maxDepth),__VA_ARGS__)\

  ^

E:\sketch_nov27a\sketch_nov27a.ino:154:1: note: in expansion of macro 'MENU_OUTPUTS'

 MENU_OUTPUTS(out, MAX_DEPTH, LIQUIDCRYSTAL_OUT(lcd, {0, 0, 16, 2}), NONE);

 ^

E:\sketch_nov27a\sketch_nov27a.ino:154:30: note: in expansion of macro 'LIQUIDCRYSTAL_OUT'

 MENU_OUTPUTS(out, MAX_DEPTH, LIQUIDCRYSTAL_OUT(lcd, {0, 0, 16, 2}), NONE);

                              ^

exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Wow, I guess the author of that menu library really likes macros!

I believe I have identified the problem. The author of the Dynamixel_Serial library had the genius idea of defining a macro named "ON". The menu library also uses either a macro or function named ON. I can't find the definition of ON that the menu library intended to use but it's definitely not the one in the Dynamixel_Serial library, thus the errors.

So here's the solution I propose:

  • File > Examples > Dynamixel_Serial > Buadrate_and_ID_setup
  • Sketch > Show sketch folder
  • Navigate up two folder levels to the root of the library folder
  • Open the file Dynamixel_Serial.h in a text editor.
  • Change line 134 from:
#define ON                              0x01

to:

#define DYNAMIXEL_SERIAL_ON                              0x01
  • Anywhere in your code where the Dynamixel_Serial library's ON macro is used change it to DYNAMIXEL_SERIAL_ON.

And please people, don't use common macro names in libraries!!!

Thanks for the info
It is the bloody "Macro" conflict.
It's not "ON" or "OFF", it's another macro. Changed them into DM_XXX.
Problem solved.