09-30-2011 07:24 AM
Hi All,
My query is regarding CRC in Modbus RTU.
I know Modbus library provided by NI calculates the CRC, but i want an event (boolean or int etc) when the CRC for transmitted and received does'nt match so that i can call it as a error. and not perform furhter operations.
Am i missing anything?
Regards,
Shrenik
Solved! Go to Solution.
09-30-2011 07:48 AM - edited 09-30-2011 07:49 AM
Hey shrekt,
the equal? fuction in the compare pallete can except most data types and outputs a boolean true if the values are the same. Could this not be used to help?
Regards,
Matt
09-30-2011 08:29 AM
Also, if you run the Modbus library CRC function on a string that already contains the CRC bytes, the CRC output of the function will return 0 if the CRC is correct, and something else if it is wrong. So you can just take the string, put it into the CRC function, and do an =0 on the CRC output of the function to get your boolean true or false.
09-30-2011 02:16 PM
If you're using this MODBUS Library there's a bug in the crc calculation, which is is fortunately trivial to fix. Change the data type of the Exception Code indicator from U8 to U16 in MB-CRC16.vi (check the comments on the library page for more info).
The bug is over 2 years old so I wouldn't wait for a fix from NI (I guess because the DSC module is the official way to use modbus, and that's an "example program").