Arduino Due - Unable to sync with device - Then works fine
I have an odd error occurring for my arduino Due.
I have a sketch which defined '#define USE_USBCON' and is running as a publisher. The baud rate is set 'nh.getHardware()->setBaud(115200);' with a value of 115200.
When I run rosserial_python to connect to the arduino (using the Programming Port, I cannot get the native port to work with ROS) I run the following command:
rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0 _baud:=115200
rosserial_python then outputs:
[INFO] [WallTime: 1469834947.678725] ROS Serial Python Node
[INFO] [WallTime: 1469834947.687998] Connecting to /dev/ttyACM0 at 115200 baud
Then paused for about 10-15 seconds and outputs:
[ERROR] [WallTime: 1469834964.796031] Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino
Immediately after this the program starts to work normally and outputs:
[INFO] [WallTime: 1469834965.178744] Note: publish buffer size is 512 bytes
[INFO] [WallTime: 1469834965.179308] Setup publisher on raw_pot_data [geometry_msgs/Vector3Stamped]
Why could this be occurring? While everything seems to be running fine after the first error, it does make me nervous that something is waiting to crash.
* EDIT *
I performed further testing as per Steven_Daniluk's suggestion, however 'while(!nh.connected()) {nh.spinOnce();}' did not work for me.
I have tried using the standard tutorial HelloWorld script, only adding a single line at the top:
#define USB_USBCON
The result was the same sync error, then a successful connection.
I tried adding 'while(!nh.connected()) {nh.spinOnce();}' after 'nh.advertise(chatter)', however this did not work either (same error).
Furthermore I have seen even worse behavior where it will be stuck permanently with the sync error, and only reloading the Arduino script appear to fix this.
I have no idea what is going on.