From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing data from Serial Port one byte at a time

Hi everyone,
 
        What I want to do is read in from the serial port byte by byte and parse each byte that I am reading in. The size of the data read in varies. How do I do that? I can do using .dll but I want to learn how to do it in labview. I searched through the forum for something similar but no luck. I have seen some that puts the VISA read in a while loop and others that puts the property node,  "bytes at Port" in a while loop. What is the difference in doing either way? I am using Labview 7.1 Can anyone point me in the right direction?
 
Thanks
0 Kudos
Message 1 of 9
(7,376 Views)

Bytes at Serial Port is used to see how many bytes are waiting to be read at the serial port.  They are not read yet.  You can use Bytes at Port and wire the output to the VISA Read function as the number of bytes to read.  The output will be a string.  Use String to Byte Array to convert the string into an array of bytes.  Then you can wire the array into a For loop with indexing enabled and the elements can be parsed one at a time.

The key is to read all bytes at once and then break them up into individual bytes.  Alternately, you can wire a number constant 1 into the number of bytes to read input of the VISA Read function and work with that one byte, then repeat in a loop to get the next byte, and so on.

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 9
(7,370 Views)
I see tbob, thanks. I have seen 'bytes at Serial Port' in a loop and the VISA read outside of the loop. Can you explain why that happens? I thought you could just use the 'bytes at Serial Port' once to read in the total number of bytes at the serial port.
0 Kudos
Message 3 of 9
(7,368 Views)

Hi,

Maybe you can have a look at this VI. I use it to communicate in a command-answer situation.

Take a look at the diagram to see how things are done and read the documentation. 

0 Kudos
Message 4 of 9
(7,352 Views)

Hi guys..

I'm still a beginner in using labview tcp/ip function. for now, i have a project to read the labview data with java programming language so that i can monitor that data using any devices that using java, such as PC or cell phone. my task for now is to determine the format of data that being sent (its type, length, etc), coz as far as i done until now, the data that read in the java is still a raw material so that i dont know how to gain the information from that data.

my question is :

- how does the type cast work in changing the data format from one to another?

- how does the bytes to read in tcp read work? coz when i'm changing the length of bytes to read constant from 4 bytes to another, the data is becoming mess up. As far as i know, the bytes to read only read the first "constant number" byte in the tcp read to determine the length and type of the data..

thanks

0 Kudos
Message 5 of 9
(7,033 Views)

Hi,

 

Did you got the solutions which you were looking for, if yes can you share the same with me as i need exactly the same.

 

Thanks

Aniket

0 Kudos
Message 6 of 9
(3,674 Views)

To what post are you referring ? Beside that this is a very old thread. I would suggest that start a new thread and explain clearly what you problem are and what you have done to get to a solution.

 

Kees

0 Kudos
Message 7 of 9
(3,642 Views)

i am referring to the very 1st post posted by NEWGUY .. 🙂

0 Kudos
Message 8 of 9
(3,635 Views)