AMCT Python Software

AMCT Purpose

The goal is to develop a set of routines to automatically (i.e. without human intervention) test AMC13 hardware using python language. Tests will exercise the functionality of the AMC13 card(s) and report errors/failures. The tool allows for a detailed testing of the AMC hardware in both supervised and non-supervised fashion and it is meant to be used as a part of the production and quality testing of the AMC13 hardware.


For python tool, typically you need to use `virtualenv` to create a separate python environment and install all dependencies. It creates a folder which contains all the necessary executables to use the packages that a Python project would need. Before starting, make sure you have 'pip' and 'virtualenv'. Use your favorite package manager to install them.

Virtualenv Installation

After you set the 'virtualenv', you need to activate it to run the code for your tests.

  • cd ./dev_tools
  • source virtualenv/bin/activate
  • pip install --upgrade pip
  • python develop

Python 2.7.12 Installation

If you dont have python 2.7.12 version (it is better than 2.6.X version) you can install it as following:

Now you have python 2.7.12. If you also want to install ipython:

  • pip install ipython

Running the AMCT Tool

Before running the AMCT tool you can look at the help options:
> dev_tools]$ amct --help
Usage: amct [OPTIONS] COMMAND [ARGS]...

  -v, --verbose
  -d, --debug
  -c, --config PATH               Global configuration
  --version                       Show the version and exit.
  -h, --help                      Show this message and exit.

  amctool    Utilities for testing AMC13 interactively.
  firmware   Operations for testing AMC13 firmware.
  testsuite  Run predefined test-suites against AMC13...

AMCT tool executes all the AMC13Tool2 commands and run them using new scripting language, such as:

For example:
>'en 1-12 f t')
>'localL1A o 1') 
>'lt 5') 
>'rv STATUS*')
>'re') #etc...
  •'any AMC13Tool2_command') # run=do (select your favorite one.)
For example:
>'en 1-12 f t')
>'localL1A o 1') 
>'lt 5') 
>'rv STATUS*')
>'re') #etc...

Info : If you want to print the test result as a table just say:

>print'any AMC13Tool2_command') 
For example:
> print'nodes t1 *ttc*error*')
9 nodes matched
0: STATUS.TTC.BCNT_ERROR                                        (addr=00000000 mask=00000040)  r
1: STATUS.TTC.BCNT_ERRORS_HI                                    (addr=00000045 mask=0000ffff)  r
2: STATUS.TTC.BCNT_ERRORS_LO                                    (addr=00000044 mask=ffffffff)  r
3: STATUS.TTC.MULT_BIT_ERROR                                    (addr=00000000 mask=00000100)  r
4: STATUS.TTC.MULT_BIT_ERRORS_HI                                (addr=00000043 mask=0000ffff)  r
5: STATUS.TTC.MULT_BIT_ERRORS_LO                                (addr=00000042 mask=ffffffff)  r
6: STATUS.TTC.SGL_BIT_ERROR                                     (addr=00000000 mask=00000080)  r
7: STATUS.TTC.SGL_BIT_ERRORS_HI                                 (addr=00000041 mask=0000ffff)  r
8: STATUS.TTC.SGL_BIT_ERRORS_LO                                 (addr=00000040 mask=ffffffff)  r

Code is working as Command-line tool for:

  • Interactive mode
  • Scripted mode

Testing AMC13 Cards Using Interactive Mode

In this method you will run the code inside python (better you install python 2.7 and use ipython), you will exacute all the commands from AMC13Tool2 and use them

If you use ipyhon do:

>amct amctool ipython -i 322  ## SerialNumber=322
If you use pyhon do:
>amct amctool python -i 322

Then start to do test!!!

Here is an example to check registers and looking at differences of registers with and without trigger using interactive mode.

>r1 = amc.get_registers()    # get  registers
>r1['STATUS.AMC01.COUNTERS.AMC13_AMC_EVENTS_LO']   #check specific register
>'en 1-12 f t')    # create fake events
>'localL1A o 1 1')    # configure localL1A)
>'lt 5')    # send 5 triggers
>r2 = amc.get_registers()     # get  registers
>r2['STATUS.AMC01.COUNTERS.AMC13_AMC_EVENTS_LO']     # check specific register after send 5 trig.
>rdiff = amc.diff_registers(r1, r2)    # define diff function to check the differences with/without trig.
>rdiff['STATUS.AMC01.COUNTERS.AMC13_AMC_EVENTS_LO']    # check diff of registers with/without trig.

Testing AMC13 Cards Using Scripted Mode

In this method you can run your commands inside the script that you prepared and can test the AMC13 cards. I have prepared an example which will test the event and time counter registers. This script will check the expected and observed values of the register(s) and compare the expected value with observed value. If the expected/observed values are equal test result will be OK. Here is the example of the script:

test1.pyamc : script to check some registers.

Tests are organized into testsuite. You can execute them against every AMC13 board like so:

  • cd dev_tools (note: dont forget to activate virtualenv)

amct --verbose testsuite run --name c01 -i 161/c

(SN =161 and c01: a folder that contain the test1.pyamc script)

--> If expected and observed values are the same then you will see below message:

INFO	13772 [08/17/2016 14:02:51]:	Testsuite c01 finished OK

--> If expected and observed values are different then you will see the message of the problematic register and its expected and observed values!

STATUS.SFP.SFP0.EVENTS_BUILT error, expected: 6, observed: 5

-- SemirayGirgisChyla - 08 Aug 2016

Topic revision: r12 - 19 Aug 2016 - SemirayGirgisChyla
  • Edit
  • Attach
Ideas, requests, problems regarding TWiki? Send feedback