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

rosserial arduino - serial port read failure

asked 2015-05-18 17:07:21 -0500

Naman gravatar image

updated 2015-05-22 07:34:44 -0500

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

edit retag flag offensive close merge delete

Comments

Hey Naman , Were you able to solve this?.I am facing the same issue.

prrraveen gravatar image prrraveen  ( 2015-07-31 05:52:11 -0500 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2015-05-20 20:51:06 -0500

updated 2015-05-22 16:09:37 -0500

Try increasing your baud rate. Is there a reason it is 38400?

edit flag offensive delete link more

Comments

I am using it with the Sabertooth 2x25 Motor Controller and the maximum baud rate it can support is 38400 AFAIK.

Naman gravatar image Naman  ( 2015-05-20 21:04:56 -0500 )edit

Are you not using an Arduino Mega?

tonybaltovski gravatar image tonybaltovski  ( 2015-05-21 11:43:31 -0500 )edit

Yes I am using Arduino Mega but motor controller can only use max baud rate of 38400. If I use 57600 as baud rate for Arduino Mega and 38400 for motor controller, I get an error (updated original question), Please have a look. TIA

Naman gravatar image Naman  ( 2015-05-21 12:40:12 -0500 )edit

Try making the motor driver use Serial1.

tonybaltovski gravatar image tonybaltovski  ( 2015-05-21 13:02:03 -0500 )edit

are you able to get the mega to reliably link to the node if you remove all the code for the motor controller - get one to work and then introduce the other

nickw gravatar image nickw  ( 2015-05-24 07:59:22 -0500 )edit
1

I changed the timeout from 5 to 10 in Serialclient.py, this seems to work better? Can anyone tell why

jaghvi gravatar image jaghvi  ( 2015-06-02 12:24:11 -0500 )edit

Also I get a similar error when running the ultrasound example in ros_lib

jaghvi gravatar image jaghvi  ( 2015-06-02 12:50:24 -0500 )edit
0

answered 2018-06-03 21:25:48 -0500

RicHykkie gravatar image

updated 2018-06-03 21:33:37 -0500

jayess gravatar image

Hey,

I got the same issue as you did. After many trials and errors I found the reason this was happening. This message actually means that your Arduino can't establish a serial connection with your PC. It is because the line SabertoothTXPinSerial.begin(9600); only establishes the serial connection between the Sabertooth and the Arduino.

Simply add Serial.begin(9600); right before and that should fix it.

Also, I would use ST.autobaud(); rather than setting it manually.

Note that the error message:

[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

might still appear, but just wait for a cycle and the connection confirmation should pop-up.

Hope that helps,

Ric

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-05-18 17:07:21 -0500

Seen: 2,691 times

Last updated: Jun 03 '18