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
fc2fe06c
Commit
fc2fe06c
authored
Oct 29, 2014
by
Theodor-Adrian Stana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw: Updated ei2c.py to account for Telnet ping messages in ELMA crates
parent
ac123760
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
28 deletions
+44
-28
ei2c.py
software/ei2c/ei2c.py
+44
-28
No files found.
software/ei2c/ei2c.py
View file @
fc2fe06c
...
...
@@ -31,6 +31,8 @@
#===============================================================================
# last changes:
# 2013-08-13 Theodor Stana t.stana@cern.ch File created
# 2014-10-29 Theodor Stana t.stana@cern.ch Accounting for Telnet
# echoes
#===============================================================================
# TODO: -
#===============================================================================
...
...
@@ -107,7 +109,9 @@ class EI2C:
if
(
ei2cdefine
.
DUMP
):
self
.
f
.
write
(
cmd
);
self
.
handle
.
send
(
cmd
)
self
.
_strip_resp
(
self
.
handle
.
recv
(
30
))
resp
=
"ERROR"
while
(
"ERROR"
in
resp
):
resp
=
self
.
_strip_resp
(
self
.
handle
.
recv
(
30
))
def
read
(
self
,
slot
,
addr
):
self
.
read_cnt
+=
1
...
...
@@ -118,8 +122,10 @@ class EI2C:
if
(
ei2cdefine
.
DUMP
):
self
.
f
.
write
(
cmd
);
self
.
handle
.
send
(
cmd
)
resp
=
self
.
_strip_resp
(
self
.
handle
.
recv
(
30
))
return
resp
resp
=
"ERROR"
while
(
"ERROR"
in
resp
):
resp
=
self
.
_strip_resp
(
self
.
handle
.
recv
(
30
))
return
int
(
resp
,
16
)
def
writemregs
(
self
,
slot
,
addr
,
val
):
self
.
write_cnt
+=
1
...
...
@@ -131,7 +137,9 @@ class EI2C:
self
.
f
.
write
(
cmd
);
#print cmd
self
.
handle
.
send
(
cmd
)
self
.
_strip_resp
(
self
.
handle
.
recv
(
30
))
resp
=
"ERROR"
while
(
"ERROR"
in
resp
):
resp
=
self
.
_strip_resp
(
self
.
handle
.
recv
(
30
))
def
readmregs
(
self
,
slot
,
addr
,
nrregs
):
self
.
read_cnt
+=
1
...
...
@@ -142,42 +150,50 @@ class EI2C:
if
(
ei2cdefine
.
DUMP
):
self
.
f
.
write
(
cmd
);
self
.
handle
.
send
(
cmd
)
resp
=
self
.
_strip_resp
(
self
.
handle
.
recv
(
30
))
resp
=
"ERROR"
while
(
"ERROR"
in
resp
):
resp
=
self
.
_strip_resp
(
self
.
handle
.
recv
(
30
))
return
resp
def
get_ver
(
self
):
return
self
.
ver
return
self
.
ver
def
_strip_resp
(
self
,
msg
):
"""Strip useful message from SysMon response.
"""Strip useful message from SysMon response.
The response string from the SysMon is stripped of unnecessary characters
and a "useful" string is returned. In case one of the error messages appear,
the function raises one of the EI2C exceptions."""
The response string from the SysMon is stripped of unnecessary characters
and a "useful" string is returned. In case one of the error messages appear,
the function raises one of the EI2C exceptions."""
#print msg.splitlines()
msg
=
msg
.
splitlines
()[
1
]
if
(
ei2cdefine
.
DUMP
):
self
.
f
.
write
(
msg
+
"
\n
"
)
while
(
1
):
try
:
#print msg.splitlines()
msg
=
msg
.
splitlines
()[
1
]
if
(
ei2cdefine
.
DUMP
):
self
.
f
.
write
(
msg
+
"
\n
"
)
break
except
IndexError
:
if
(
ei2cdefine
.
DUMP
):
self
.
f
.
write
(
"ERROR
\n
"
)
return
"ERROR"
if
"Not Ack"
in
msg
:
raise
NAckError
if
"Not Ack"
in
msg
:
raise
NAckError
if
"Invalid register number!"
in
msg
:
raise
RegNumberError
if
"Invalid register number!"
in
msg
:
raise
RegNumberError
if
"Bad command!"
in
msg
:
raise
InvalidCmdError
if
"Bad command!"
in
msg
:
raise
InvalidCmdError
if
"I2C Timer expired"
in
msg
:
raise
TimerExpiredError
if
"I2C Timer expired"
in
msg
:
raise
TimerExpiredError
if
"Invalid slot number!"
in
msg
:
raise
SlotError
if
"Invalid slot number!"
in
msg
:
raise
SlotError
if
"Read Data:"
in
msg
:
msg
=
msg
.
split
(
" "
)[
3
]
msg
=
int
(
msg
,
16
)
if
"Read Data:"
in
msg
:
msg
=
msg
.
split
(
" "
)[
3
]
return
msg
return
msg
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