LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Asynchronous serial read methods

I'm still a little hesitant about events in LabVIEW using data coming in (not user events, mouse click, keyboard, etc.). When I'm looking for an async serial stream to start coming in, I currently use the upper loop in the attached VI (38.4 KB, hex string in, the "stop loop control" is actually set from the serial bytes coming in - a 2-byte terminator) and it works fine, getting the whole string I need. It's polling the port every 1 ms until something comes in.

 

Would the lower loop give me the same functionality without doing this continuous polling, or would it actually do something different? If I were to use this one instead, am I blocked from writing to the same port in another part of the code until I get some data in and the while loop stops, or is there some way to barge in and then start looking for data again?

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 1 of 3
(2,453 Views)

You can write to the same serial port in other parts of your code.

 

I have never used serial events before, so I don't know if there are any oddities to it.

 

In both examples, I would use the bytes at port to read all the bytes at the port that are available at that moment and concatenate them to the string rather than just one.

0 Kudos
Message 2 of 3
(2,452 Views)

@RavensFan wrote:
In both examples, I would use the bytes at port to read all the bytes at the port that are available at that moment and concatenate them to the string rather than just one.

I'm only reading one byte at a time because of the way I have to determine the stop situation (because of dealing with other, older, inherited code), although, looking at that part of the code, I might be able to remove that here and do single-byte checking down the line. I know it slows me up a bit, sl I'll check that out.

 

Cameron

(Steelers Fan)

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 3 of 3
(2,449 Views)