I am trying to implement Modbus Ascii slave over Serial port , but have trouble understanding LRC calculation. I stored data that is sent from master in uint_8 array, and don't understand next part, do ascii characters that are sent from master need to be converted to their hex value before calculation? If calculation is done with hex characters how does conversion from ascii char to hex version of it look like?
Asked
Active
Viewed 733 times
0
-
1Welcome to StackOverflow! Please take the [tour] and read "[ask]" to learn how this site works. -- You don't need to "convert" ASCII to hex, it's all just interpretation of the same binary value. For example, the ASCII character `'A'` has the binary value 1000001 or in hex 0x41. You can simply use the ASCII value as an integer. – the busybee Nov 01 '21 at 20:53
1 Answers
0
Go to Appendix B on this document for LRC calculation
https://modbus.org/docs/Modbus_over_serial_line_V1_01.pdf
Modbus ASCII sends the ASCII characters of the hexadecimal value, the same happens with LRC byte that is send as two ASCII characters.

from56
- 3,976
- 2
- 13
- 23