LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Joining two 2-byte values into 4-byte value in LabWindows

I am using Modbus communication to obtain measurement data from a temperature controller. My measurement device returns the temperature as two short integers representing high and low 2-byte values. I am now trying to join those integers together for a 4-byte value. Does anyone know how to join these together in LabWindows? Thanks
0 Kudos
Message 1 of 2
(2,771 Views)
In ANSI C (CVI), you can do it several ways: either shift the upper word 16 bits to the left or multiply it by 2^16, then add that result to the lower word.
int upperWord, lowerWord, longWord;
// the following statements result in the same value:
longWord = (upperWord << 16) + lowerWord;
longWord = (upperWord * pow(2,16)) + lowerWord;
0 Kudos
Message 2 of 2
(2,771 Views)