diff scpisock.py @ 74:b6ebe05f250f

Add some commentry about what it works with
author Daniel O'Connor <doconnor@gsoft.com.au>
date Wed, 25 Sep 2024 21:10:01 +0930
parents c6be52360c2f
children
line wrap: on
line diff
--- a/scpisock.py	Wed Sep 25 20:57:26 2024 +0930
+++ b/scpisock.py	Wed Sep 25 21:10:01 2024 +0930
@@ -36,9 +36,7 @@
 SCPI_PORT = 5025
 
 class SCPISockDevice(object):
-    def __init__(self, host, port = None):
-        if port == None:
-            port = SCPI_PORT
+    def __init__(self, host, port = SCPI_PORT):
         self.sock = socket.create_connection((host, port))
 
     def flush(self):
@@ -50,23 +48,23 @@
 
     def write(self, data):
         trail = ''
-        if data[-1] != '\n':
-            trail = '\n'
-            
+        if data[-1] != b'\n':
+            trail = b'\n'
+
         self.sock.send(data + trail)
 
     def read(self, timeout = None):
-        res = ''
+        res = b''
         if timeout == None:
             timeout = 0.1
-            
+
         while True:
             r, w, x = select.select([self.sock], [], [], timeout)
             if len(r) == 0:
                 break
             res = res + self.sock.recv(1024)
-            if res[-1] == '\n':
+            if res[-1] == b'\n':
                 break
 
-        return res.rstrip('\n')
-                        
+        return res.rstrip(b'\n')
+