Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

GPIB Visa C++: Wait after viWrite Command until a Response comes

Hello,

 

I´ve been trying to make a little C++ Program.

The Program should wait, until the Device is Ready to Read the value.

 

Example Code:

 

Snippet

viOpenDefaultRM(&m_defaultRM);
viOpen(m_defaultRM, "GPIB0::1::INSTR", VI_NULL, m_tmo, &m_Session[x]);
viWrite(m_Session[pad],(ViBuf)"X?", 2, &actual);

/* Wait Until the Value is Ready to Read ( WaitOnEvent ??? ) */

viRead(m_Session[pad], (ViPBuf)strres, 255,&actual);

 

 

Have you any Solution for me ?

 

Thanks.

0 Kudos
Message 1 of 4
(5,086 Views)

@pmb wrote:

Hello,

 

I´ve been trying to make a little C++ Program.

The Program should wait, until the Device is Ready to Read the value.

 

Example Code:

 

Snippet

viOpenDefaultRM(&m_defaultRM);
viOpen(m_defaultRM, "GPIB0::1::INSTR", VI_NULL, m_tmo, &m_Session[x]);
viWrite(m_Session[pad],(ViBuf)"X?", 2, &actual);

/* Wait Until the Value is Ready to Read ( WaitOnEvent ??? ) */

viRead(m_Session[pad], (ViPBuf)strres, 255,&actual);

 

 

Have you any Solution for me ?

 

Thanks.


Any reason why you want to wait ?

Generally with most instruments the response is fairly instantaneous.

You would generally to wait if reading waveforms back from an oscilloscope or something of that nature.

 

Also, why C++ ?

 

Rohde-Schwarz has a very explanation about measurement synchronization in chapter 4. http://www.rohde-schwarz.pl/file_7561/1EF62_0E.pdf

Also read http://cdn.rohde-schwarz.com/pws/dl_downloads/dl_application/application_notes/1gp79/1GP79_1E_SCPI_P...

 

 

 

0 Kudos
Message 2 of 4
(5,074 Views)

How does the instrument indicate, that it  is ready to be read  ?  Check the instruments documentation for that. 

 

 

 

0 Kudos
Message 3 of 4
(5,050 Views)

Thanks for the replies.

I do it now over the STB register.

This works for me.

 

Snippet

do
	{
		state = viReadSTB(m_Session[pad], &statusByte);
		Sleep(10);
	        if(state != 0) 
		{ 
			return "ERROR";
		}
	}
	while(statusByte!=16); 

 

 

0 Kudos
Message 4 of 4
(5,032 Views)