ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

rosserial_arduino : sending a null character

asked 2015-10-14 16:29:30 -0500

inask gravatar image

Hello everyone,

I am using rosserial to send messages from an Arduino to my computer. I send a char* using std_msgs::String.

The problem is that sometimes, one of the char is equal to 0, which causes the subscriber to this topic to only receive the characters sended before this null one.

Does anyone know how to avoid this 'interpretation' of the null character ?

Cheers,

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-10-15 05:56:28 -0500

gvdhoorn gravatar image

Does anyone know how to avoid this 'interpretation' of the null character ?

Don't use String? nul chars are special characters, meant to signal end-of-string in C. If you're sending binary data, use another message type for that.

edit flag offensive delete link more

Comments

Thank you for your answer ! I will try that... Do you have any idea of wich container I could use ? Will (char *) will also be considered as a kind of string and then use those special characters ?

inask gravatar image inask  ( 2015-10-15 06:14:29 -0500 )edit

If you really need an array of binary data, then any of the *MultiArray msgs could work. It is generally considered a better approach to use typed msgs though (so any of the sensor_msgs),

gvdhoorn gravatar image gvdhoorn  ( 2015-10-15 07:08:23 -0500 )edit

Question Tools

Stats

Asked: 2015-10-14 16:29:30 -0500

Seen: 218 times

Last updated: Oct 15 '15