I realize that this may be too specialized a cpp question but I thought I'd just give it a try in case there are any serial programming gurus here. Every now and then, I have to restart the create because i am getting bad serial data. What is the proper way to reset the serial buffer?
The create is an Irobot Create 1. It is a programmable robot using a serial programming interface.
While the question I posted here is more general. The issue is a consequence of my failure to request streaming data from the robot. Somehow, starting and stopping the stream results in corrupted sensor data packets in the read line. Not to mention that I couldn't get any data from the irobot create using the streaming sensor method. I can parse the start byte and the packet ID byte but the data byte is zero.
I was trying to find a not so drastic reset of the serial buffer in this thread to see If I can make the system recover from a bad sensor stream attempt. That would at least shed some more light into the issue. The tcflush did not restore the system to before the sensor read. A shutdown and restart fixes the issue.
May I refer you to this thread and anybody else who wish to reply:
Let me guess the scenario:
The sensor permanently sends data to the serial port. Then some times later the device is reading from the serial port, correct?
The would mean that it is rather unlikely that you get valid data at the beginning. So you have to read until you determine a correct dataset.
Flushing doesn't help here. It is actually only for write operations.
Thanks for your response. I will continue to study the problem. I will post as soon as I have more info. My real life work has gotten busier at the moment. I am also leaning away from the serial streaming solution at this time in favor of sensor packet requests. It would be nice to figure out the problem though.
Thanks
Chris