My situation is as follows, I have a robot that has 4 motor controllers attached to an arduino that has a xbee series 1 connected. Xbee has its default settings except baudrate which is set to 57600. My communication with the arduino is one way from pc to arduino sending 5 bytes every 40 milliseconds (one byte for command 4 bytes for 4 pwms). All calculations are done on the pc, all arduino does is read these bytes and apply pwm values to pins. Robot is never more than 10 meters away from the transmitter, nothing in between.
What I am seeing is sometimes even though I'm sending a motor commands the solenoid on the robot triggers I'm guessing some packets got lost and the next byte on the stream is equal to a solenoid command.
What I am trying to do is something like UDP where I can just send commands and any command that is send while arduino is processing to be discarded basically every-time I read a command from xbee I would like to get the newest command send from the pc? Is there a way to achieve this?