LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Endian Conversion?

DonRoth wrote:
> Based on our discussions, I just put a byte swapper together for dbl
> type if anyone wants it. A general byte swapper can be envisioned
> with a case for each class (I32, I64, dbl, sgl, array? etc.) by
> programatically obtaining the cases from the classID or
> typedescriptor. What I did for the dbl type was first typecast it into
> I32 array and then do the byte swap word swap procedure, followed by
> rebuilding array, reversing array, and retypecasting back to dbl..Don

Using the previously mentioned Byte Swap and Word Swap together should
do the right (TM) thing for all possible LabVIEw data types including
when you apply it to a cluster with all kinds of data types in it.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 11 of 15
(1,853 Views)
I thought so to. But, I tested doing just that for a dbl and it did not produce the correct result. It seems to me you have to break it down to to 4 byte packets first (from the 8-byte dbl) which is what I did in my code and then the correct result is produced.

I think to get it to work in the same fashion as you are thinking, you would need also a 'swap double word' fx also....

Don
0 Kudos
Message 12 of 15
(1,853 Views)
Hi all
Ineresting some of the procedures.
I found this vi - old one from NI examples- that ilustrates some procedures to change endian

Regards
Alipio
---------------------------------------------------------
"Qod natura non dat, Salmantica non praestat"
---------------------------------------------------------
0 Kudos
Message 13 of 15
(2,244 Views)
I just downloaded and looked at the VI. I'm starting to think that if you don't have an array where the word and byte swap fxs are directly applicable, the method you proposed of first typecasting to U8 array, then reversing array, and retypecasting back to the original type, is probably best most general method and a polymorphic VI could be made....Don
Message 14 of 15
(2,245 Views)
Why not just flatten to string, reverse string, and unflatten from string?  I would think this would be the quickest way for scalars.
0 Kudos
Message 15 of 15
(1,750 Views)