From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DASYLab

cancel
Showing results for 
Search instead for 
Did you mean: 

Checksum by word

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.

0 Kudos
Message 1 of 3
(7,251 Views)

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)

Checksum

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.

 

 

Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.
0 Kudos
Message 2 of 3
(7,248 Views)
thank you very much for your reply. You mean I don't need to calculate checksum, Indeed! But you know, this checksum is not a standard one. So Dasylab did not provide us the way to automaticly gen. it. Meanwhile, commands are different, some commands also contain some strings that you can never meet. So I cannot calculate them before. Here I just want some one can give me a way to automaticlly generate the checksum word.  BTW, word in ASAP means two bytes, and checksum word means add all words before and just keep one word as a checksum word.
0 Kudos
Message 3 of 3
(7,229 Views)