Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
auke.klazema
HPIB
Commits
141b2752
Commit
141b2752
authored
Feb 16, 2018
by
auke.klazema
Browse files
extracted default plaform values to a method
parent
73ce0a2a
Changes
1
Hide whitespace changes
Inline
Side-by-side
hpib.py
View file @
141b2752
...
...
@@ -22,16 +22,8 @@ class PrologixGpibUsb(PortDevice):
def
__init__
(
self
,
port
=
""
,
timeout
=
1
,
portFormat
=
"%d"
,
maxDeviceNum
=
9
,
verbose
=
False
,
findDevices
=
False
):
if
port
==
""
:
if
platform
.
system
()
==
"Linux"
:
port
=
"/dev/ttyUSB0"
portFormat
=
"%d"
maxDeviceNum
=
99
elif
platform
.
system
()
==
"Darwin"
:
port
=
"/dev/ttys000"
portFormat
=
"%03d"
maxDeviceNum
=
999
else
:
raise
NotImplementedError
(
"Windows is not supported"
)
maxDeviceNum
,
port
,
portFormat
=
self
.
_set_default_platform_values
()
if
verbose
:
print
"Looking for ports such as %s in range %d on %s"
%
\
(
port
,
maxDeviceNum
,
platform
.
system
()
)
...
...
@@ -73,6 +65,19 @@ class PrologixGpibUsb(PortDevice):
self
.
_devices
=
"Not scanned."
self
.
_hpib_address
=
-
1
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
command
(
self
,
hpib_address
,
command
):
if
hpib_address
!=
self
.
_hpib_address
:
command
=
"++addr "
+
str
(
hpib_address
)
+
chr
(
10
)
+
command
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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