LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to simulate "expect" and do scripting on com port data?

send "this", expect "that", if true, do "the other" I initialize com ports and want to parse the stream, like EC2.0N+B1=ffff+ of nonsense chars, and have an array to lookup what to do upon exact literal char string.

I know my char end character, "+" but all strings are of different length. if it sees a "B1" and "=" then the next 4 chars must be converted ascii to hex and displayed on this box over here, (which I already labelled)

its simple using tcl/tk and expect, but I have no clue how this gets done using labview, even tho I took a course in this before.

looking at the help and texts, it seems almost impossible, but that cant be the case?

I can output text using concatenate st
ring with a CR+LF, wiring that to my "port write vi" inside some sequence structure...

but taking 115K streaming data from the com port and parsing it? im lost, help!
0 Kudos
Message 1 of 2
(2,910 Views)
Use Visa read serial and set the termination charachter to "+". Put this is a while loop. when visa sees the + it will return all charachters before this. Take the last 4 characters of the retured string and do whatever parsing you need to do. The loop will repeat. You set the stop loop condition. Either a button you press or a byte count (115K) or both or something else. Make sure the buffer is big enough to gather incoming bytes while you are parsing string. This really shouldn't be a problem though with the comparable speed of the serial port to the microprocessor.

You could either parse the returned string like stated above, or match on the "=" and take all after the match. Converion from hex ascii to readable ascii is as simple as wiring to a text box. To c
onvert bytes like 'ff' to some decimal value, there are hex string to decimal conversion vi's. All the tools are there, I promise.

Jared
Message 2 of 2
(2,910 Views)