02-19-2009 07:27 AM
Dear all Dasylab users.
I am using Dasylab to connect to INCA. By ASAP3 interface.
I get a ASAP protocol "Serial version", it listed some commands.
And I find that every command need a checksum by word.
e.g. INIT command
code is 0x02
the command should be \x00 \x06 \x00 \x02 \x00 \x08
|LENGTH|CODE |CHECKSUM|
How to caluculate checksum?
00 06
+ 00 02
--------------------------
00 08
That's called least significant word.
I wonder who can help me with the checksum calculation.
02-19-2009 08:21 AM
I'm not sure how to compute the checksum for you, but, once computed, it won't change. DASYLab won't need to calculate it, and it can be a fixed element of the data request command.
If you do need to compute the checksum on the fly, the Help offers the following information. I don't have a lot of experience with devices that need checksums, other than to figure out how to turn it off if the communications channel is mostly error free.
Output Format (RS232)
The string to be sent may also contain one or more check bits. Use \c followed by the type to build the checksum. The position in the string also defines the position of the check bit. The following checksum types are implemented:
horizontal sum: \cq
All bytes of the string before \cg are added (starting at the beginning of the string or after the last checksum sign, including data values). Carries are not considered. The resulting byte will be placed at the defined place in the data string.
CRC-check: \cc
All bytes of the string are calculated using the crc16 algorithm (cyclic redundancy check). The both resulting bytes will be placed at the defined place in the data string.
XOR sum: \cx
All bytes before the checksum sign (starting at the beginning or with the sign after the last checksum sign ) of the string (also incl. measured values) are combined with the Exclusive-Or operator. The resulting byte will be placed at the defined place in the data string.
XOR sum with control character suppressing: \cy
Works similar to \cx, but the resulting byte is increased with 32, if the origin value is less than 32.
02-21-2009 06:27 PM