From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

visa read write to serial port independently & simultaneously !

Solved!
Go to solution

Hello all !

I need to read and write data to and from a serial port (rs232) independently and simultaneously .

i'm sorry that i can't put a picture of this but it is very simple :

i used "configure serial port" and passed the resource reference to two while loops.

one loop is reading data and the other loop is writing data to the port.

the problem is when the read loop (read from serial function) waits for data - it locks the other loop from running (write to serial function is blocked).

i searched the forum and find that visa open function has "duplicate session" option - is this what i need ?

if true, can anyone explain exactly how to wire and use it in the correct way ?

thanks a lot.

guy.

 

 

0 Kudos
Message 1 of 9
(7,824 Views)

I have no idea how you did your coding so that one loop is blocking the other since you don't want to post an image. Going to be hard to tell you what to change.

0 Kudos
Message 2 of 9
(7,814 Views)

hookso,

It is my understanding that a serial port may pass data bi-directionally, but the information cannot be passed simultaneously. You may need two ports or perhaps a parallel port.

Ben D.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 9
(7,793 Views)

A picture of my problem is attached !

0 Kudos
Message 4 of 9
(7,770 Views)
Did you look at the shipping serial examples? Why don't you have a VISA Bytes at Serial Port and only do a read when something is there?
0 Kudos
Message 5 of 9
(7,765 Views)

because i will have to poll the port all the time.i want my code efficient.

0 Kudos
Message 6 of 9
(7,752 Views)

I fail to see how periodically polling for bytes is any less efficient than constantly doing a read that times out but the duplicate VISA session can be tried. It's an option with the VISA Open function.

0 Kudos
Message 7 of 9
(7,735 Views)
Solution
Accepted by topic author hookso

Ok , i found an example that solved my problem : a VI called  serialduplicatesessions.

The file is attached.

this is the link for any case : http://zone.ni.com/devzone/cda/epd/p/id/1727

Message 8 of 9
(7,709 Views)

It also solves my problem.  Thanks

0 Kudos
Message 9 of 9
(5,424 Views)