LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

bit Reversal

How do I reverse the bit order? I am receiving the mirror image of the data being sent to me.  for example, if the data being sent id 01020304, the data that I will receive is 40302010.  How do I fix this problem.  Another thing, can the ClientTCPRead be used twice like sequentially? first to read a 4 byte number then read a 16 byte number?


Thank You,

Jem
0 Kudos
Message 1 of 9
(3,562 Views)
You actually seem to be referring to reversing the bytes, not the bits. TCP/IP functions read bytes, but it's usually returned as a string. You can convert the string to an array of bytes using the String to Byte Array function, and then just use a Reverse 1D Array function to simply reverse the order:



For your second question, I'm not sure what this "ClientTCPRead" VI that you're referring to is. The TCP Read function operates by you telling it how many bytes to read. Thus, to read a 4-byte number, you feed it a 4, and for a 16-byte number you feed it 16 for the "bytes to read" input.


Message Edited by smercurio_fc on 07-14-2008 02:23 PM
0 Kudos
Message 2 of 9
(3,556 Views)

I think the TCP functions now let you specify endianess.

Try swap bytes swap words to get your bytes in order.

Yes you can have two reads in a row.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 9
(3,554 Views)
Hmm... 40302010  ---> 01020304  looks to me like a reversal of bytes rather than an endianess problem. Unless the poster is really trying to talk about endianess, and the question about reversing is just the wrong question.

Also, the TCP Read has no input regarding endianess. At least in 8.2, and the online manual for 8.5 shows no such input. Now I'm confused.
0 Kudos
Message 4 of 9
(3,540 Views)
Thanks for everyones reply. (I am using CVI labwindows btw 7.1)

 I am talking about the bit reversal, I dont think it is an endianess problem as well.  The second question was an unrelated to the bit reversal (sorry). 
0 Kudos
Message 5 of 9
(3,534 Views)

Hi Saverio,

It was "Unflatten from string" I was think about (I usually have this nearby when doing TCP).

I believe a byte swap followed by a word swap will produce those results.

I believe endianess usaully refers to byte order and not bit order.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 9
(3,524 Views)


Jemellie wrote:
Thanks for everyones reply. (I am using CVI labwindows btw 7.1)

 I am talking about the bit reversal, I dont think it is an endianess problem as well.  The second question was an unrelated to the bit reversal (sorry). 

Well, this is a LabVIEW board, so you''re probably in the wrong place anyway, but your question is not clear.

" for example, if the data being sent id 01020304, the data that I will receive is 40302010"
If this is a hexadecimal formatted U32 number (00000000-FFFFFFFF), this actually IS a plain byte order problem (endianness). You need to give us a full dataset and tell us the format of the data, so we can tell what's the approriate solution.
0 Kudos
Message 7 of 9
(3,517 Views)

@Jemellie wrote:
Thanks for everyones reply. (I am using CVI labwindows btw 7.1)

Then the LabWindows forum is the one you want. This is the LabVIEW forum, the graphical programming language.
0 Kudos
Message 8 of 9
(3,515 Views)
I thought I searched for CVI lab windows.  I apologize. Thank you Nonetheless.
0 Kudos
Message 9 of 9
(3,511 Views)