rosserial arduino - serial port read failure
Hi all,
I am using rosserial_python to talk to the arduino Mega controller. It starts without any problem and the publisher is setup but then I get a warning and then after some time, the publisher is setup again and this keeps on repeating. I run the command: rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0 _baud:=38400
and get the following output:
[INFO] [WallTime: 1431985219.669859] ROS Serial Python Node
[INFO] [WallTime: 1431985219.681885] Connecting to /dev/ttyACM0 at 38400 baud
[INFO] [WallTime: 1431985222.080703] Note: publish buffer size is 512 bytes
[INFO] [WallTime: 1431985222.081016] Setup publisher on re_ticks [geometry_msgs/Vector3]
[INFO] [WallTime: 1431985222.084923] Note: subscribe buffer size is 512 bytes
[INFO] [WallTime: 1431985222.085169] Setup subscriber on cmd_vel [geometry_msgs/Twist]
[WARN] [WallTime: 1431985370.795273] Serial Port read returned short (expected 24 bytes, received 11 instead).
[WARN] [WallTime: 1431985370.796246] Serial Port read failure:
[INFO] [WallTime: 1431985370.797106] Packet Failed : Failed to read msg data
[INFO] [WallTime: 1431985370.797706] msg len is 24
[INFO] [WallTime: 1431985370.908577] Setup publisher on re_ticks [geometry_msgs/Vector3]
[WARN] [WallTime: 1431985370.930211] Serial Port read returned short (expected 76 bytes, received 41 instead).
[WARN] [WallTime: 1431985370.930796] Serial Port read failure:
[INFO] [WallTime: 1431985370.931169] Packet Failed : Failed to read msg data
[INFO] [WallTime: 1431985370.931641] msg len is 79
[INFO] [WallTime: 1431985371.051592] Setup publisher on re_ticks [geometry_msgs/Vector3]
As this warning keeps on coming, sometimes I face issues in sending commands to the arduino and receiving data from the arduino.
Update: (from the comments and answer) @tonybaltovski
The issue is the max baud rate I can use for the motor_controller is 38400 so if I increase the baud rate of Arduino Mega to say 57600 and keep the baud rate for the motor_controller to 38400, I get the following error:
[INFO] [WallTime: 1432229409.776248] ROS Serial Python Node 1
[INFO] [WallTime: 1432229409.788611] Connecting to /dev/ttyACM0 at 57600 baud
[ERROR] [WallTime: 1432229426.895735] Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino
Relevant part from the Arduino code:
void setup()
{
nh.getHardware()->setBaud(57600); // 57600 gives error
nh.initNode(); // Initialize Node
nh.advertise(encoder_ticks_pub);
nh.subscribe(motor_sub);
SabertoothTXPinSerial.begin(9600); // 9600 is the default baud rate for Sabertooth packet serial.
ST.setBaudRate(38400);
SabertoothTXPinSerial.end();
SabertoothTXPinSerial.begin(38400);
}
Does anyone have any idea why is this happening? Please let me know if you need more information from my side. Any help will be appreciated.
Thanks in advance.
Naman Kumar
Hey Naman , Were you able to solve this?.I am facing the same issue.