S
S
sidsukana2015-09-17 12:20:40
Arduino
sidsukana, 2015-09-17 12:20:40

Is it possible to lose data via UART?

I will describe the situation in more detail.
There is a PC that connects to the Arduino Uno via USB (UART). There is a need to make communication between them in the form of packets (analogous to communication via TCP).
Suppose there is a packet structure: a header of 2 bytes (1 - data size, 1 - opcode), then the data size is in the header.
Serial connection with 9600 8N1 (8E1) configuration.
USB 1 meter)
If packet reading is not controlled with start and end markers, or with hashsums, can data loss or corruption occur, causing the data stream to be read out of sync?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Martyanov, 2015-09-17
@vilgeforce

A much more different situation can happen: you start processing the packet not from the beginning, but from the middle and get garbage instead of normal data.

A
Alexander Komarchuk, 2015-09-18
@AlexanderKomarchouk

Loss of data during transmission over serial protocols is possible. If you need to overcome this situation, then turn your attention to the Kermit protocol .
In the 90s, we connected a PC to a UNIX server via RS-232, and using the Kermit software package of the same name, we not only worked in the terminal, but also transferred various files (including binary ones) between systems connected by a three-wire line.
Study the sources (you will learn a lot of useful things for yourself), simplify them to the level of use in Arduino (or take them as an idea), and you will succeed.

V
vanyamba-electronics, 2015-09-24
@vanyamba-electronics

The data is transferred via the USB protocol. In the case of a virtual COM port, the protocol implies resending the packet if the packet is received with an error.
But they can be lost on the Arduino side if the received data processor does not have time to process them during the time between packets. This problem can be easily solved if the computer, after sending the packet, waits for a response from the Arduino that the packet has been received and processed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question