Skip to content

Commit

Permalink
check the MAV bit in OLCurrentSourceGPIB
Browse files Browse the repository at this point in the history
  • Loading branch information
jborbely committed Oct 25, 2023
1 parent d69a605 commit 80df296
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -354,20 +354,26 @@ def _send(self, message: bytes) -> None:

class OLCurrentSourceGPIB(OLCurrentSource, ConnectionGPIB):

MAV = 0b00000001 # Bit 0: active high means Message AVailable

def __init__(self, record):
super(OLCurrentSourceGPIB, self).__init__()
super(OLCurrentSource, self).__init__(record)
self.set_exception_class(OptronicLaboratoriesError)

def _receive(self, expected: bytes, iteration: int = 0) -> bytes:
"""Receive a message."""
self.wait_for_srq(handle=self.board_handle)
while True:
self.wait_for_srq(handle=self.board)
if self.serial_poll() & self.MAV:
break

reply = self.read(decode=False).rstrip()
values = reply[1:-1].split()

# all replies start with the command character that was sent,
# sometimes the reply is from a previous request so read again
# all replies start with the command character that was sent, sometimes
# (for the RS-232 interface) the reply is from a previous request so
# read again ... did not observe this with GPIB, but keep it
if values[0] != expected:
msg = f'Invalid reply character, {bytes(values[0])} != {expected}'
if iteration < 3:
Expand Down

0 comments on commit 80df296

Please sign in to comment.