Commit 33dad756 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

software: Add SR scripts

The old gwvers.py script has been changed to getsr.py, which
lists the fields of the board status register in a more comprehensive
manner.

Then, the setsr.py script has been added as a means to clear set error
bits.

Note that unlike what the git commit output below states, the
gwvers.py was actually renamed (and changed to) getsr.py.
Signed-off-by: Theodor-Adrian Stana's avatarTheodor Stana <t.stana@cern.ch>
parent 16acb106
......@@ -3,8 +3,9 @@ Python scripts for diagnostics
timetag/ -- Python scripts for working with the time-tagging logic
clrchxpcr.py -- Clears the channel pulse counter registers
gwvers.py -- Read gateware version from board CSR
getsr.py -- Read the board's SR and print the list of fields
mantrig.py -- Manually trigger a pulse on a selected channel
rdchxpcr.py -- Read the channel pulse counter registers
setsr.py -- Set the board's SR, typically for clearing error bits
therm.py -- Get the unique ID and temperature from the
DS18B20 thermometer on-board the CONV-TTL-BLO
#!/usr/bin/python
#===============================================================================
# CERN (BE-CO-HT)
# Retrieve gateware version from CONV-TTL-BLO board
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
#
# date of creation:
#
# version: 1.0
#
# description:
# This script retrieves the value of the CONV-TTL-BLO status register and
# retrieves the GWVERS field of the register.
#
#===============================================================================
# GNU LESSER GENERAL PUBLIC LICENSE
#===============================================================================
# This source file is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation; either version 2.1 of the License, or (at your
# option) any later version. This source is distributed in the hope that it
# will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with this
# source; if not, download it from http://www.gnu.org/licenses/lgpl-2.1.html
#===============================================================================
# last changes:
# 2014-05-02 Theodor Stana Changed to print the bits of the SR
# in turn.
#===============================================================================
# TODO: -
#===============================================================================
import sys
sys.path.append("../ei2c")
from ei2c import *
import ei2cdefine
if __name__ == "__main__":
# Get the IP, user and password for the ELMA crate from ei2cdefine.py
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
testelma = EI2C(ip, user, pwd)
testelma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Get status register value and print
v = testelma.read(slot, 0x4)
print("Status register : 0x%08x" % v)
print("===============================")
# Strip GWVERS and print
maj = (v & 0xf0) >> 4
min = v & 0x0f
print("Gateware version : v%d.%d (0x%02x)" % (maj, min, v & 0xff))
# Strip SWITCHES and print
switches = (v & 0xff00) >> 8
print("Switches : 0x%02x" % switches)
if not (switches & 0x80):
print(" TTL repetition : on")
else:
print(" TTL repetition : off")
if not (switches & 0x01):
print(" Glitch filter : on")
else:
print(" Glitch filter : off")
# Strip RTM and print
rtm = (v & 0x3f0000) >> 16
rtmm = rtm & 0x7
rtmp = (rtm & 0x3f) >> 3
print("RTM detection : 0x%02x" % rtm)
print(" RTMM[2:0] : %s" % ("{0:#03b}".format(rtmm)[2:]))
print(" RTMP[2:0] : %s" % ("{0:#03b}".format(rtmp)[2:]))
# Strip the other status bits and print
print("I2C timeout error : %s" % ("{0:#01b}".format(int(bool(v & (1 << 22))))[2]))
print("White Rabbit pres. : %s" % ("{0:#01b}".format(int(bool(v & (1 << 23))))[2]))
print("I2C address error : %s" % ("{0:#01b}".format(int(bool(v & (1 << 24))))[2]))
print("Pulse miss error : %s" % ("{0:#01b}".format(int(bool(v & (1 << 25))))[2]))
testelma.close()
#!/usr/bin/python
#===============================================================================
# CERN (BE-CO-HT)
# Retrieve gateware version from CONV-TTL-BLO board
# Set converter board status register
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
#
# date of creation:
# date of creation: 2014-05-02
#
# version: 1.0
#
# description:
# This script retrieves the value of the CONV-TTL-BLO status register and
# retrieves the GWVERS field of the register.
# Set the converter board status register, typically for clearing set error
# bits.
#
# dependencies:
# ../ei2c/ei2c.py
# ../ei2c/ei2cdefine.py
#
#===============================================================================
# GNU LESSER GENERAL PUBLIC LICENSE
......@@ -27,9 +31,12 @@
# source; if not, download it from http://www.gnu.org/licenses/lgpl-2.1.html
#===============================================================================
# last changes:
# 2014-05-02 Theodor Stana File created
#===============================================================================
# TODO: -
# TODO: -
#===============================================================================
import sys
sys.path.append("../ei2c")
from ei2c import *
......@@ -60,9 +67,15 @@ if __name__ == "__main__":
except:
print("Unexpected error: ", sys.exc_info()[0])
# Get gateware version field and close
# Get status register value, set and re-print
v = testelma.read(slot, 0x4)
maj = (v & 0xf0) >> 4
min = v & 0x0f
print("Gateware version: %d.%d" % (maj, min))
print("SR (pre-set) : 0x%08x" % v)
print("==========================")
v = raw_input("Value to set : 0x")
v = int(v, 16)
testelma.write(slot, 0x4, v)
print("==========================")
v = testelma.read(slot, 0x4)
print("SR (post-set) : 0x%08x" % v)
testelma.close()
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