LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

byte reversal

First off, I am using CVI LabWindows version 7.1.  How do I reverse the byte order? I am receiving the mirror image of the data being sent to me over a TCP connection.  for example, if the data being sent (in hexadecimal) is 01020304, the data that I will receive is 40302010.  How do I fix this problem?



Thank You,

Jem
0 Kudos
Message 1 of 2
(3,009 Views)
Hi Jemellie,


short SwapBytes (short data)
{
char temp;

union {
short data;
struct {
char byte_1;
char byte_2;
} order;
} swap;

swap. data = data;
temp = swap.order.byte_1;
swap.order.byte_1 = swap.order.byte_2;
swap.order.byte_2 = temp;
return swap.data;
}

Just call this function with the two byte value you want to swap the byte
order. The return value is the result.

Grettings from Bremerhaven (Germany)

Norbert



"Jemellie" <x@no.email> schrieb im Newsbeitrag
news:1216068013380-743746@exchange.ni.com...
> First off, I am using CVI LabWindows version 7.1.&nbsp; How do I reverse
> the byte
> order? I am receiving the mirror image of the data being sent to me over a
> TCP connection.&nbsp;
> for example, if the data being sent (in hexadecimal) is 01020304, the data
> that I will
> receive is 40302010.&nbsp; How do I fix this problem?Thank You, Jem


Message 2 of 2
(2,993 Views)