Closed bdorney closed 6 years ago
Additionally the undocumented commands test1
and test2
are broken in the current software and it's not clear how to fix them or what they do. So I have dropped support for them at present.
If this is desired perhaps @mexanick or @evka85 can resolve the errors reported in the above elog which are beyond the scope of this PR.
I would be more in favour of implementing these changes using the ArgParse
module: it's more future safe, and can persist the current usage, while improving the clarity of the usage.
I had started to implement this quite some time ago, and then @mexanick made the change that prompted my start (card_name
).
The basics are effectively the same as OptParse
, but there is a difference between an argument
(mandatory), and an option
(optional)
import argparse
parser = argparse.ArgumentParser(description='Arguments to supply to sca.py')
parser.add_argument('card', metavar='card', type=str,
help='Birdname CTP7 hostname')
parser.add_argument('oh_mask', metavar='oh_mask', type=str,
help='Mask of OptoHybrids to operate on, hex (0x) or binary (0b) accepted')
parser.add_argument('command', metavar='command', type=str,
help='Command to send via SCA')
parser.add_argument('-t', '--type', metavar='imgtype', type=str,
help='Firmware image type \'program-fpga\' command')
parser.add_argument('-f','--file', metavar='imgfile', type=str,
help='Firmware image file to load for \'program-fpga\' command')
parser.add_argument('--bitfile', metavar='bitfile', type=str,
help='BIT image file to load for \'compare-mcs-bit\' command')
parser.add_argument('--mcsfile', metavar='mcsfile', type=str,
help='MCS image file to load for \'compare-mcs-bit\' command')
args = parser.parse_args()
The syntax would remain identical for most use cases we've currently had, and the parsing and logic makes sure that for certain commands, the required options are specified.
Ah I thought argparse
was not available in python2.7 but only from 3.X.
Okay if it's available in 2.7 I can easily make this switch.
It's available even in 2.6
, and officially, 2.7
deprecates optparse
.
I've been using argparse
almost exclusively for any new thing I develop
Switched to argparse
Now using sub commands. Will test this afternoon.
rebased onto 70d243e5d3513e734d289618876a22530633726d
Okay so testing completed on the daq machine, everything behaves as expected.
I was unable to install the rpms (elog) on the ctp7
but would argue this is beyond the scope of this PR.
The only thing is needed to do from the ctp7
that cannot be done from the DAQ machine is to program the FPGA using JTAG via the SCA. However this is 100% superseded by the working promless functionality.
So if this meets your approval @jsturdy maybe we can merge it in (need the gpio
functionality for OHv3c testing.)
Description
Exhibited several bugs with
sca.py
while testing v3 electronics. All of which seem to relate to lack of care with argument order ofsys.argv
. To be more pythonic I've implemented anargparser
object and have done extensive testing.Previous positional arguments have been maintained.
Noted significant divergences between
sca.py
on thetexas
account of CTP7 and our use case. This should be really frowned upon and active development on private area locations should be stopped.Types of changes
Motivation and Context
Changes to
sca.py
over time have made the order of arguments challenging to keep up with and resulted in ambiguity. This addresses #21 and other incidents in which the addition of the<cardName>
has caused an index error.Additionally several undocumented instructions are now necessary to configure the OHv3c (bad). These are now documented.
How Has This Been Tested?
Extensively tested at this elog postExtensively tested usingSee postargparser
at this elog postNew usage:
Additional option menus for
sub_commands
:Comparing firmware files:
Programming FPGA using JTAG via SCA:
Setting gpio direction:
Setting gpio output:
Comparing FW Files
Issuing Resets
Reading FPGA-ID
GPIO Commands
Programming FPGA
This is not yet testable since it requires changes to
setup_ctp7.sh
and migration of reg_utils to the actual card. However the script correctly identifies that it should not be called from the DAQ machine with this command.Reading sysmon
Checklist: