Commit f5d13a54 authored by Dimitris Lampridis's avatar Dimitris Lampridis

Repository cleanup, restructuring, addition of READMEs, source headers and…

Repository cleanup, restructuring, addition of READMEs, source headers and modification of test02 to run over SSH.
parent f83537f6
# CONV-RS485-OPT-RTM Production Test System (PTS)
This is the repository for the the CONV-RS485-OPT-RTM.
Currently it contains the [software for the Production Test System software (PTS)](pts/), under the
`pts` directory.
#!/bin/bash
source ./set_env.sh
#######################################################################
####################### Make sure that run as root ####################
#######################################################################
#if [ "$EUID" -ne 0 ]
# then echo "Please run as root"
# exit
#fi
#######################################################################
###################### Setting project paths ##########################
#######################################################################
topdirname="opt-pts"
projectpath="."
LOGDIR="${HOME}/Desktop/opt-pts-log/"
#######################################################################
############# Getting absolute path for project #######################
#######################################################################
# if [ -n "$1" ]
# then
# top="$1"
# else
# prg=$0
# if [ ! -e "$prg" ]; then
# case $prg in
# (*/*) exit 1;;
# (*) prg=$(command -v -- "$prg") || exit;;
# esac
# fi
# dir=$(
# cd -P -- "$(dirname -- "$prg")" && pwd -P
# ) || exit
# prg=$dir/$(basename -- "$prg") || exit
# top=$prg
# while true
# do
# if [ `basename "$top"` == "$topdirname" ]
# then
# break;
# else
# top=`dirname "$top"`
# fi
# done
# fi
#######################################################################
####################### Drivers management ############################
#######################################################################
#######################################################################
############################## Logging ################################
#######################################################################
# create log directories
mkdir -p "$LOGDIR"
# get board serial
serial=0000
extra_serial=0000
serial=$1
if [ x$1 = x"" ]; then
echo -n "Please scan CERN serial number bar-code, then press [ENTER]: "
read serial
fi
if [ x$serial = x"" ]; then
serial=0000
fi
extra_serial=$2
if [ x$2 = x"" ]; then
echo -n "If needed input extra serial number and press [ENTER] OR just press [ENTER]: "
read extra_serial
fi
if [ x$extra_serial = x"" ]; then
extra_serial=0000
fi
echo " "
board_plugged=$3
echo -n "---> Now please plug in the board and then press [ENTER]"
read board_plugged
nb_test_limit=2
nb_test=1
#######################################################################
############################## Testing ###############################
#######################################################################
while [ "$nb_test" -le "$nb_test_limit" ]
do
echo "--------------------------------------------------------------"
echo "Test series run $nb_test out of $nb_test_limit"
echo " "
# run tests
#sudo ${top}/pts/pts-opt.py -b pts-opt -s $serial -e $extra_serial "-t${top}/python" -l $LOGDIR 00 01
sudo ./pts.py -b OptRtm -s $serial -e $extra_serial -t./python -l $LOGDIR 00 01 02
# repeat test?
if [ "$nb_test" != "$nb_test_limit" ]
then
echo " "
echo -n "Do you want to run the test series again [y,n]? "
read reply
if [ "$reply" != "y" ]
then
break
fi
fi
nb_test=$(($nb_test+1))
done
echo "--------------------------------------------------------------"
echo " "
echo -n "End of the test, do you want to switch the computer OFF? [y,n]"
read reply
if [ "$reply" = "y" ]
then
sudo poweroff
fi
[DUT.FEC]
MgtHostName = cfvm-774-opt-pts2
MgtPort = 23
MgtUserName = admin
MgtPassword = Gr@nBr@st0
Slot = 5
[CTR.FEC]
MgtHostName = cfvm-774-opt-pts1
MgtPort = 23
MgtUserName = admin
MgtPassword = Gr@nBr@st0
CpuHostName = cfv-774-opt-pts1
CpuPort = 22
# Please set CpuUserName to an account name you have access to on the CTR.FEC
CpuUserName = nobody
# CONV-RS485-OPT-RTM Production Test System (PTS)
This is the software for the the CONV-RS485-OPT-RTM PTS.
To configure it, please edit directly the file `CONFIG.ini`. In particular, please make sure that
you have set `CpuUserName` to an account name you have access to on the Front-End Computer (FEC)
that is hosting the Central Timing Receiver (CTR) cards.
To run it, simply run the `run-pts.sh` script.
**Dependencies:**
- snmp
- python configparser
#!/usr/bin/env python
# Copyright CERN, 2011
# Author: Juan David Gonzalez Cobas <dcobas@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
################################################################################
## CERN BE-CO-HT
## CONV-RS485-OPT-RTM
## https://www.ohwr.org/projects/conv-rs485-opt-rtm
################################################################################
##
## unit name: pts.py
##
## description: Generic PTS framework used for running the various tests and
## logging their outputs.
##
################################################################################
## Copyright CERN 2011-2019
################################################################################
##
## This program is free software: you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation, either version 3 of the License, or (at your option) any later
## version.
##
## This program 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 General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program. If not, see <https://www.gnu.org/licenses/>.
##
## SPDX-License-Identifier: GPL-3.0-or-later
################################################################################
import sys
import cmd
......@@ -21,14 +46,12 @@ import fnmatch
from ConfigParser import ConfigParser, NoOptionError
from optparse import OptionParser
#from sha import sha as sha160
import hashlib
from ptsexcept import *
default_config_file = 'ptsdefault.cfg'
default_log_pattern = '{timestamp}_pts_tst_{runid}_{board}_{serial}_{number}.txt'
default_log_name = '{timestamp}_pts_run_{runid}_{board}_{serial}.txt'
default_zip_name = '{timestamp}_zip_run_{runid}_{board}_{serial}.zip'
default_log_pattern = '{timestamp}_pts_tst_{board}_{serial}_{number}.txt'
default_log_name = '{timestamp}_pts_run_{board}_{serial}.txt'
default_zip_name = '{timestamp}_zip_run_{board}_{serial}.zip'
default_test_pattern = r'test[0-9][0-9]'
default_test_syntax = r'(test)?(\d\d)'
......@@ -226,18 +249,14 @@ class Suite(object):
card = None
sequence = self.validate_and_compute_run()
ts = timestamp()
#runid = hashlib.sha(self.board + ':' + self.serial + ':' + ts)
runid = hashlib.sha256(self.board + ':' + self.serial + ':' + ts)
logfilename = self.log_name.format(board=self.board,
serial=self.serial,
timestamp=ts,
runid=runid)
timestamp=ts)
logfilename = os.path.join(self.log_path, logfilename)
log = file(logfilename, 'wb')
zipfilename = self.zip_name.format(board=self.board,
serial=self.serial,
timestamp=ts,
runid=runid)
timestamp=ts)
zipfilename = os.path.join(self.log_path, zipfilename)
ziplist = [ logfilename ]
......@@ -249,9 +268,8 @@ class Suite(object):
' serial = {1}\n'
' optional serial = {2}\n'
' comment = {3}\n'
' timestamp = {4}\n'
' runid = {5}\n'.format(
self.board, self.serial, self.extra_serial, self.comment, ts, runid))
' timestamp = {4}\n'.format(
self.board, self.serial, self.extra_serial, self.comment, ts))
failures = []
for test in sequence:
try:
......@@ -259,8 +277,7 @@ class Suite(object):
shortname= re.match('test(\d\d)', testname).group(1)
logname = self.log_pattern.format(board=self.board,
serial=self.serial,
timestamp=timestamp(),
runid = runid,
timestamp=ts,
number=shortname)
logname = os.path.join(self.log_path, logname)
ziplist.append(logname)
......@@ -322,10 +339,6 @@ class Suite(object):
log.write(msg)
log.close()
# adc_data_files=get_files("/tmp","mfdata*")
# adc_read_script=os.path.abspath("../python/read_samples.py")
# ziplist = ziplist + adc_data_files + [ adc_read_script ]
make_zip(zipfilename, ziplist)
def get_serial():
......@@ -343,19 +356,6 @@ def timestamp():
"""
return datetime.datetime.now().strftime('%Y%m%d.%H%M%S.%f')
def sha(blob, len=7):
"""create a sha-160 hash of a binary object
len is the number of hex digits to take from the hex digest,
defaulting to 7 just as in git
"""
#hash = sha160(blob)
hash = hashlib.sha256(blob)
ret = hash.hexdigest()
if len:
return ret[:len]
class Cli(cmd.Cmd, Suite):
def __init__(self, cfgfilename=default_config_file):
cmd.Cmd.__init__(self)
......@@ -466,7 +466,8 @@ def main():
parser.add_option("-e", "--extra_serial", dest="extra_serial",
help="another board serial number [Optional]", metavar="SERIAL")
parser.add_option("-t", "--test-path", dest="test_path",
help="path to test files", metavar="PATH")
help="path to test files", metavar="PATH",
default=os.getcwd()+"/tests")
parser.add_option("-l", "--log-path", dest="log_path",
help="path to log files", metavar="PATH")
parser.add_option("-n", "--ntimes", dest="repeat",
......
#! /usr/bin/env python
# coding: utf8
#!/usr/bin/env python
################################################################################
## CERN BE-CO-HT
## CONV-RS485-OPT-RTM
## https://www.ohwr.org/projects/conv-rs485-opt-rtm
################################################################################
##
## unit name: ptsexcept.py
##
## description: Generic PTS framework used for running the various tests and
## logging their outputs: common exceptions and handling
##
################################################################################
## Copyright CERN 2011-2019
################################################################################
##
## This program is free software: you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation, either version 3 of the License, or (at your option) any later
## version.
##
## This program 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 General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program. If not, see <https://www.gnu.org/licenses/>.
##
## SPDX-License-Identifier: GPL-3.0-or-later
################################################################################
class PtsException(Exception):
pass
......
#!/usr/bin/env python
# Copyright CERN, 2019
# Author: <Dimitris.Lampridis@cern.ch>, <Evangelia.Gousiou@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
################################################################################
## CERN BE-CO-HT
## CONV-RS485-OPT-RTM
## https://www.ohwr.org/projects/conv-rs485-opt-rtm
################################################################################
##
## unit name: test00.py
##
## description: Test for reading out the RTM ID over I2C
##
################################################################################
## Copyright CERN 2019
################################################################################
##
## This program is free software: you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation, either version 3 of the License, or (at your option) any later
## version.
##
## This program 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 General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program. If not, see <https://www.gnu.org/licenses/>.
##
## SPDX-License-Identifier: GPL-3.0-or-later
################################################################################
# Import system modules
import os
import sys
import time
import os, errno, re, sys, struct
import os.path
import traceback
import configparser
# Import common modules
sys.path.append('..')
import ptsexcept
import utilities as util
import vv_skt
from ptsdefine import *
##-------------------------------------------------------------------------------------------------
## main --
##-------------------------------------------------------------------------------------------------
def main (card=None, default_directory='.',suite=None, serial=""):
......@@ -35,13 +51,28 @@ def main (card=None, default_directory='.',suite=None, serial=""):
util.section_msg("I2C to read RTM ID")
test_results={}
dut = vv_skt.SKT()
config = configparser.ConfigParser()
config.read(default_directory + "/../../CONFIG.ini")
lun = int(config['DUT.FEC']['Slot'])
ip = config['DUT.FEC']['MgtHostName']
port = int(config['DUT.FEC']['MgtPort'])
user = config['DUT.FEC']['MgtUserName']
pwrd = config['DUT.FEC']['MgtPassword']
# Turn on VME crate
os.popen("snmpset -v2c -c %s %s 1.3.6.1.4.1.37968.1.1.7.2.1.3.1 i 0" % (pwrd, ip))
time.sleep(10)
dut = vv_skt.SKT(lun, ip, port, user, pwrd)
###############################################################################
############################ actual test ######################################
###############################################################################
rtm = (dut.vv_read(CSR) >> CSR_RTM_OFS) & 0x3f
rtm = (dut.vv_read(4) >> 16) & 0x3f
if (rtm == 0x05):
test_results['DUT identification']= 1
util.info_msg("DUT identified; detection lines read correctly: 0x%02X" % rtm)
else:
test_results['DUT identification']= 0
......@@ -50,6 +81,7 @@ def main (card=None, default_directory='.',suite=None, serial=""):
###############################################################################
########################## result processing ##################################
###############################################################################
errors = util.summarise_test_results(testname, test_results)
sys.stdout.flush()
return 0;
......
#!/usr/bin/env python
# Copyright CERN, 2019
# Author: <Dimitris.Lampridis@cern.ch>, <Evangelia.Gousiou@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
###TODO: add switching ON of the vme crate
################################################################################
## CERN BE-CO-HT
## CONV-RS485-OPT-RTM
## https://www.ohwr.org/projects/conv-rs485-opt-rtm
################################################################################
##
## unit name: test01.py
##
## description: Test LEDs
##
################################################################################
## Copyright CERN 2019
################################################################################
##
## This program is free software: you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation, either version 3 of the License, or (at your option) any later
## version.
##
## This program 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 General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program. If not, see <https://www.gnu.org/licenses/>.
##
## SPDX-License-Identifier: GPL-3.0-or-later
################################################################################
import sys
import os
......@@ -42,7 +64,7 @@ def test_led_all():
def main (card=None, default_directory='.',suite=None, serial=""):
testname= "Test00: LEDs and basic connectivity"
testname= "Test01: LEDs and basic connectivity"
util.header_msg( testname, [ "LED connectivity"] )
###############################################################################
......@@ -50,7 +72,6 @@ def main (card=None, default_directory='.',suite=None, serial=""):
###############################################################################
test_results={}
###############################################################################
############################ actual test ######################################
###############################################################################
......
#!/usr/bin/env python
# Copyright CERN, 2019
# Author: <Dimitris.Lampridis@cern.ch>, <Evangelia.Gousiou@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
################################################################################
## CERN BE-CO-HT
## CONV-RS485-OPT-RTM
## https://www.ohwr.org/projects/conv-rs485-opt-rtm
################################################################################
##
## unit name: test02.py
##
## description: Test all transmitters and receivers by feeding them with a GMT
## signal and verifying that there are no errors on the CTRs.
##
################################################################################
## Copyright CERN 2019
################################################################################
##
## This program is free software: you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation, either version 3 of the License, or (at your option) any later
## version.
##
## This program 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 General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program. If not, see <https://www.gnu.org/licenses/>.
##
## SPDX-License-Identifier: GPL-3.0-or-later
################################################################################
###TODO: it seems the test passes when there is no CTR in the crate:-o
......@@ -11,16 +36,17 @@ import os
import string
import time
import sys
import configparser
sys.path.append('..')
import utilities as util
import ptsexcept
def get_ctrtest_err(module):
def get_ctrtest_err(user, host, port, module):
cmd = 'echo "mo {0} rst" | /usr/local/bin/ctrtest-timdt | grep -A 7 -e MsMissedErrs | xargs'.format(module)
output = os.popen(cmd).read()
output = os.popen("ssh -p %d %s@%s '%s'" % (port, user, host, cmd)).read()
items = string.split(output)
......@@ -41,58 +67,65 @@ def main (card=None, default_directory='.',suite=None, serial=""):
############################ initialization ###################################
###############################################################################
test_results={}
result={}
config = configparser.ConfigParser()
config.read(default_directory + "/../../CONFIG.ini")
host = config['CTR.FEC']['CpuHostName']
port = int(config['CTR.FEC']['CpuPort'])
user = config['CTR.FEC']['CpuUserName']
mgt_ip = config['DUT.FEC']['MgtHostName']
mgt_pwrd = config['DUT.FEC']['MgtPassword']
ms1 = [0, 0, 0, 0]
pll1 = [0, 0, 0, 0]
miss1 = [0, 0, 0, 0]
ms2 = [0, 0, 0, 0]
pll2 = [0, 0, 0, 0]
miss2 = [0, 0, 0, 0]
errors = False
test_results={}
test_results['Ms errors'] = 1
test_results['PLL errors'] = 1
test_results['Missed errors'] = 1
###############################################################################
############################ actual test ######################################
###############################################################################
for i in range(0,4):
ms1[i], pll1[i], miss1[i] = get_ctrtest_err(i+1)
ms1[i], pll1[i], miss1[i] = get_ctrtest_err(user, host, port, i+1)
#time.sleep(60.0)
time.sleep(3.0)
ms2 = [0, 0, 0, 0]
pll2 = [0, 0, 0, 0]
miss2 = [0, 0, 0, 0]
errors = False
for i in range(0,4):
ms2[i], pll2[i], miss2[i] = get_ctrtest_err(i+1)
ms2[i], pll2[i], miss2[i] = get_ctrtest_err(user, host, port, i+1)
if (ms1[i] != ms2[i]):
result['Ms errors'] = 0
util.err_msg("Module %d: Ms errors detected"%(i+1))
#errors = True
#print 'Module {0}: Ms errors detected ({1} != {2})'.format(i+1, ms2[i], ms1[i])
test_results['Ms errors'] = 0
util.err_msg("Module %s: Ms errors detected ({%s} != {%s})"%(i+1, ms2[i], ms1[i]))
if (pll1[i] != pll2[i]):
result['PLL errors'] = 0
util.err_msg("Module %d: PLL errors detected"%(i+1))
#errors = True
#print 'Module {0}: PLL errors detected ({1} != {2})'.format(i+1, pll2[i], pll1[i])
test_results['PLL errors'] = 0
util.err_msg("Module %s: PLL errors detected ({%s} != {%s})"%(i+1, pll2[i], pll1[i]))
if (miss1[i] != miss2[i]):
result['Missed errors'] = 0
util.err_msg("Module %d: Missed errors detected"%(i+1))
#errors = True
#print 'Module {0}: Missed errors detected ({1} != {2})'.format(i+1, miss2[i], miss1[i])
test_results['Missed errors'] = 0
util.err_msg("Module %s: Missed errors detected ({%s} != {%s})"%(i+1, miss2[i], miss1[i]))
# Turn off VME crate
os.popen("snmpset -v2c -c %s %s 1.3.6.1.4.1.37968.1.1.7.2.1.3.1 i 1" % (mgt_pwrd, mgt_ip))
###############################################################################
########################## result processing ##################################
###############################################################################
if not result:
util.info_msg("All transmitters/receivers have been validated OK")
else:
util.err_msg("Board funtionality not validated")
errors = util.merge_dictionaries( test_results, result)
errors = util.summarise_test_results(testname, test_results)
sys.stdout.flush()
return 0
......
#!/usr/bin/env python
################################################################################
## CERN BE-CO-HT
## CONV-RS485-OPT-RTM
## https://www.ohwr.org/projects/conv-rs485-opt-rtm
################################################################################
##
## unit name: utilities.py
##
## description: Generic PTS framework used for running the various tests and
## logging their outputs: common utilities
##
################################################################################
## Copyright CERN 2011-2019
################################################################################
##
## This program is free software: you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation, either version 3 of the License, or (at your option) any later
## version.
##
## This program 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 General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program. If not, see <https://www.gnu.org/licenses/>.
##
## SPDX-License-Identifier: GPL-3.0-or-later
################################################################################
import os
import sys
import inspect
......@@ -5,25 +37,11 @@ import numpy as np
import string
import ptsexcept
DEBUG = False
INFO = True
WARRNING = True
CRITICAL = True
TOPDIRNAME ="opt-pts"
mintemp = 15
maxtemp = 60
fmcmasterfip_commonpath="/python/common"
fmcmasterfip_regspath="/python/regs"
speclib_path = '/software/spec-sw/tools/libspec.so';
faldacq_path = "/software/fmc-adc-100m14b4cha-sw/libtools/fald-acq"
def lineno(steps = 1):
"""Returns the current line number in our program."""
ptr = inspect.currentframe().f_back
......@@ -172,5 +190,3 @@ def merge_dictionaries_prefix(dict0, dict1, prefix0, prefix1):
tmp[prefix1+k]=v
return tmp
#! /usr/bin/python
# coding: utf8
#!/usr/bin/env python
################################################################################
## CERN BE-CO-HT
## CONV-RS485-OPT-RTM
## https://www.ohwr.org/projects/conv-rs485-opt-rtm
################################################################################
##
## unit name: vv_skt.py
##
## description: A simple python class to handle Telnet communication with an
## ELMA crate.
##
################################################################################
## Copyright CERN 2014-2019
################################################################################
##
## This program is free software: you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation, either version 3 of the License, or (at your option) any later
## version.
##
## This program 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 General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program. If not, see <https://www.gnu.org/licenses/>.
##
## SPDX-License-Identifier: GPL-3.0-or-later
################################################################################
# Copyright CERN, 2014
# Author: Julian Lewis <julian.lewis@cern.ch>
# Theodor Stana <t.stana@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
import sys
import time
from ctypes import *
import os, errno, re, sys, struct
from ptsexcept import *
import socket
from socket import SHUT_RDWR
import binascii
from ptsdefine import *
from ptsexcept import *
import utilities as util
class SKT:
def __init__(self, lun=None):
def __init__(self, lun, ip, port, user, pwrd):
""" Telnet access over a socket to ELMA I2C bus
"""
slot = int(os.environ['ELMASLOT'])
if type(lun) == type(slot):
self.lun = lun
else:
self.lun = slot
#raise PtsWarning("Warning: SKT __init__: Bad lun=(slot), default to %s" % slot)
self.ip = ip
self.port = port
self.user = user
self.pwrd = pwrd
self.base = 0;
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((os.environ['ELMAIP'], 23))
addr = (self.ip, self.port)
s = socket.create_connection(addr)
s.recv(256)
s.send("admin\r\n")
s.send("%s\r\n" % self.user)
s.recv(256)
s.send(os.environ['ELMAPWD'] + "\r\n")
s.send("%s\r\n" % self.pwrd)
s.recv(256)
self.handle = s
......@@ -48,14 +60,11 @@ class SKT:
ver = self.handle.recv(256)
pos = ver.find("Software version")
if (pos == -1):
util.crit_msg("Crate %s not responding as expected" % os.environ['ELMAIP'])
#print("Unexpected response from \"version\" command, exiting...")
#self.close()
util.crit_msg("Crate %s not responding as expected" % self.addr)
sys.exit(2)
ver = float(ver[pos+17:pos+21])
self.ver = ver
def vv_read(self, byte_offset):
""" Read from the application FPGA via ELMA telnet
The byte offset will be aligned to D32
......@@ -67,7 +76,6 @@ class SKT:
if (self.ver < 2.27):
rn = byte_offset/4 + 1
cm = "readreg %d %d\r\n" % (self.lun,rn)
#print "vv_read:Debug:cm:%s\n" % (cm)
self.handle.send(cm)
orig = self.handle.recv(256)
rp = orig
......@@ -81,11 +89,6 @@ class SKT:
return rp
def vv_init(self):
""" Init the library, its a NO-OP in SKT class
"""
return self.handle
def vv_close(self):
""" Close the socket
"""
......
#!/bin/sh
################################################################################
## CERN BE-CO-HT
## CONV-RS485-OPT-RTM
## https://www.ohwr.org/projects/conv-rs485-opt-rtm
################################################################################
##
## unit name: run-pts.sh
##
## description: Top level script to run the full PTS of the CONV-RS485-OPT-RTM.
##
################################################################################
## Copyright CERN 2019
################################################################################
##
## This program is free software: you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation, either version 3 of the License, or (at your option) any later
## version.
##
## This program 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 General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program. If not, see <https://www.gnu.org/licenses/>.
##
## SPDX-License-Identifier: GPL-3.0-or-later
################################################################################
BOARD="OptRtm"
LOGDIR=`pwd`"/log/"
mkdir -p "$LOGDIR"
serial=0000
extra_serial=0000
serial=$1
if [ x$1 = x"" ]; then
echo -n "Please scan CERN serial number bar-code, then press [ENTER]: "
read serial
fi
if [ x$serial = x"" ]; then
serial=0000
fi
extra_serial=$2
if [ x$2 = x"" ]; then
echo -n "If needed input extra serial number and press [ENTER]"\
"OR just press [ENTER]: "
read extra_serial
fi
if [ x$extra_serial = x"" ]; then
extra_serial=0000
fi
echo
board_plugged=$3
echo -n "---> Now please plug in the board and then press [ENTER]"
read board_plugged
# run tests
cd python
python pts.py -b $BOARD -s $serial -e $extra_serial -l $LOGDIR 00 01 02
cd ..
echo
echo "---------------"
echo
echo "End of the test"
#===============================================================================
# CERN (BE-CO-HT)
# PTS definitions file
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
#
# date of creation: 2013-10-31
#
# version: 1.0
#
# description:
# This module contains register address definitions that are used across the
# various tests. Importing this module inside a test script makes these
# definitions available for use within a bus.vv_write or bus.vv_read method
# (see vv_pts.py for these methods).
#
# dependencies:
# none.
#
# references:
# none.
#
#===============================================================================
# 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-10-31 Theodor Stana t.stana@cern.ch File created
#===============================================================================
# TODO: -
#===============================================================================
BOARD = "$BOARD"
# ELMA crate definitions
ELMAIP = "$ELMAIP"
ELMAPWD = "$ELMAPWD"
ELMASLOT = $ELMASLOT
# Board ID register
BIDR = 0x000
BIDR_ARR = [ "TBLO", "T485" ]
# Control and Status Register
CSR = 0x004
CSR_CHLEDT_OFS = 0
CSR_STLEDT_OFS = 1
CSR_RLEDT_OFS = 2
CSR_TTLPT_OFS = 3
CSR_REARPT_OFS = 4
CSR_TSTCVCC_OFS = 5
CSR_TSTCMUXEN_OFS = 6
CSR_TSTCS0_OFS = 7
CSR_TSTCS1_OFS = 8
CSR_RST_UNLOCK_OFS = 14
CSR_RST_OFS = 15
CSR_SWITCH_OFS = 16
CSR_RTM_OFS = 24
CSR_I2C_ERR_OFS = 30
CSR_I2C_WDTO_OFS = 31
# Line Status Register
LSR = 0x008
LSR_FRONT_OFS = 0
LSR_FRONTINV_OFS = 6
LSR_REAR_OFS = 10
LSR_REARFS_OFS = 26
# Termination Enable Register
TER = 0x00c
TER_ITERM_OFS = 0
TER_OTERM_OFS = 6
TER_HWVERS_OFS = 16
# 1-Wire base address, used in therm_id.py
TEMP_1WIRE_BASE = 0x010
# 1-Wire unique ID
UIDREGLS = 0xac # 1-wire chip Unique ID - LSB
UIDREGMS = 0xb0 # 1-wire chip Unique ID - MSB
# DAC and clock info registers and offsets, used in dac_vcxo_pll.py
PLL_DAC_BASE = 0X020
VCXO_DAC_BASE = 0x080
PLL_CLKINFO_BASE = 0x100
VCXO_CLKINFO_BASE = 0x120
CLKINFO_RST_OFS = 0x014
CLKINFO_ENABLE_OFS = 0x018
CLKINFO_VALUE_OFS = 0x010
# SFP I2C master base address, used in sfp_eeprom.py
SFP_EEPROM_BASE = 0x140
# SFP endpoint, miniNIC and buffer RAM base addresses and offsets,
# used in sfp_test.py
SFP_BASE = 0x200
SFP_ENDPOINT_OFS = 0x000
SFP_MINIC_OFS = 0x200
SFP_DPRAM_OFS = 0x600
# Pulse counter base address
PULSE_CNT_BASE = 0xc00
#!/bin/bash
export BOARD="opt-rtm"
export ELMAIP="cfvm-774-opt-pts2"
export ELMAPWD="Gr@nBr@st0"
export ELMASLOT=5
#! /usr/bin/python
# coding: utf8
# Copyright CERN, 2014
# Author: Julian Lewis <julian.lewis@cern.ch>
# Theodor Stana <t.stana@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
import sys
import time
from ctypes import *
import os, errno, re, sys, struct
from ptsexcept import *
import socket
from socket import SHUT_RDWR
import binascii
from ptsdefine import *
import utilities as util
class SKT:
def __init__(self, lun=None):
""" Telnet access over a socket to ELMA I2C bus
"""
slot = int(os.environ['ELMASLOT'])
if type(lun) == type(slot):
self.lun = lun
else:
self.lun = slot
#raise PtsWarning("Warning: SKT __init__: Bad lun=(slot), default to %s" % slot)
self.base = 0;
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((os.environ['ELMAIP'], 23))
s.recv(256)
s.send("admin\r\n")
s.recv(256)
s.send(os.environ['ELMAPWD'] + "\r\n")
s.recv(256)
self.handle = s
# get crate firmware version, to apply proper address in readreg/writereg
self.handle.send("version\r\n")
ver = self.handle.recv(256)
pos = ver.find("Software version")
if (pos == -1):
util.crit_msg("Crate %s not responding as expected" % os.environ['ELMAIP'])
#print("Unexpected response from \"version\" command, exiting...")
#self.close()
sys.exit(2)
ver = float(ver[pos+17:pos+21])
self.ver = ver
def vv_read(self, byte_offset):
""" Read from the application FPGA via ELMA telnet
The byte offset will be aligned to D32
The value will contain the 32 bit integer read
"""
try:
cm = "readreg %d %x\r\n" % (self.lun, byte_offset)
if (self.ver < 2.27):
rn = byte_offset/4 + 1
cm = "readreg %d %d\r\n" % (self.lun,rn)
#print "vv_read:Debug:cm:%s\n" % (cm)
self.handle.send(cm)
orig = self.handle.recv(256)
rp = orig
rp = rp.split(" ")[3]
rp = rp.split("\n")[0]
rp = int(rp,16)
except Exception as e:
msg = "vv_read: No reply from register at address 0x%03x " % (byte_offset)
raise PtsException(msg)
return rp
def vv_init(self):
""" Init the library, its a NO-OP in SKT class
"""
return self.handle
def vv_close(self):
""" Close the socket
"""
self.handle.shutdown(SHUT_RDWR)
self.handle.close()
self.handle = 0
return 0
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