vmatos / rosserial_tivac

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

bug in usb mode #6

Closed altineller closed 4 years ago

altineller commented 4 years ago

In the usb mode, there is a bug that affects only certain messages when publishing.

I can publish a sensor_msgs/MagneticField and not sensor_msgs/Imu

When I publish an imu message I get 'wrong checksum for topic id and msg' and I think the usb_buffer is garbled.

It works perfectly when USB flag is not set, from the normal serial port, but while in usb mode, it will work for small messages, but not for large ones.

I did fix the usblib bug mentioned in the tutorial, recompiled tivaware with gcc, and recompiled rosserial_tivac, and sure my program is linked to gcc/libusb.a - but the bug persisted.

This is for an open source project that is based on the rosserial_tivac

https://github.com/altineller/fximu/tree/master/ros_fximu

In this version, I am publishing a custom message, at 230400 baud perfectly with no problem.

But I have updated my code to run the ros's imu_tools complementary_filter to run on the TM4C123, the port is almost done, but I am unable to publish imu messages.

I have attached a serial sniffer to illustrate the difference and debug:

Here is sniffed packed while in normal serial mode:

FF FE 38 01 C6 7D 00 00 00 00 00 00 00 00 00 00 ..8..}.......... 00 00 00 00 00 00 00 00 00 00 A0 ED 7C BF 3F 00 ............|.?. 00 00 40 B6 F3 CD 3F 00 00 00 E0 7A 14 D6 3F 00 ..@...?....z..?. 00 00 A0 1A 2F DD 3F 00 00 00 00 00 00 00 00 00 ..../.?......... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 A0 ED 7C BF 3F 00 00 00 40 B6 F3 CD 3F 00 ....|.?...@...?. 00 00 E0 7A 14 D6 3F 00 00 00 00 00 00 00 00 00 ...z..?......... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 A0 ED 7C BF 3F 00 00 00 40 B6 F3 CD 3F 00 ....|.?...@...?. 00 00 E0 7A 14 D6 3F 00 00 00 00 00 00 00 00 00 ...z..?......... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ FF FE 08 00 F7 0A 00 00 00 00 00 00 00 00 00 F5 ................ FF FE 49 00 B6 00 00 7D 00 08 00 00 00 69 6D 75 ..I....}.....imu 2F 64 61 74 61 0F 00 00 00 73 65 6E 73 6F 72 5F /data....sensor_ 6D 73 67 73 2F 49 6D 75 20 00 00 00 36 61 36 32 msgs/Imu ...6a62 63 36 64 61 61 65 31 30 33 66 34 66 66 35 37 61 c6daae103f4ff57a 31 33 32 64 36 66 39 35 63 65 63 32 00 02 00 00 132d6f95cec2....

Here is the sniffed packed in usb mode FF FE 38 01 C6 7D 00 00 00 00 00 00 00 00 00 00 ..8..}.......... 00 00 00 00 00 00 00 00 00 00 A0 ED 7C BF 3F 00 ............|.?. 00 00 40 B6 F3 CD 3F 00 00 00 E0 7A 14 D6 3F 00 ..@...?....z..?. 00 00 A0 1A 2F DD 3F 00 00 00 00 00 00 00 00 00 ..../.?......... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 A0 ED 7C BF 3F 00 00 00 40 B6 F3 CD 3F 00 ....|.?...@...?. 00 00 E0 7A 14 D6 3F 00 00 00 00 00 00 00 00 00 ...z..?......... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 A0 ED 7C BF 3F 00 00 00 40 B6 F3 CD 3F 00 ....|.?...@...?. 00 00 7A 14 D6 3F 00 00 00 00 00 00 00 00 ..z..?........

It is either the usb mode can not transmit a buffer of 512, OR we are not able to pass the correct buffer size. I have experimented with the Imu message type, defining buffer sizes of 128, 256, 512 and so found out it will require 512 bytes buffer size.

Best regards, -CA

altineller commented 4 years ago

I found out why, and will make a note here and close the issue.

In the CMakeFile of the project, you have to add:

add_definitions(-DUART_BUFFER_SIZE=1024)

otherwise usb buffer size will be 256, as defined in the code. the TX_BUFFER_SIZE and RX_BUFFER_SIZE parameters are not for the usb. usb buffer size is determined by UART_BUFFER_SIZE definition.