Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
Conv TTL RS485 - Testing
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
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 RS485 - Testing
Commits
72e0b91e
Commit
72e0b91e
authored
Sep 21, 2018
by
Denia Bouhired-Ferrag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modification tp pts to log serial number (1-wire unique ID) into separate log file
parent
36222770
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
5 deletions
+51
-5
pts.py
pts-fm/python/pts.py
+51
-5
No files found.
pts-fm/python/pts.py
View file @
72e0b91e
...
...
@@ -32,6 +32,7 @@
##
## Authors Julian Lewis (Julian.Lewis@cern.ch)
## Theodor Stana (t.stana@cern.ch)
## Denia Bouhired (denia.bouhired@gmail.com)
## Website http://www.ohwr.org/projects/conv-ttl-rs485
## Date 30/10/2014
##-------------------------------------------------------------------------------------------------
...
...
@@ -64,6 +65,8 @@ import subprocess
import
re
# Import ptsdefine module to avoid wrong `make's
from
ptsexcept
import
*
from
vv_pts
import
*
from
ptsdefine
import
*
##-------------------------------------------------------------------------------------------------
...
...
@@ -104,6 +107,7 @@ if __name__ == '__main__':
# Turn off the VME crate
men_off
()
bus
=
SKT
(
ELMASLOT
)
# Scan the first barcode
while
True
:
sn1
=
raw_input
(
"--> Scan the 1st barcode: "
)
...
...
@@ -183,15 +187,57 @@ if __name__ == '__main__':
subprocess
.
call
(
"grep FAIL log/*.log"
,
shell
=
True
,
stdout
=
sys
.
stdout
,
stderr
=
sys
.
stderr
)
# Save results on USB key...
print
"
\n
Saving test results
on USB key
"
print
"
\n
Saving test results
in /home/pts-administrator/pts/log
"
try
:
subprocess
.
call
(
"mkdir -p /
media
/pts/log"
,
shell
=
True
,
stdout
=
sys
.
stdout
,
stderr
=
sys
.
stderr
)
subprocess
.
call
(
"cp log/*.log /
media
/pts/log"
,
shell
=
True
,
stdout
=
sys
.
stdout
,
stderr
=
sys
.
stderr
)
subprocess
.
call
(
"cp log/*.inf /
media
/pts/log"
,
shell
=
True
,
stdout
=
sys
.
stdout
,
stderr
=
sys
.
stderr
)
subprocess
.
call
(
"mkdir -p /
home/pts-administrator
/pts/log"
,
shell
=
True
,
stdout
=
sys
.
stdout
,
stderr
=
sys
.
stderr
)
subprocess
.
call
(
"cp log/*.log /
home/pts-administrator
/pts/log"
,
shell
=
True
,
stdout
=
sys
.
stdout
,
stderr
=
sys
.
stderr
)
subprocess
.
call
(
"cp log/*.inf /
home/pts-administrator
/pts/log"
,
shell
=
True
,
stdout
=
sys
.
stdout
,
stderr
=
sys
.
stderr
)
except
e
:
print
"ERROR: No access to
USB key at /media
/pts"
print
"ERROR: No access to
directory /home/pts-administrator
/pts"
print
e
#-------------------------------------------------------------------------------
# Reading board unique ID and storing to separate log file
#-------------------------------------------------------------------------------
# ... power-cycle the crate
print
"VME Crate power-cycle..."
men_off
()
time
.
sleep
(
3
)
men_on
()
time
.
sleep
(
10
)
#Read unique board ID
IDMS
=
bus
.
vv_read
(
UIDREGMS
)
IDLS
=
bus
.
vv_read
(
UIDREGLS
)
#Generate log file
# Generate output file named according to current time
fname
=
time
.
strftime
(
"serial-num-CTDAH-
%
Y-
%
m-
%
d"
,
time
.
localtime
())
+
".txt"
ret
=
subprocess
.
call
([
"ls /home/pts-administrator/pts/log | grep "
+
fname
],
shell
=
True
,
stdout
=
None
,
stderr
=
None
)
#print ("%d" % ret)
if
(
ret
!=
0
):
f
=
open
(
"/home/pts-administrator/pts/log"
+
fname
,
"w"
)
print
(
" File not found ... Create new one
\n
"
)
f
.
write
(
"
\n
"
)
f
.
write
(
"CONV-TTL-BLO Upgrade log created on
%
s
\n
"
%
time
.
strftime
(
"
%
Y-
%
m-
%
d-
%
Hh
%
Mm
%
Ss"
,
time
.
localtime
()))
f
.
write
(
"---------------------------------------------------------------------------------
\n
"
)
f
.
write
(
"Barcode 1 | Barcode 2 | PCB ID |
\n
"
)
f
.
write
(
"---------------------------------------------------------------------------------
\n
"
)
f
.
close
()
print
(
"Upgrade log can be found in /home/pts-administrator/pts/log/
%
s
\n
"
%
fname
)
print
(
"Board unique ID can be found in /home/pts-administrator/pts/log/
%
s
\n
"
%
fname
)
f
=
open
(
"/home/pts-administrator/pts/log/"
+
fname
,
"a"
)
f
.
write
(
"
%
s
\t
%
s
\t
%
x
%
x
\n
"
%
(
sn1
,
sn2
,
IDMS
,
IDLS
)
)
f
.
close
()
#-------------------------------------------------------------------------------
# We're done, turn off the VME crate
print
"
\n
Testing completed!"
men_off
()
...
...
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