rosserial_arduino : sending a null character
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,
Asked by inask on 2015-10-14 16:29:30 UTC
Answers
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.
Asked by gvdhoorn on 2015-10-15 05:56:28 UTC
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 ?
Asked by inask on 2015-10-15 06:14:29 UTC
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),
Asked by gvdhoorn on 2015-10-15 07:08:23 UTC
Comments