WaitSRQ spurios triggers
Michael K via Linux-gpib-general <[email protected]> Thu, 7 Dec 2023 17:22:48 +0000 (UTC)
| Newsgroups | gmane.linux.hardware.gpib.general |
|---|---|
| Message-ID | <[email protected]> |
I have some code that sets up an instrument and has another thread looping on WaitSRQ for the device to complete the task (OPC).
This works but I also get a spurious trigger of WaitSRQ...
In the monitoring thread, the WaitSRQ() call waits for the OPC to trigger the SRQ. When WaitSRQ() completes with a 1 result, I do a serial poll (ibrsp()) and confirm that the poll came from my instrument. This causes the instrument to drop the SRQ. The thread loops and executes WaitSRQ again.
In the main program I write another command to the instrument that should not trigger an SRQ but WaitSRQ then returns a 1 even though there is no SRQ (I do a serial poll and see that my instrument did not send an SRQ) (and the HP59401A shows no SRQ).
Is this a bug or am I doing something wrong?
Michael
// This thread is run and waits for the SRQ line be raised
// Once the SRQ line is raised, we check if it was the HP8753 by reading the status (serial poll)
// The act of checking will release the SRQ (if the HP8753 triggered it).
// If the SRQ was activated because of OPC, we flag this for the main thread.
void* threadWaitForSRQ( void *data )
{
gshort waitResult;
tThreadData *pThreadData = (tThreadData *) data;
gboolean bDie = FALSE;
do {
gchar status = 0;
gchar sESR[5] = {0}; // the ASCII representation of the ESR value
gint ESR = 0; // ESR converted to an integer
#define SRQ_EVENT 1
#define TIMEOUT_EVENT 0
// This will timeout every second (the timeout we set for the controller)
WaitSRQ( pThreadData->GPIBcontrolerID, &waitResult);
g_mutex_lock( &pThreadData->mutexGPIB );
if ( waitResult == SRQ_EVENT ) {
g_print( "\nSRQ received .. determine if it is the HP8753C that sent it!\n");
// This "serial poll" will also de-assert the SRQ if the HP8753 activated it
ibrsp( pThreadData->descGPIBdevice, &status);
g_print( "Status word from HP8753C 0x%02x\n", status );
// if there are other devices on the GPIB we could get SRQs that we are not interested in
// check if the SRQ came from the HP8753C
if( status & ST_SRQ ) {
if( status & ST_ESR ) { // We enabled SRQ when OPC ESR bit set (B5 SRE & B0 ESE) .. check
// Ask for and read the ESR
if( (ibwrt(pThreadData->descGPIBdevice, "ESR?;", 5) & ERR ) )
bDie = TRUE;
else if( (ibrd(pThreadData->descGPIBdevice, &sESR, 4) & ERR ) ) // Set the OPC when the single sweep has completed
bDie = TRUE;
else {
g_print( "ESR: 0x%02x\n", (ESR = atoi( sESR )));
// check if the OPC set ( single sweep has completed )
if( ESR & ESE_OPC )
pThreadData->flags.bSweepComplete = TRUE;
// the other reason an SRQ is issued is an error
else if ( ESR & (ESE_QERR | ESE_EERR | ESE_SERR) )
g_printerr( "HP8753C reports error\n" );
}
} else {
g_print( "SRQ came from HP8753C but it was not from ESR" );
}
} else {
g_print( "SRQ did not come from the HP8753C\n" );
}
}
g_mutex_unlock( &pThreadData->mutexGPIB );
} while ( !bDie && !pThreadData->flags.bEnd ); // loop until we are told to stop
if ( bDie )
return (void *)ERROR;
else
return NULL;
}
_______________________________________________
Linux-gpib-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-gpib-general