LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

REVERSE BYTE ORDER

Hi,
I have a simple question! I'm trying to rotate a 4 byte hex digits in  a string  as follow:
                                                 
Byte 0                     Byte 4
  A1        F7    14       9C                =>>           9C      14     F7     A1 
 
Coudn't find a built in function to do this quickly. Any suggestion.
Thanks
dphan128
0 Kudos
Message 1 of 12
(8,567 Views)

Check out

Programming / String / Additional String Functions.  There is a VI called reverse string.  Its icon looks like ab --> ba

Message Edited by Ravens Fan on 04-02-2007 09:50 PM

Message 2 of 12
(8,562 Views)
thank you for the reply. But I have tried it before, and the result was not as expected since it changed the bit order also. And in my case I just want the byte order changed.
dphan128
 
0 Kudos
Message 3 of 12
(8,545 Views)

1   are your bytes in a byte array?  if so you could reverse 1d array

2   you could also look at the data manipulation pallet under the numeric pallet and try the swap bytes or swap words

3   if you are building an array of strings or numbers you can prepend or append values to the array depending on how you wire the build array

4   you could use queue's and use the enqueue element at opposite end then when you dequeue it will be reversed

5   also in the data manipulation pallet you can use the split and join numbers to manipulate bytes but you may need to use the shifting or rotating vi's when joining them back together

Message Edited by James R on 04-03-2007 10:40 AM

- James

Using LV 2012 on Windows 7 64 bit
Message 4 of 12
(8,543 Views)
James wrote;
 
"

2   you could also look at the data manipulation pallet under the numeric pallet and try the swap bytes or swap words

 
"
 
A slight variation on this is "try the swap bytes [FOLLOWED by] swap words".
 
Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 5 of 12
(8,541 Views)
Based on what you described in your original message, my answer in reply #2 should have worked.  But now I realize you didn't have a string of 4 bytes in hex format, but a string of 8 bytes whose characters represent 4 hex bytes.
 
Attached is a VI in LV 8.2, along with the front panel and block diagram to describe the ways of doing it.  If it is a string of 8 characters representing 4 hex bytes, the bottom method should work.

Message Edited by Ravens Fan on 04-03-2007 01:44 PM

Download All
Message 6 of 12
(8,518 Views)

Thanks Ravens Fan. This is exactly what I need.

dphan128

0 Kudos
Message 7 of 12
(8,505 Views)

Will this work for bytes endian conversion?

I am trying to reverse a string of bytes generated in C# and transmitted over UDP to labview myRIO. Doesn't seem to work in my case.

0 Kudos
Message 8 of 12
(7,470 Views)

Maybe, maybe not.  It depends on what you are trying to send, how long it is, what the datatype is supposed to be.

 

I suggest starting a new message thread.  Attach some examples as to what the data looks like, and what it should be converted to.

 

Look on the Numeric >> Data Manipulation palette for some functions that help with endianism.

0 Kudos
Message 9 of 12
(7,465 Views)

@Lexilighty wrote:

...and transmitted over UDP to labview myRIO.


That sounds like a place to use the Unflatten From String to get the data in the format you need.  There is an input for Endianness.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 12
(7,453 Views)