Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tammo Jan Dijkema
HPIB
Commits
3f15a50b
Commit
3f15a50b
authored
Apr 26, 2018
by
Tammo Jan Dijkema
Browse files
Try to make PrologicUSB thread safe
parent
d7ed83c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
hpib.py
View file @
3f15a50b
...
...
@@ -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,7 +103,8 @@ class PrologixGpibUsb(PortDevice):
command
=
"++addr "
+
str
(
hpib_address
)
+
chr
(
10
)
+
command
self
.
_hpib_address
=
hpib_address
self
.
_write_serial
(
command
+
chr
(
10
))
with
self
.
_lock
:
self
.
_write_serial
(
command
+
chr
(
10
))
def
query
(
self
,
hpib_address
,
query
,
count
=
80
):
if
hpib_address
!=
self
.
_hpib_address
:
...
...
@@ -109,8 +112,9 @@ class PrologixGpibUsb(PortDevice):
self
.
_hpib_address
=
hpib_address
query
+=
chr
(
10
)
+
"++read eoi"
+
chr
(
10
)
self
.
_write_serial
(
query
)
line
=
self
.
_serialPort
.
readline
()
with
self
.
_lock
:
self
.
_write_serial
(
query
)
line
=
self
.
_serialPort
.
readline
()
return
line
[:
-
1
]
def
set_local
(
self
,
hpib_address
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment