I am looking for a reliable serial protocol that can be used for communication between PC host and a MCU programmer. Currently I've devised a prompt-like protocol, which has been great for testing, but I need reliability and functionality in terms of error checking, ACK/NACKs, parameter parsing, etc. The device I am working on will communicate with the host PC via UART.
I've done some testing with the current protocol, and it turns out the PC sends data too fast for the MCU to react, and a lot of data is lost. In the beginning I though I would be able to get away with a custom protocol, which I've used a lot (prompt-like, no error checking, ASCII-based), however it appears it's not good for the application.
Edit: The programmer I am working on will be used with the BDM protocol of some very old MPC55x processors. The custom serial protocol currently has the following properties:
- Data from MCU is encapsulated in
- Data from host (PC) is not encapsulated but must end with
\r. That's makes it easier to use a terminal
- Each command returns a response
- The MCU returns an error response if the command is not recognized
- The host software waits for a valid response a number of seconds after each command is sent. If no response is returned, application takes action
- The host app provides error checking in terms of reading back data which has been written in the flash
My question is: Is there a serial protocol, which I can employ, and which would have all the features above (and possibly CRC/checksum).
Now when writing it all down, it appears that such a protocol will be a hard thing to find, since I want to be able to use the console for debug - that makes encapsulating messages hard. Therefore I am considering moving away from that concept towards a more machine-friendly interface.