LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert "8 byte, 2's complement, Least significant byte first" number into a decimal number?

Solved!
Go to solution

Their driver has the string simply reversed and type-casted into a long integer, and it's output doesn't seem to be accurate.

Little Endian.png

0 Kudos
Message 11 of 29
(2,038 Views)

The manual isn't very clear as to what the data should look like.  Since it has some character commands, and ends with a CR LF has a terminator, I'm going to assume that the data is sent as 8 hexadecimal characters (letters "A"-"F" digits "0" - "9") rather than has a hex byte where 4 bytes make up the integer in a normal binary format.  When there is a chance that the ASCII characters of CR (hex 0D) and linefeed (hex 0A) would show up in the data and be misinterpreted as the termination characters.

 

Do you have an example of what a string actually looks like?

 

Try using Hexadecimal string to number on two hexadecimal characters at a time.  Reverse the resulting array, and the typecast it to an I32.

 

 

Message 12 of 29
(2,028 Views)

Here's a screen shot of how the output looks like.

 

0 Kudos
Message 13 of 29
(2,026 Views)

The screenshot is missing.

0 Kudos
Message 14 of 29
(2,018 Views)

@rosh wrote:

Their driver has the string simply reversed and type-casted into a long integer, and it's output doesn't seem to be accurate.

Little Endian.png


Actually,  the string is reversed twice in the driver.  I'm not asking why.  but the string data is read, reversed sent to the next subvi and reversed again cast to U32 and multplied by 1e-16. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 15 of 29
(2,012 Views)

String output.PNG

 

Here's the screenshot of the string outputs

0 Kudos
Message 16 of 29
(2,002 Views)

Can you post it as a VI, or a screen shot with hex display turned on?

 

This is getting more confusing because it looks like you have a total of 8 bytes there after all.  (And they do look like actual binary values rather than the HexCharacter representation.  Which would be a bad idea for a communication protocol that relies on the ASCII characters of CR and LF to terminate a string.

0 Kudos
Message 17 of 29
(2,000 Views)

Bill, They do some fairly odd things in the driver to account for those \r  (It really isn't robust)


"Should be" isn't "Is" -Jay
0 Kudos
Message 18 of 29
(1,985 Views)

Here's the vi. According to the manual the output is in hex format.

0 Kudos
Message 19 of 29
(1,975 Views)

  

0 Kudos
Message 20 of 29
(1,972 Views)