vmatos / rosserial_tivac

rosserial package for the TivaC Launchpad boards
3 stars 1 forks source link

Can't Choose Serial Number of Device #3

Open sdahdah opened 7 years ago

sdahdah commented 7 years ago

I noticed that the serial number is hard-coded in usb_serial_structs.c. However, since I'm using multiple Tiva's, I'd like to give them their own serial numbers as a parameter in CMake.

How can we make this work?

vmatos commented 7 years ago

Here we make it like this.

Copy both usb_serial_structs.cand usb_serial_structs.h to your project directory and make your changes. Then on your projects CMakeLists.txt include usb_serial_structs.c on your src list.

It should include, compile and link these files first.

sdahdah commented 7 years ago

When I do that I get errors about multiple definitions of things like TxBuffer, etc. If I clean and do it again, then i get an error where it can't find common_msgs... it's a bit odd. You add the file to your innermost CMakeLists.txt, right?

sdahdah commented 7 years ago

To be more specific, this is my exact error message: screenshot from 2017-05-12 19-43-08

malcolmwhat commented 7 years ago

This is the first error message @sdahdah is referring to

[ 30%] Linking CXX executable /home/robotics/rover/catkin_ws/devel/arm_shoulder.axf
CMakeFiles/arm_shoulder.axf.dir/home/robotics/rover/catkin_ws/build/rover_tiva/ros_lib/usb_serial_structs.c.obj: In function `TxHandler':
usb_serial_structs.c:(.text.TxHandler+0x0): multiple definition of `TxHandler'
CMakeFiles/arm_shoulder.axf.dir/usb_serial_structs.c.obj:usb_serial_structs.c:(.text.TxHandler+0x0): first defined here
CMakeFiles/arm_shoulder.axf.dir/home/robotics/rover/catkin_ws/build/rover_tiva/ros_lib/usb_serial_structs.c.obj: In function `RxHandler':
usb_serial_structs.c:(.text.RxHandler+0x0): multiple definition of `RxHandler'
CMakeFiles/arm_shoulder.axf.dir/usb_serial_structs.c.obj:usb_serial_structs.c:(.text.RxHandler+0x0): first defined here
CMakeFiles/arm_shoulder.axf.dir/home/robotics/rover/catkin_ws/build/rover_tiva/ros_lib/usb_serial_structs.c.obj: In function `ControlHandler':
usb_serial_structs.c:(.text.ControlHandler+0x0): multiple definition of `ControlHandler'
CMakeFiles/arm_shoulder.axf.dir/usb_serial_structs.c.obj:usb_serial_structs.c:(.text.ControlHandler+0x0): first defined here
CMakeFiles/arm_shoulder.axf.dir/home/robotics/rover/catkin_ws/build/rover_tiva/ros_lib/usb_serial_structs.c.obj:(.data.g_sTxBuffer+0x0): multiple definition of `g_sTxBuffer'
CMakeFiles/arm_shoulder.axf.dir/usb_serial_structs.c.obj:(.data.g_sTxBuffer+0x0): first defined here
CMakeFiles/arm_shoulder.axf.dir/home/robotics/rover/catkin_ws/build/rover_tiva/ros_lib/usb_serial_structs.c.obj:(.data.g_sRxBuffer+0x0): multiple definition of `g_sRxBuffer'
CMakeFiles/arm_shoulder.axf.dir/usb_serial_structs.c.obj:(.data.g_sRxBuffer+0x0): first defined here
CMakeFiles/arm_shoulder.axf.dir/home/robotics/rover/catkin_ws/build/rover_tiva/ros_lib/usb_serial_structs.c.obj:(.data.g_sCDCDevice+0x0): multiple definition of `g_sCDCDevice'
CMakeFiles/arm_shoulder.axf.dir/usb_serial_structs.c.obj:(.data.g_sCDCDevice+0x0): first defined here
CMakeFiles/arm_shoulder.axf.dir/home/robotics/rover/catkin_ws/build/rover_tiva/ros_lib/usb_serial_structs.c.obj:(.rodata.g_ppui8StringDescriptors+0x0): multiple definition of `g_ppui8StringDescriptors'
CMakeFiles/arm_shoulder.axf.dir/usb_serial_structs.c.obj:(.rodata.g_ppui8StringDescriptors+0x0): first defined here
CMakeFiles/arm_shoulder.axf.dir/home/robotics/rover/catkin_ws/build/rover_tiva/ros_lib/usb_serial_structs.c.obj:(.rodata.g_pui8ConfigString+0x0): multiple definition of `g_pui8ConfigString'
CMakeFiles/arm_shoulder.axf.dir/usb_serial_structs.c.obj:(.rodata.g_pui8ConfigString+0x0): first defined here
CMakeFiles/arm_shoulder.axf.dir/home/robotics/rover/catkin_ws/build/rover_tiva/ros_lib/usb_serial_structs.c.obj:(.rodata.g_pui8ControlInterfaceString+0x0): multiple definition of `g_pui8ControlInterfaceString'
CMakeFiles/arm_shoulder.axf.dir/usb_serial_structs.c.obj:(.rodata.g_pui8ControlInterfaceString+0x0): first defined here
CMakeFiles/arm_shoulder.axf.dir/home/robotics/rover/catkin_ws/build/rover_tiva/ros_lib/usb_serial_structs.c.obj:(.rodata.g_pui8SerialNumberString+0x0): multiple definition of `g_pui8SerialNumberString'
CMakeFiles/arm_shoulder.axf.dir/usb_serial_structs.c.obj:(.rodata.g_pui8SerialNumberString+0x0): first defined here
CMakeFiles/arm_shoulder.axf.dir/home/robotics/rover/catkin_ws/build/rover_tiva/ros_lib/usb_serial_structs.c.obj:(.rodata.g_pui8ProductString+0x0): multiple definition of `g_pui8ProductString'
CMakeFiles/arm_shoulder.axf.dir/usb_serial_structs.c.obj:(.rodata.g_pui8ProductString+0x0): first defined here
CMakeFiles/arm_shoulder.axf.dir/home/robotics/rover/catkin_ws/build/rover_tiva/ros_lib/usb_serial_structs.c.obj:(.rodata.g_pui8ManufacturerString+0x0): multiple definition of `g_pui8ManufacturerString'
CMakeFiles/arm_shoulder.axf.dir/usb_serial_structs.c.obj:(.rodata.g_pui8ManufacturerString+0x0): first defined here
/usr/bin/../lib/gcc/arm-none-eabi/6.2.1/../../../../arm-none-eabi/bin/ld: Warning: size of symbol `g_pui8ManufacturerString' changed from 32 in CMakeFiles/arm_shoulder.axf.dir/usb_serial_structs.c.obj to 36 in CMakeFiles/arm_shoulder.axf.dir/home/robotics/rover/catkin_ws/build/rover_tiva/ros_lib/usb_serial_structs.c.obj
CMakeFiles/arm_shoulder.axf.dir/home/robotics/rover/catkin_ws/build/rover_tiva/ros_lib/usb_serial_structs.c.obj:(.rodata.g_pui8LangDescriptor+0x0): multiple definition of `g_pui8LangDescriptor'
CMakeFiles/arm_shoulder.axf.dir/usb_serial_structs.c.obj:(.rodata.g_pui8LangDescriptor+0x0): first defined here
collect2: error: ld returned 1 exit status
CMakeFiles/arm_shoulder.axf.dir/build.make:330: recipe for target '/home/robotics/rover/catkin_ws/devel/arm_shoulder.axf' failed
make[6]: *** [/home/robotics/rover/catkin_ws/devel/arm_shoulder.axf] Error 1
CMakeFiles/Makefile2:164: recipe for target 'CMakeFiles/arm_shoulder.axf.dir/all' failed
make[5]: *** [CMakeFiles/arm_shoulder.axf.dir/all] Error 2
CMakeFiles/Makefile2:176: recipe for target 'CMakeFiles/arm_shoulder.axf.dir/rule' failed
make[4]: *** [CMakeFiles/arm_shoulder.axf.dir/rule] Error 2
Makefile:157: recipe for target 'arm_shoulder.axf' failed
make[3]: *** [arm_shoulder.axf] Error 2
rover_tiva/CMakeFiles/rover_tiva_arm_shoulder_arm_shoulder.axf.dir/build.make:57: recipe for target 'rover_tiva/CMakeFiles/rover_tiva_arm_shoulder_arm_shoulder.axf' failed
make[2]: *** [rover_tiva/CMakeFiles/rover_tiva_arm_shoulder_arm_shoulder.axf] Error 2
CMakeFiles/Makefile2:6731: recipe for target 'rover_tiva/CMakeFiles/rover_tiva_arm_shoulder_arm_shoulder.axf.dir/all' failed
make[1]: *** [rover_tiva/CMakeFiles/rover_tiva_arm_shoulder_arm_shoulder.axf.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
vmatos commented 7 years ago

I forgot one detail. You must allow multiple definitions.

On the firmware's CMakeLists.txt, add this line before generate_tivac_firmware(...)

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z muldefs")

I feel this solution is a bit hackish. But I haven't decided yet if having the ability for a (beginner) user to change the serial of the CDC device is worth it or not.

sdahdah commented 7 years ago

Thanks, that worked! This is a good enough solution for me.

In general, I think it should be possible to change the serial number. If multiple Tivas using rosserial_tivac are connected to a computer, it's impossible to distinguish between them.

However, maybe it would be better for the default serial number to be the one contained inside the Tiva's ROM, instead of 12345678. That way, the Tivas would be distinguishable. That's an easier change, but it makes the devices distinguishable. What do you think?

vmatos commented 7 years ago

I'll look into it when I have the time.

sdahdah commented 7 years ago

Thanks. If I can figure it out I'll fork and pull request