LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

C code

Solved!
Go to solution

Sorry muks,

 

I just realised that LabVIEW computes in Big Endian ordering. However, i need to compute in Little Endian ordering. I know one easy way is to input the datas as 'FF81', '8B17' and '94' as they are constant. What if these values are not constant, i.e. it is dependent on other loop. So i wish to ask if there is any way to switch 81 and FF around?

0 Kudos
Message 11 of 18
(3,745 Views)

i used the flatten to string function with byte order 2 and managed to swap it around. are there better way to do it? Also, let's say my checksum is FF65E2 and i am only interested in getting 65E2, are there ways to filter out the FF?

0 Kudos
Message 12 of 18
(3,738 Views)

There is a function called Swap Bytes.  Look under the Numeric palette.

 

Change your data type to U16 instead of I32, then when it adds up, it should roll over after 2 bytes and you won't get the FF.

0 Kudos
Message 13 of 18
(3,737 Views)

Thank you Ravens Fan..

0 Kudos
Message 14 of 18
(3,727 Views)

Hi,

 

I have another problem here. For 18FF, 178B and 94, i am using I32. This is because after swapping, FF81 + 8B17 will result in bit overflow (from 16bits to 17bits). If i continue use I16, the MSB will be ignored and eventually the summation will not reflect the desired output.

 

As i need to send 18FF, 178B and 94 (together with the checksum) as a message, there will be an error. For e.g., the data to be send over are 'FF81', '8B17', '9400' and '68E1' (all after little endian byte ordering conversion). There is a need to stick to I16. If I32 were to be used, will there be an error? Because the receiving party will accept FF81 as the first two bytes and then 8B17,etc. If I32 were to be used, byte0 = FF, byte1 = 81, but will byte2 be equal to 8B? As I32 = 4 bytes. Please advise. Thank you.

0 Kudos
Message 15 of 18
(3,714 Views)

Hi all,

 

I tried to output them in array and they seems fine. So just want to double confirm that if FF81 and 8B17 were to be send, the receiving party will take byte0 = FF, byte1 = 81, byte2 = 8B and byte3 = 17? This is regardless whether i set FF81 and 8B17 as I32 or I64?

0 Kudos
Message 16 of 18
(3,712 Views)

Hi,

 

Have attached my vi here. I dont have issue with the data FF81, 8B17 and 9400. Now the problem is with the checksum 68E1. As mentioned, the receiving party only recognise the first two bytes. Therefore i need to shrink this checksum to two bytes. This is because my checksum is "FFFDE168" after byte swap it becomes "FDFF68E1" and i only need the 68E1 as my checksum to be send over. How can i "shrink" this data to two bytes because by changing I32 to I16, it is just for indicator/display purpose.

Download All
0 Kudos
Message 17 of 18
(3,701 Views)

Hi all,

 

Managed to solve that. First i use a swap byte (16bits) on "FFFDE168" to get "E168FFFD". Then output of this wired to a type cast to change the size to I16 to "E168". This is then wired to swap byte (8bits) to get the desired "68E1".

0 Kudos
Message 18 of 18
(3,689 Views)