This is my first question on StackOverflow and I'm still learning English. So I implore you your tolerance.
I'm working on a project where I need to receive data from USB serial port using Python (Pyserial library specifically). An Arduino sends me the data through a serial cable and then I receive it from a COM port.
I'm currently implementing a basic checksum process to verify that the transmitted data arrived complete. From the Arduino I add the value of the data I am transmitting and set to checksum field, which will be transmitted too. Then, on the computer, I perform the same operation over the data and verify that the sum is equal to the value of the checksum field.
My question is. Should I worry about this or that task is already performed by USB protocol?
If someone could give me some reference, it would be very helpful for me.
This is how currently I am calculating the checksum:
{
s1: 425.2,
s2: 426.4,
s3: 78.2,
s4: 785.2,
chksum: 1715
}
The USB does not correct the serial data. It is just a bus that the CPU uses to talk to the serial port with. You idea of adding some checksum to the protocol that you use to talk between the Arduino and PC is good and sound idea.
A very common hardware protocol used by serial ports is the RS232. It contains some support for error detection using a parity bit. If the parity bit isn't correct the received byte will just be thrown away. So I don't think it would be much help in you case.