This is one of the more complicated issues of the robot. We’ve got to be able to receive every bit of data that is sent to the robot. Transmitting data isn’t going to be that hard, but encoding to make it reliable will take up a significant portion of the main loop.
Fortunately, in autonomous mode we only need to transmit when certain events occur. Manual mode requires receiving commands and might be a bit more tricky. The second link here describes a really good protocol method and methods for keeping the protocol nice and clean and easy to receive.
The actual protocol would look something like:
Basically ‘U’, converted to its ASCII # and then to binary is a good ‘0101’. This maintains good transitions and provides a solid lock for the PC or Tower to lock onto the data-stream. When an event occurs such as a dot is found, the robot enters a transmitDot routine which would send out a packet prepended with ’;;’ and then the data-code for “dot found” along with its node number. The packet would be assembled, padded to the fixed length we decide on, and a checksum value would be calculated and appended to the end of the packet. This would then be transmitted instead of UUUU…
The receiving modules would simply be scanning their input streams for ’;;’ The receivers would then read in the next two bits to determine the Node number. This is useful because the tower would simply quit listening when it determined that the packet was sent by the PC for example. When the receivers detect ’;;’ and the node number they are listening for, they then read in the next X bits which is determined by our fixed packet length. This data is then checksum and that checksum value would be compared to the checksum bit at the end of the packet.
If some sort of data corruption occurred (and it will) that packet would be discarded. Otherwise we’d decode the packet and take appropriate action on the PC, Tower, or Module.
We could even institute a acknowledgment system. When a PC receives a packet, successful decodes and uses a packet from the robot, it could send out a packet to the robot in the form of a code that meant “message received”. If the robot didn’t receive an acknowledgment packet within an arbitrary amount of time (say 3 seconds) it would retransmit the packet X amount of times. If it received the acknowledgment it would continue on with its program.