changeset 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 f95db5ea2fe1
files usb488.py
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/usb488.py	Tue Jan 19 17:13:21 2021 +1030
+++ b/usb488.py	Tue Jan 19 17:17:55 2021 +1030
@@ -338,9 +338,17 @@
         return result
 
     def ask(self, s, timeout = None):
+        '''Wrapper to send a command and wait for a reply'''
         self.write(s)
         return self.read(timeout = timeout)
 
+    def chkcmd(self, cmd):
+        '''Wrapper to send a command and check for an error'''
+        self.write(cmd)
+        if int(self.ask('*STB?')) & STATUS_EVE_QUEUE != 0:
+            self.write('*CLS')
+            raise BaseException('Command failed')
+
     def isConnected(self):
         """Check if the device is present"""