Commit 72e0b91e authored by Denia Bouhired-Ferrag's avatar Denia Bouhired-Ferrag

Modification tp pts to log serial number (1-wire unique ID) into separate log file

parent 36222770
......@@ -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 "\nSaving test results on USB key"
print "\nSaving 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 "\nTesting completed!"
men_off()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment