Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Conv TTL Blocking
Manage
Activity
Members
Labels
Plan
Issues
5
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
Conv TTL Blocking
Commits
b82b9b4f
Commit
b82b9b4f
authored
8 years ago
by
Projects
Browse files
Options
Downloads
Patches
Plain Diff
pulsegen: Catch exceptions when initializing the serial port
parent
425f16cd
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
conv-ttl-blo-gw
+1
-1
1 addition, 1 deletion
conv-ttl-blo-gw
software/utils/pulsegen.py
+21
-10
21 additions, 10 deletions
software/utils/pulsegen.py
with
22 additions
and
11 deletions
conv-ttl-blo-gw
@
da591442
Subproject commit
adbbd31b1af412639786a8478fbeec9b78188dc2
Subproject commit
da5914420a7d0731f6bc8e262f78148008fa936a
This diff is collapsed.
Click to expand it.
software/utils/pulsegen.py
+
21
−
10
View file @
b82b9b4f
...
...
@@ -52,6 +52,7 @@ class PulseGen:
"""
def
__init__
(
self
,
device
=
"
/dev/ttyUSB0
"
,
baud
=
115200
):
self
.
initialized
=
False
self
.
ser
=
serial
.
Serial
(
device
,
baud
,
timeout
=
1
,
rtscts
=
1
)
# generator limits
...
...
@@ -74,9 +75,10 @@ class PulseGen:
sys
.
exit
(
2
)
self
.
reset
()
self
.
initialized
=
True
def
__del__
(
self
):
if
self
.
ser
is
not
None
:
if
self
.
initialized
:
# disable generator output
self
.
ser
.
write
(
b
'
OUTP OFF
\r\n
'
)
self
.
ser
.
close
()
...
...
@@ -223,6 +225,14 @@ class PulseGen:
###############################################################################
if
__name__
==
'
__main__
'
:
# default parameters
device
=
'
/dev/ttyUSB0
'
baud
=
115200
count
=
2000000
freq
=
2e6
# Hz
width
=
250e-9
# s
samples
=
500
# number of samples for arbitrary waveform
def
usage
():
print
(
'
(c) CERN 2017
'
)
print
(
'
Maciej Suminski <maciej.suminski@cern.ch>
'
)
...
...
@@ -239,14 +249,6 @@ if __name__ == '__main__':
print
(
''
)
print
(
'
-h|--help shows this information
'
)
# default parameters
device
=
'
/dev/ttyUSB0
'
baud
=
115200
count
=
2000000
freq
=
2e6
# Hz
width
=
250e-9
# s
samples
=
500
# number of samples for arbitrary waveform
print
(
'
pulsegen: Agilent 33250A pulse burst generator
\r\n
'
)
# parse options
...
...
@@ -284,7 +286,16 @@ if __name__ == '__main__':
print
(
'
Connecting to %s @ %s
'
%
(
device
,
baud
))
gen
=
PulseGen
(
device
,
baud
)
try
:
gen
=
PulseGen
(
device
,
baud
)
except
serial
.
SerialException
as
err
:
print
(
err
.
strerror
)
sys
.
exit
(
2
)
except
:
print
(
'
Error occurred
'
)
sys
.
exit
(
2
)
gen
.
reset
()
gen
.
pulse
(
count
,
freq
,
width
,
samples
)
gen
.
wait
()
...
...
This diff is collapsed.
Click to expand it.
Preview
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!
Save comment
Cancel
Please
register
or
sign in
to comment