If there is any good source regarding error correction in UART (or alike) communication I would be more than happy to dive into it and understanding how real life practical system implementing UART communication work. However I haven't found much on this topic even though I really searched for it.What I meant is that your scheme can’t be used in practice to make the channel more reliable because it is utterly naive and inefficient. Bit error rates on serial connections are well known and documented. Schemes to deal with them, which look nothing like yours are also documented everywhere. Even a naive scheme that at least used blocks of data would make more sense. The errors you are “correcting” are redundant if you check the actual data for errors. A simple checksum, or a CRC on packetized data would get you started in reliable data transmission.
The packet size can be calculated by the expected BER (Bit Error Rate) of the channel. I really think you’d find more to learn making a simple but practical error correction scheme than this.
Currently, only error checking is on hardware level - that is framing and overrun. You suggest I should focus on software based error correction like checksum and CRC and ignore hardware based ones (detected by internal logic of microprocessor)?