Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I implement 'WaitCommEvent' in VISA for RS232?

I am trying to use VISA to control my RS232 device as a beginner.

I would like to know how I can implement a fuction 'WaitCommEvent' of VC++ in VISA. The usage is as follow(You can check it in MSDN):

WaitCommEvent(hFile, lpEvtMask, NULL);

The function waits until any event happens in RS232. For example, if a character is available in buffer, the function stop.

If I open RS232 connection with CNiVisaSession, what corresponds to 'hFile?.' Or, how I can implement the function in VISA?

Thank you very much.
0 Kudos
Message 1 of 2
(3,094 Views)
Hi,

One option for you here that could be very easy is to set the timeout for a very large value, then just make a read call to the serial port. The function will not return until the timeout completes or when you receive the data. You may need to play with the termination character and the number of bytes you read depending on the data that you expect to read.

Make sure that you take a look at the examples that ship with MStudio.

I hope this helps.

Regards,

Juan Carlos
N.I.
0 Kudos
Message 2 of 2
(3,094 Views)