GPIB Operation Programming Examples
ML2437A/38A OM/PM PN: 10585-00001 Rev. P 8-135
Function 4882SendReceive (Board%, Addr%, cmdstring$, Result$, Result_code%) as integer
‘ Set up SRE and ESE values first, then process User
’ commands, then do *OPC
cmd$ = “*ESE 49; *SRE 48; ” + cmdstring$ + “; *OPC”
‘ Send the command string
Call DLLsend(Board%, Addr%, cmd$, Len(cmd$), Nlend,
ibsta%, iberr%, ibcntl&)
‘ Wait for either the MAV_bit (Message Available)
‘ or/and the ESB_bit (*OPC)
WaitSRQ(Board, Address, MAV_bit + ESB_bit, stb)
If (stb And MAV_bit) Then
‘ Read the data string out from the ML2430A
Result_Code% = ReadML2430A(Board, Address, Result$)
' If we did not have the ESB_bit set, wait for
‘ it again (*OPC will set this)
If (stb And ESB_bit) = 0 Then WaitSRQ(Board, Address,
ESB_bit, stb)
End if
‘ Check if anything went wrong by asking for the ESB register
Call DLLsend(Board, Address, “*ESR?”, 5, NLend, ibsta%, iberr%,
ibcntl&)
‘ Wait for it to return the data on the output queue.
WaitSRQ(Board, Address, MAV_bit, stb)
ReadML2430A(Board, Address, ESB)
‘ Read the ESB value
‘ Check the ESB for the OPC bit being set
‘ (pending commands complete).
If (Val(ESB) and 1) Then
4882SendReceive = True
' Everything sent
end if
‘ Now check if anything has gone wrong.
If (Val(ESB) And CMD_ERR_bit) Then
4882SendReceive = Command_Error
ElseIf (Val(ESB) And EXEC_ERR_bit) Then
4882SendReceive= Execution_Error
ElseIf (Val(ESB) And DEVICE_ERR_bit) Then
4882SendReceive = Device_dependent_Error
End If
End Function