Commit 3f15a50b authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Try to make PrologicUSB thread safe

parent d7ed83c0
......@@ -3,6 +3,7 @@ import time
import re
import platform
import sys
from threading import Lock
class PortDevice(object):
......@@ -27,6 +28,7 @@ class PrologixGpibUsb(PortDevice):
max_device_num, port, port_format = self._set_default_platform_values()
self._validate_port(port)
self._lock = Lock()
if verbose:
print("Looking for ports such as %s in range %d on %s" % \
......@@ -101,6 +103,7 @@ class PrologixGpibUsb(PortDevice):
command = "++addr " + str(hpib_address) + chr(10) + command
self._hpib_address = hpib_address
with self._lock:
self._write_serial(command + chr(10))
def query(self, hpib_address, query, count=80):
......@@ -109,6 +112,7 @@ class PrologixGpibUsb(PortDevice):
self._hpib_address = hpib_address
query += chr(10) + "++read eoi" + chr(10)
with self._lock:
self._write_serial(query)
line = self._serialPort.readline()
return line[:-1]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment