LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Communication - Losing data from string

Well, are you checking the checksum to test for data integrity?

"You are strongly encouraged to check the checksum. You are strongly encouraged in developing software to implement checking of both responses and the checksums..."

 

Right there in the manual. 
So, the FW weenie knew he had a marginal driver and told you you can't depend on the data integrity without checking the checksum.  if the checksum fails toss the data- its not good.


"Should be" isn't "Is" -Jay
0 Kudos
Message 11 of 36
(923 Views)

Thanks,that is something that I am trying to do: that is either using the checksum or somehow reading the string back to check and make sure if it is correct, and then reiterate the command if it is not. However, I am not too familiar with this. Is there any way someone could help me with implementing a checksum? Thanks!

0 Kudos
Message 12 of 36
(919 Views)

I will receive a string like this:

 

AZ,09909.02,4,P01,      10.00,F5

 

I think the F5 would be the checksum. I am not sure how I would add the rest of the string without the F5 and do a checksum so that it equals to F5. Any help would be much appreciated, thanks!

0 Kudos
Message 13 of 36
(916 Views)

Grab everything before the last 2 hex characters (including the ,) string to byte array- sum array.  (this is the checksum of what you really recieved)  the last two characters can go through hex string to number and should be equal to the other value you calculated


"Should be" isn't "Is" -Jay
0 Kudos
Message 14 of 36
(912 Views)

How would I "grab everything before the array?"

 

Thanks

0 Kudos
Message 15 of 36
(906 Views)

String Subset

0 Kudos
Message 16 of 36
(904 Views)

I've tried string subset and the sum function as you have suggested, but I think I am still doing it wrong. I get a different checksum, even if I were able to switch it to hex. I've attached my program below. Thanks again.

0 Kudos
Message 17 of 36
(883 Views)

Save your VI with data saved in the controls as default.  Tell us what checksum you expect to get.

 

It is kind of hard to troubleshoot a VI that doesnt' have any data in it!

 

Do you have a manual that describes how they are calculating the checksum?

0 Kudos
Message 18 of 36
(871 Views)

I uploaded the manual for my controller in one of the above posts (CM-400 Draft).

 

I put in my command and get :

AZ,09909.02,4,P01,      10.00,F5

 

F5 should be the checksum I think in hex: see below.

 

Every response is preceded by the “AZ” string and to ensure valid communications every response ends with a checksum. The checksum is appended to responses as an ASCII representation of a two digit hex number representing a mod256 negated sum of all characters in the response up to and including the comma just prior to the checksum itself. This is similar to the line checksum used in an Intel hex file. You are strongly encouraged to check the checksum. You are strongly encouraged in developing software to implement checking of both responses and the checksums

 

Thanks for the help!

0 Kudos
Message 19 of 36
(853 Views)

!0.png

Don't let it kick your A$$.  The AZ isn't part of the calculation and the CSUM is sent as a two's complement.  (The idea being it requires fewer operations to test)


"Should be" isn't "Is" -Jay
Message 20 of 36
(847 Views)