LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview - Calculation of Invert of Byte Sum

Hi,
 
I am attempting to address a remote instrument via its serial port. 
 
The command structure (Message header; Data body; and Message Tail) consists of a byte stream, the tail of which contains 12 bytes: 4 which refer to the 'Invert of byte sum of data body', and 4 which refer to the 'Invert sum of message'. Both these are formatted as integers.
 
Can anyone suggest how I should calculate these?
 
Thanks!
0 Kudos
Message 1 of 4
(3,258 Views)
Do you have some examples supplied with the protocol? That should make it easier to see the target.
 
As for how to work on it, you have various manipulation functions in the String>>Advanced, Boolean and Advanced>>Data Manipulation palettes. The locations might be slightly different in LV 8.x.

___________________
Try to take over the world!
0 Kudos
Message 2 of 4
(3,245 Views)

Without having a bit more detail of the protocol and the data type of your inputs I put this together that might be helpfull.  What I did here was to convert the input strings to arrays of bytes.  Then I could use the sum array function.  I converted the bytes to U32 data first.  The sum array will then produce a U32 (4 byte integer) that I invert (for "invert of byte sum") and that result and cast it back to a string.  Then I combinded the whole thing with the string concatenate.

In your message you mentioned that there are 12 bytes in the tail and only list the function of 8 of those bytes.  Do you know what the other 4 are?  Also you might need to check the endian of the inverted sum to make sure it matches what you protocol needs.

Hope this helps some,

paul

 

Message 3 of 4
(3,235 Views)

Thanks, this worked very well - problem solved!

A few quick points: the remaining 4 bytes in the tail are labelled as 'reserved' in the instrument command, and return an error code for the instrument message (which has the same structure). Also, the 'Invert sum of command' seems to include everything in the header, body, and tail up to the final 4 bytes.

I spent a week on this, so I am grateful for your input :).

Mark

0 Kudos
Message 4 of 4
(3,228 Views)