Hello people...
I am learning programming of arduino and I wanted to know how to implement the parity error detection of my recieved text from another arduino transmitter.
I am using lifi in which uses light blinking to transmit 1 & 0 bits through light to another reciever arduino...
So, how I can come to know weather the recieved bits are all correctly recieved by using parity error detection?
Below is code which enables me to write anything in between a start byte of < nd stop byte of > at serial port of transmitter and then sends it to reciever on which serial port I see the sent data....
You would have to implement that yourself. You need to decide on the parity you want (odd/even) and have the transmitter make sure that it does that. The receiver checks to make sure the parity is as expected and then accepts the byte received. This requires an additional bit per byte. If you are using a library to send/receive, you might not be able to do it unless it supports it.
An alternative might be to calculate some sort of checksum over an entire message you transmit and have the receiver check that.
blh64:
You would have to implement that yourself. You need to decide on the parity you want (odd/even) and have the transmitter make sure that it does that. The receiver checks to make sure the parity is as expected and then accepts the byte received. This requires an additional bit per byte. If you are using a library to send/receive, you might not be able to do it unless it supports it.
An alternative might be to calculate some sort of checksum over an entire message you transmit and have the receiver check that.
Plz guide me how to do checksum then...how to calculate or generate checksum?
Actually as I am sending bytes of text from 1 serial port to another serial port of another arduino I want to know how to apply checksum on it?
However you want to implement it. I would suggest you google "arduino checksum algorithm" and leverage all the work others have done. Whatever is easy for you to understand and implement
Perhaps the simplest kind of checksum to implement would be a, well, check_sum_: just add up the bytes (of course, treating each byte as its numerical value: a number from 0 to 255), and use the result as the checksum.
It appears from your original post that your are receiving text message over UART Port which is asynchronous serial protocol, and it supports only 'parity bit' for data validity check. You may choose one of the following options for 'parity' check bit; but, you have to write codes yourself to take advantage of it.
Serial.begin(speed, config)
Parameters
Serial: serial port object.
speed: in bits per second (baud) - long
config: sets data, parity, and stop bits. Valid values are
SERIAL_8N1 (the default: 8 data bits, no parity, 1 stop bit)
SERIAL_8E1 (8 data bits, even parity, 1 stop bit)
SERIAL_8O1 (8 data bits, odd parity, 1 stop bit)
It appears from your original post that your are receiving text message over UART Port which is asynchronous serial protocol, and it supports only 'parity bit' for data validity check. You may choose one of the following options for 'parity' check bit; but, you have to write codes yourself to take advantage of it.
Serial.begin(speed, config)
Parameters
Serial: serial port object.
speed: in bits per second (baud) - long
config: sets data, parity, and stop bits. Valid values are
SERIAL_8N1 (the default: 8 data bits, no parity, 1 stop bit)
SERIAL_8E1 (8 data bits, even parity, 1 stop bit)
SERIAL_8O1 (8 data bits, odd parity, 1 stop bit)
**Example**
Serial.begin(9600, SERIAl_8E1);
Thnx I will try to implement it meanwhile any other advices from u all will be appreciated...