Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

NI VISA .NET C# Serial Read in a loop

I am trying to build a test tool for a customer's hardware, the hardware will send "Ready" in Hex thru the serial once powered on. I've been thinking how to make the program actively listening this activity at the background. So far for some hours glancing in the library Help docs I could only think about using a loop and RawIO.Read() to constantly read from Serial until it hits the term "Ready". But this is so not elegant and inefficient and I don't see WaitOnEvent have similar functions to it. Anyone can point me into a right direction?

0 Kudos
Message 1 of 2
(919 Views)

For a serial connection you don't need Visa, the Net serialport class is simpler to use and works well,  for asynchronous reading you just need to implement the DataReceived event handler:

https://docs.microsoft.com/en-us/dotnet/api/system.io.ports.serialport.datareceived?view=dotnet-plat...

0 Kudos
Message 2 of 2
(872 Views)