LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

visa read 8 bits to 32 bits ?

Solved!
Go to solution

I run a counter  to measure the number  of  pulses  count  and i send that number  over  serial to bluetooth HC 06  to virtual serial port in my laptop . to do that i break unsigned 32 bit value count into 8 bit pieces a b c d  shift it 0, 8, 16 and 24 bit positions to the right to send it via  UART  .problem is how to  reassemble 8 bit pieces with labview on the other end.i have to shift a b c d 0, 8, 16 and 24 bit positions to the left and reassemble them with or .this is a c example :

unsigned char a,b,c,d;//final result dcba

a=0x09;b=0xEF;c=0xCD;d=0xAB;
intcount;
count=0x00000000;
count=count|a;
inttemp=b<<8;
count=count|temp;
temp=c<<16;
count=count|temp;
temp=d<<24;
count=count|temp;
0 Kudos
Message 1 of 7
(2,854 Views)
Solution
Accepted by topic author aymanch

Hi aymanch,

 

this would be a straight-forward approach:

check.png

You receive 4 bytes and put them together using the Join function.

 

There are other (more advanced) approaches like TypeCast or UnflattenFromString…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(2,847 Views)

In LabVIEW just use decimate array and join numbers.

!1.png

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 7
(2,842 Views)
But how do you know the byte order that you receive? Any serial read is asynchronous with what you are transmitting. You would need s prefix for each byte or one for the entire packet.
0 Kudos
Message 4 of 7
(2,827 Views)

Unflatten From String makes this easy.


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 5 of 7
(2,820 Views)

Oh, you can use an array if you have multiple samples...


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 6 of 7
(2,815 Views)

thank  you guys for your guidance and support that's really help me . just another question , i have two serial to bluetooth devices both send count to pc.what i want to know is can i have the name or mac adress anything i can identify bluetooth device without seding data to it with visa if possible.second thing can i connect on with a device the close session and connect with second device on the same com is that possible.i want to use bluetooth as rfid to identify a wagon if u understand what i mean .anyway i am new here so ur help push me to continue and to learn more .thanks.

0 Kudos
Message 7 of 7
(2,764 Views)