Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
Conv TTL Blocking
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Conv TTL Blocking
Commits
b82b9b4f
Commit
b82b9b4f
authored
Feb 13, 2017
by
Projects
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pulsegen: Catch exceptions when initializing the serial port
parent
425f16cd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
11 deletions
+22
-11
conv-ttl-blo-gw
conv-ttl-blo-gw
+1
-1
pulsegen.py
software/utils/pulsegen.py
+21
-10
No files found.
conv-ttl-blo-gw
@
da591442
Subproject commit
adbbd31b1af412639786a8478fbeec9b78188dc2
Subproject commit
da5914420a7d0731f6bc8e262f78148008fa936a
software/utils/pulsegen.py
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
()
...
...
Write
Preview
Markdown
is supported
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