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
b749cfe2
Commit
b749cfe2
authored
Feb 16, 2018
by
auke.klazema
Browse files
Moved extracted methodes into order of appearance
parent
63fe7b16
Changes
1
Hide whitespace changes
Inline
Side-by-side
hpib.py
View file @
b749cfe2
...
...
@@ -40,25 +40,23 @@ class PrologixGpibUsb(PortDevice):
self
.
_devices
=
"Not scanned."
self
.
_hpib_address
=
-
1
def
_find_devices
(
self
):
self
.
_devices
=
[]
for
self
.
_hpib_address
in
range
(
0
,
31
):
commandStr
=
"++addr "
+
str
(
self
.
_hpib_address
)
+
chr
(
10
)
+
\
"*idn?"
+
chr
(
10
)
+
\
"++read"
+
chr
(
10
)
self
.
_serialPort
.
write
(
commandStr
)
returnStr
=
self
.
_serialPort
.
readline
()
if
returnStr
!=
""
:
self
.
_devices
+=
[
self
.
_hpib_address
,
returnStr
]
def
_set_default_platform_values
(
self
):
if
platform
.
system
()
==
"Linux"
:
port
=
"/dev/ttyUSB0"
port_format
=
"%d"
max_device_num
=
99
elif
platform
.
system
()
==
"Darwin"
:
port
=
"/dev/ttys000"
port_format
=
"%03d"
max_device_num
=
999
else
:
raise
NotImplementedError
(
"Windows is not supported"
)
return
max_device_num
,
port
,
port_format
def
_initialize_prologix_gpi
(
self
):
self
.
_serialPort
.
write
(
"++savecfg 0"
+
chr
(
10
))
self
.
_serialPort
.
write
(
"++auto 0"
+
chr
(
10
))
self
.
_serialPort
.
write
(
"++eoi 1"
+
chr
(
10
))
self
.
_serialPort
.
write
(
"++eos 2"
+
chr
(
10
))
self
.
_serialPort
.
write
(
"++eot_enable 0"
+
chr
(
10
))
self
.
_serialPort
.
write
(
"++eot_char 0"
+
chr
(
10
))
self
.
_serialPort
.
write
(
"++read_tmo_ms 500"
+
chr
(
10
))
def
_validate_port
(
self
,
port
):
self
.
_rematch
=
re
.
search
(
r
"(/dev/tty.*[^0-9])([0-9]+$)"
,
port
)
if
not
self
.
_rematch
:
raise
ValueError
(
port
)
def
_find_available_port
(
self
,
maxDeviceNum
,
port
,
portFormat
,
timeout
,
verbose
):
while
int
(
self
.
_rematch
.
group
(
2
))
<
maxDeviceNum
:
...
...
@@ -73,23 +71,25 @@ class PrologixGpibUsb(PortDevice):
if
self
.
_serialPort
is
None
:
raise
serial
.
SerialException
(
"Cannot find port"
)
def
_validate_port
(
self
,
port
):
self
.
_rematch
=
re
.
search
(
r
"(/dev/tty.*[^0-9])([0-9]+$)"
,
port
)
if
not
self
.
_rematch
:
raise
ValueError
(
port
)
def
_initialize_prologix_gpi
(
self
):
self
.
_serialPort
.
write
(
"++savecfg 0"
+
chr
(
10
))
self
.
_serialPort
.
write
(
"++auto 0"
+
chr
(
10
))
self
.
_serialPort
.
write
(
"++eoi 1"
+
chr
(
10
))
self
.
_serialPort
.
write
(
"++eos 2"
+
chr
(
10
))
self
.
_serialPort
.
write
(
"++eot_enable 0"
+
chr
(
10
))
self
.
_serialPort
.
write
(
"++eot_char 0"
+
chr
(
10
))
self
.
_serialPort
.
write
(
"++read_tmo_ms 500"
+
chr
(
10
))
def
_set_default_platform_values
(
self
):
if
platform
.
system
()
==
"Linux"
:
port
=
"/dev/ttyUSB0"
port_format
=
"%d"
max_device_num
=
99
elif
platform
.
system
()
==
"Darwin"
:
port
=
"/dev/ttys000"
port_format
=
"%03d"
max_device_num
=
999
else
:
raise
NotImplementedError
(
"Windows is not supported"
)
return
max_device_num
,
port
,
port_format
def
_find_devices
(
self
):
self
.
_devices
=
[]
for
self
.
_hpib_address
in
range
(
0
,
31
):
commandStr
=
"++addr "
+
str
(
self
.
_hpib_address
)
+
chr
(
10
)
+
\
"*idn?"
+
chr
(
10
)
+
\
"++read"
+
chr
(
10
)
self
.
_serialPort
.
write
(
commandStr
)
returnStr
=
self
.
_serialPort
.
readline
()
if
returnStr
!=
""
:
self
.
_devices
+=
[
self
.
_hpib_address
,
returnStr
]
def
command
(
self
,
hpib_address
,
command
):
if
hpib_address
!=
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