LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write and read serial port simultaneously

Duplicate VISA session is the way to go for this

 

Open a session for your VISA Write loop and open duplicate a session for your VISA Read loop instead of branching a single VISA ref wire.

Then the VISA Read will not block the VISA Write and the two loops will operate independently of each other.

Besure to close each session, for if you don't you will keep adding VISA sessions and will see something like this from the VISA ref control drop down

 

Com1 (1)

Com1 (2)

Com1 (3)

Com1 (4)

so on and so on

Omar
Message 11 of 14
(1,426 Views)

@Omar_II wrote:

Duplicate VISA session is the way to go for this


I would still contend that you should be doing the whole check for data in the port before reading when you are dealing with non-streaming data.  I have actually had it so I got half of my message before the VISA Read timed out.  By doing the check for data, you are ensuring that you can get the entire message before the timeout stops the read.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 12 of 14
(1,423 Views)

I will try to implement it tomorrow and make some test to see ho it works.

 

Thank you very much!

Omar

0 Kudos
Message 13 of 14
(1,420 Views)

Thank you!!!!

Just finished spending "a few" hours trying to solve this.

 

Where this applies in my case is running on an embedded controller, the NI sbRIO

I use the serial port to log LOTS of diagnostic's, and also to receive an occasional command.

set the timeout to small and it crops my Tx.

set the timeout to big and it's waiting to long and my Tx queue overflows.

 

Thank you again!

-Jason

0 Kudos
Message 14 of 14
(292 Views)