How to create a safe UART communication protocol?
I think you should define longer commands including probably checksum or CRC and wait for an ACK / NACK or error condition.
You can take examples from easy protocols like TFTP (RFC 1350)
For a safe communication you should consider all possible threads to your communication line. Therefore you need to define, if the system is accessable from the outside (third party systems e.g. wireless)
In generall you have to think about the following threads:
- repetition
- ommision
- resequencing
- manipulation
- delay
- insertion
- corruption
Standard measures against threads are:
- Sequencing or timestamps
- time supervision
- unique source and destination codes
- response
- identification precedure
- some kind of checksum, hash code ...
- cryprographic techniques some of these you already have implemented with your simple protocoll.