USB Virtual Com to send/receive message
I have enabled USB Device FS and successfully use it as a virtual com port.
I now need to determine the best way to send messages from master to slave over this port, and how I will handle potentially corrupted data, timeouts, and how enabling CRC will help.
My message format includes a start byte '12', then a payload size byte, then a command byte, followed by data payload bytes and 2 CRC-16 checksum bytes.
What happens if the master sends a payload of 2 bytes, but the slave receives corrupted data and interprets the payload size as 64 bytes? I have the master 'retrying' if it does not receive a response back from the slave after 100ms, but should the slave also have a timeout to reset? I can see the slave expecting 64 bytes in my case, potentially never parsing a complete valid message, or the slave and master becoming endlessly 'out of sync' . I'm seeing the timeouts on the master and slaves potentially triggering in a way that would also cause them to become out of sync endlessly.
Thank you
