I have to revert back to an old thread i opened. I have to add the error detection mechanism in my RS-485 Library. 3v0, can you please advice the simplest error detection (not correction) algorithm consuming few bytes.
What i have in my mind is to generate some kind of a hash which i will transmit at the end of data bytes (From transmitter to Receiver node). Then once the Receiver has all the bytes, it will again generate the hash and compare both of them. If the hash matches, there is no error in bytes, otherwise it will request the complete frame again.
Now i am unable to write a hash function in C to accomplish this which takes about like 1 or two bytes.
Also one more problem is that if i send Address 1 in my frame (here 1 goes in 9 bit UART mode) the receiver doesn't respond. For anyother address it responds okay. Now i checked the ASCII table and 1 means SOH (Start Of Heading). Can there be anything wrong with sending SOH character in UART as first character?
Also can you please help me with the following problem:
Also one more problem is that if i send Address 1 in my frame (here 1 goes in 9 bit UART mode) the receiver doesn't respond. For anyother address it responds okay. Now i checked the ASCII table and 1 means SOH (Start Of Heading). Can there be anything wrong with sending SOH character in UART as first character?
I found a CRC16 code library written in C. However it calculates the CRC for one byte.
Will it still be any good if i calculate CRC for all the data bytes and then XOR them together and send it or will it ruin the CRC calculated all together?
okay i have implemented the CRC16 algorithm into my RS-485 library. It is working quite well now.
I do have a small stupid question though. When we send a value from an integer variable, are the first 8 bits truncated (because serial data go in bytes and since int is 16 bits)