Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
HPIB
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tammo Jan Dijkema
HPIB
Commits
019414d0
Commit
019414d0
authored
7 years ago
by
auke.klazema
Browse files
Options
Downloads
Patches
Plain Diff
extracted port name validation to a method
parent
141b2752
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
hpib.py
+11
-8
11 additions, 8 deletions
hpib.py
with
11 additions
and
8 deletions
hpib.py
+
11
−
8
View file @
019414d0
...
...
@@ -24,13 +24,11 @@ class PrologixGpibUsb(PortDevice):
if
port
==
""
:
maxDeviceNum
,
port
,
portFormat
=
self
.
_set_default_platform_values
()
self
.
_validate_port
(
port
)
if
verbose
:
print
"
Looking for ports such as %s in range %d on %s
"
%
\
(
port
,
maxDeviceNum
,
platform
.
system
()
)
self
.
_rematch
=
re
.
search
(
r
"
(/dev/tty.*[^0-9])([0-9]+$)
"
,
port
)
if
not
self
.
_rematch
:
raise
ValueError
(
port
)
while
int
(
self
.
_rematch
.
group
(
2
))
<
maxDeviceNum
:
if
verbose
:
...
...
@@ -65,6 +63,11 @@ class PrologixGpibUsb(PortDevice):
self
.
_devices
=
"
Not scanned.
"
self
.
_hpib_address
=
-
1
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
_set_default_platform_values
(
self
):
if
platform
.
system
()
==
"
Linux
"
:
port
=
"
/dev/ttyUSB0
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment