leds.py 4.45 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
##_______________________________________________________________________________________________
##
##                                       CONV-TTL-RS485 PTS
##
##                                         CERN,BE/CO-HT
##_______________________________________________________________________________________________
##
##-----------------------------------------------------------------------------------------------
##
##                                     CONV-TTL-RS485 LEDs test
##
##-----------------------------------------------------------------------------------------------
##
## Description  Testing of the Front Panel status LEDs (IC1 and bi-color LEDs) and pulse
##              LEDs (IC5 and channel LEDs) of the CONV-TTL-BLO board.
##
##              For this test, the operator's intervention is needed; when prompted, the operator
##              needs to visually check the LEDS.
##
##              The FPGA gateware sequences through each of the front panel LEDs (pulse LEDs
##              status LEDs) based on the value of the current test field in the PTS control
##              register. In order to start and stop LED sequencing, the test sets and clears
##              control bits in the PTS CSR.
##
## Authors      Julian Lewis (Julian.Lewis@cern.ch)
##              Theodor-Adrian Stana (t.stana@cern.ch)
## Website      http://www.ohwr.org/projects/pts
## Date         30/10/2014
##-----------------------------------------------------------------------------------------------
##
##------------------------------------------------------------------------------------------------
##                               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
##-------------------------------------------------------------------------------------------------

##-------------------------------------------------------------------------------------------------
##                                            Import
##-------------------------------------------------------------------------------------------------

# Import system modules
import sys
sys.path.append("pyts")
import time
import os, errno, re, sys, struct
import os.path
import traceback

# Import common modules
from ctypes import *
from ptsexcept import *
from vv_pts import *
from ptsdefine import *

##-------------------------------------------------------------------------------------------------
##                                             main                                              --
##-------------------------------------------------------------------------------------------------

def main(bus,tname,inf,log):

    """
    tests : Front Panel LEDs, bicolor LEDs with transceiver IC1
    uses  : pts.bit and leds.py
    """

    pel = PTS_ERROR_LOGGER(inf,log)

    try:

    # First phase of LED test, enable pulse LED sequencing
        val = bus.vv_read(CSR)
        val |= (1 << CSR_CHLEDT_OFS)
        bus.vv_write(CSR, val)

        # The gateware should blink the LEDs, ask the operator for input
        inp = raw_input("--> Are the channel LEDs blinking one by one? yes/no: ")
        while True:
            if inp.find("yes") != -1 or inp.find("YES") != -1:
                break

            if inp.find("no") != -1 or inp.find("NO") != -1:
               msg = "ERROR: Front Panel LEDs"
               pel.set(msg)
               break

            inp = raw_input('Please type "yes" or "no" to continue: ')

        return pel.get()

    except BusException, e:
        raise PtsError("SKT Exception: %s" % (e))

    except BusWarning, e:
        raise PtsError("SKT Warning: %s" % (e))

    finally:
        # Clean-up -- clear status and front LED test bits
        val = bus.vv_read(CSR)
        val &= ~((1 << CSR_CHLEDT_OFS) | (1 << CSR_STLEDT_OFS))
        bus.vv_write(CSR, val)