comparison usb488.py @ 67:98b9258c75b6

Add chkcmd helper to execute command check STB to see if it failed.
author Daniel O'Connor <doconnor@gsoft.com.au>
date Tue, 19 Jan 2021 17:17:55 +1030
parents bf411c7f5e78
children 7386f2888508
comparison
equal deleted inserted replaced
66:bf411c7f5e78 67:98b9258c75b6
336 result = result[0:-1] 336 result = result[0:-1]
337 337
338 return result 338 return result
339 339
340 def ask(self, s, timeout = None): 340 def ask(self, s, timeout = None):
341 '''Wrapper to send a command and wait for a reply'''
341 self.write(s) 342 self.write(s)
342 return self.read(timeout = timeout) 343 return self.read(timeout = timeout)
344
345 def chkcmd(self, cmd):
346 '''Wrapper to send a command and check for an error'''
347 self.write(cmd)
348 if int(self.ask('*STB?')) & STATUS_EVE_QUEUE != 0:
349 self.write('*CLS')
350 raise BaseException('Command failed')
343 351
344 def isConnected(self): 352 def isConnected(self):
345 """Check if the device is present""" 353 """Check if the device is present"""
346 354
347 # libusb makes it very hard (at least on FreeBSD) to determine if we're still connected. 355 # libusb makes it very hard (at least on FreeBSD) to determine if we're still connected.