02-09-2006 08:21 AM
Here is the simplified sourcecode:
EnterCriticalSection();
// write function call to Keithley 2602
ViStatus viStatErr = viWrite(m_viSession, (unsigned char*)szData, nLenIn, &nLenOut);
LeaveCriticalSection();
// allow other threads to communicate with their instruments
SwitchToThread();
EnterCriticalSection();
// read return value of function call
viStat = viScanf(m_viSession, "%t", buf);
LeaveCriticalSection();
viScanf returns sporadic with failure "query interrupted" or "timeout expired before operation completed".
In this cases the receive buffer (buf) contains always only the first character of the expeced instrument reply.
We found a workarround but this slows down the system: if we do not allow other threads to access GPIB between the function call (viWrite) and the reading of the functions response (viScanf), communication runs stable.
Software used:
NI-VISA 3.2
NI-VXI 3.3.1
NI-488 2.4
WinXP
MS VS 6.0
Additional note:
If in the upper code viWrite would be replaced by viPrintf, the following call to viScanf would all times return a n error.
What makes viPrintf behave other than viWrite in this circumstance?
Appreciate any hint to this subject.
Thanks in advance,
Fritz
02-20-2006 09:30 AM
02-20-2006 10:59 AM
02-20-2006 11:21 AM - edited 02-20-2006 11:21 AM
このメッセージは 02-21-2006 02:24 AMに Makoto が編集しています。
02-20-2006 11:53 AM
Thanks Makoto for answering.
In the case questioned no SCPI-Command is called, but a stored user script function with is executed by the GPIB-instrument before returning some sting. What we are trying to do to increase performance is to split up writing the function call to the instrument and reading of the function result. If this writing and reading is done noninterruptable (crit section encloses both operations) we don't have any problem but performance is slow.
Termination character is not the problem. Called functions are executed by the instruments (write operations succeeded), but sporadic the read operations returns sporadic errorrouse having only the first char of the return string in the receive buffer.
Best regards,
Fritz