cms-gem-daq-project / reg_utils

0 stars 9 forks source link

add a script to read a register multiple times #33

Closed AndrewLevin closed 5 years ago

AndrewLevin commented 6 years ago

This script first issues a link reset, then reads a register, whose name is an input parameter, n times, where n is also an input parameter.

Description

This script takes three mandatory input parameters: the name of the register to read, the number of times to read the register, and the sleep delay between the reads. There is also an optional output filename parameter.

The script first issues a link reset, then performs the repeated reads, then reports the register values in the form of a python dictionary. Six slow control monitoring registers are also read at the beginning at the end, and their values, and the difference between their initial and final values, is reported in the form of a table.

Help output:

usage: repeated_reg_read.py [-h] [-f filename] [--card card]
                            reg_name nreads sleeptime

Arguments to supply to repeated_reg_read.py

positional arguments:
  reg_name              Name of the register to read
  nreads                Number of reads
  sleeptime             Amount of time to sleep in microseconds

optional arguments:
  -h, --help            show this help message and exit
  -f filename, --filename filename
                        Filename to which output information is written
  --card card           CTP7 hostname (has no effect if you are running on a
                        hostname that starts with eagle)

Example command:

repeated_reg_read.py GEM_AMC.OH.OH0.GEB.VFAT1.HW_CHIP_ID 10 250 -f my_filename.txt --card eagle64

Example output:

Open pickled address table if available  /opt/cmsgemos/etc/maps/amc_address_table_top.pickle...
This script is not running on an eagle machine. rpc_connect("eagle64") will be called.
Initial value to write: 1, register GEM_AMC.GEM_SYSTEM.CTRL.LINK_RESET
|        | CRC_ERROR_CNT | PACKET_ERROR_CNT | BITSTUFFING_ERROR_CNT | TIMEOUT_ERROR_CNT | AXI_STROBE_ERROR_CNT | TRANSACTION_CNT |
|:------ | :------------ | :--------------- | :-------------------- | :---------------- | :------------------- | :-------------- |
| before | 0x00000000  | 0x00000000 | 0x00000000 | 0x00000000 | 0x00000000 | 0x00000000 |
| after | 0x00000000  | 0x00000000 | 0x00000000 | 0x00000000 | 0x00640000 | 0x00640000 |
| delta | 0  | 0 | 0 | 0 | 6553600 | 6553600 |
{'0x000012e2': 10, '0x000112e2': 90}

Types of changes

Motivation and Context

We are trying to investigate an issue of bit slip i.e. a register which should contain a constant does not have a constant value based on tests using gem_reg.py

How Has This Been Tested?

This script has been tested both on the GEM DAQ machines and on the ctp7.

Checklist:

bdorney commented 5 years ago

(use on the ctp7 requires commenting and uncommenting some of the import lines).

We will be moving to an rpm based installation on the CTP7's but this will require an updated linux image from the card makers. For this please drop the lines that need to be commented when pushing to the official repo.

bdorney commented 5 years ago

Could you please add the help menu printout and some usage examples to the PR description.

AndrewLevin commented 5 years ago

@bdorney, I have made all of the requested updates, other than https://github.com/cms-gem-daq-project/reg_utils/pull/33#issuecomment-423893577. Regarding https://github.com/cms-gem-daq-project/reg_utils/pull/33#issuecomment-423893577, it seems the import statements for running on ctp7 and DAQ PC are mutually exclusive. Please clarify what you want.

bdorney commented 5 years ago

@bdorney, I have made all of the requested updates, other than #33 (comment). Regarding #33 (comment), it seems the import statements for running on ctp7 and DAQ PC are mutually exclusive. Please clarify what you want.

This code generates an rpm that is installed on a machine. Right now these are installed on the DAQ machine. In the future the linux image of the CTP7 will be updated such that rpm's can be installed on each boot of the OS (if the card is rebooted or power cycled only things under /mnt/persistent/ persist through reboot...everything is reloaded from an image on the card.

So in this future linux image scenario, there will be no commenting/uncommenting import lines. The package is installed and it works out of the box. Please update to reflect this. For testing purposes now you needed the lines, but in the repo don't push them.

AndrewLevin commented 5 years ago

So, is it correct that these lines

from reg_utils.reg_interface.common.reg_xml_parser import getNode, parseXML
from reg_utils.reg_interface.common.print_utils import printRed
from reg_utils.reg_interface.common.jtag import initJtagRegAddrs
from reg_utils.reg_interface.common.reg_base_ops import *

will work on the ctp7 in the future, so these lines

#from rw_reg import *                                                                                                                                                                     
#from mcs import *   

can be removed?

bdorney commented 5 years ago

That is correct.

AndrewLevin commented 5 years ago

OK, the commented import lines are removed now.

AndrewLevin commented 5 years ago

@jsturdy, I have addressed all of your comments now

AndrewLevin commented 5 years ago

@jsturdy, readAddress returns an object of type str representing a hexadecimal value

bdorney commented 5 years ago

Side comment, are you casting these as 16 bit integers? Are you sure that's correct? The RPC framework only returns 32 bit integers; you can of course drop the higher bits but only in the case that the higher bits are not used.

The CTP7 registers are all 32 bits, sub registers may exist, e.g. in one 32 bit register you can have two 16 bit counters.

Do these counters that the value you're casting as 16 bit integers only use 16 bits? Or are they 32 bit counters?

AndrewLevin commented 5 years ago

@bdorney, the syntax int(XXX,16) will create an integer with as many bits necessary:

[gemuser@gem904daq01 ~]$ python
Python 2.7.5 (default, Aug  4 2017, 00:39:18) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> int('0x1000',16)
4096
>>> int('0x10000',16)
65536
>>> int('0x1000000000000',16)
281474976710656
>>> 
bdorney commented 5 years ago

I misread your response, I understand. Thanks for the example. The 16 is the base.

AndrewLevin commented 5 years ago

@bdorney, I just created a pull request for sw_utils to add this to the v3 user's guide: https://github.com/AndrewLevin/sw_utils/pull/1