Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA SERIAL terminaison character producer consumer model

Solved!
Go to solution
Hello,

I'm developping an IHM to receive data from a sensor.
The hardware sensor is built  in my company and I have no flexibility with it.Only 2 wires RX & GND, no possibility of
hardware handshake.

The sensor send to a RS232 com port some Hexa string every 1s, 10s, 60s or more  and I can't know the sending frequency.
So I scan every 20ms data at serial port with VISA Read and bytes at serial port. At the end of the Hexa string sent by the sensor
there is a termination character but I don't how to use it.

I'm using the producer/consumer model to not lose any data.

Actually I read and concatain received data (with VISA READ) until I have received the right number of bytes (because I know the size of
the hexastring sent =495 bytes).
But in the real working, I will don't know the size of the data to receive from the sensor.(<500 bytes)

So, I want to use the terminaison character to stop the producer loop who contain VISA READ.

What special function or property node must I use to make this operation?
 

I attached a JPEG screenshot of my code.

PS : for the developpment of the VI, I simulate the data of the sensor with an another PC who sent Hexa string in loop
with termination character.
0 Kudos
Message 1 of 4
(3,973 Views)
The VISA Configure Serial Port has inputs called 'termination char' and 'Enable Termination Char'. If your termination character is a single byte, just pass the hex value of it to the 'termination char' input and wire a True constant to the 'Enable Termination Char' input. For the VISA Read, you can wire some large number to the bytes to read input and the VISA Read will automatically terminate when the term character is detected.
0 Kudos
Message 2 of 4
(3,970 Views)
Solution
Accepted by topic author Chri=s=tophe

Chri=s=tophe wrote:
Hello,

But in the real working, I will don't know the size of the data to receive from the sensor.(<500 bytes)

One method to read an unknown number of bytes: Put just the Bytes at Port into the while loop (not the read). Put the output of Bytes at Port into a shift register, and compare the last iteration with the current one. When the number stops changing (current loop = last loop) then all bytes have arrived. Bail out of the while loop then directly to VISA Read.

Richard






Message 3 of 4
(3,951 Views)

Thank you Broken Arrow!

It's working very well.

0 Kudos
Message 4 of 4
(3,878 Views)