Skip to content

Commit

Permalink
add better help for tlv add
Browse files Browse the repository at this point in the history
  • Loading branch information
bradjc committed Jan 23, 2024
1 parent cb7aedc commit a3d173a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 2 additions & 4 deletions tockloader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,16 +1188,14 @@ def main():
)

# Add subcommands for adding each TLV so we can specify number of arguments.
for tlvname, nargs in tbfh.get_addable_tlvs():
for tlvname, nargs, param_help in tbfh.get_addable_tlvs():
tbf_tlv_add_tlv = tbf_tlv_add_subparser.add_parser(
tlvname,
parents=[parent],
help="Add a {} TLV to the TBF header".format(tlvname),
)
tbf_tlv_add_tlv.set_defaults(func=command_tbf_tlv_add)
tbf_tlv_add_tlv.add_argument(
"parameters", help="Relevant values for this TLV", nargs=nargs
)
tbf_tlv_add_tlv.add_argument("parameters", help=param_help, nargs=nargs)
tbf_tlv_add_tlv.add_argument("tab", help="The TAB or TABs to modify", nargs="*")

## MODIFY
Expand Down
9 changes: 7 additions & 2 deletions tockloader/tbfh.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def object(self):
class TBFTLVWriteableFlashRegions(TBFTLV):
TLVID = TBFTLV.HEADER_TYPE_WRITEABLE_FLASH_REGIONS
NUMBER_PARAMETERS = 2
PARAMETER_HELP = "<offset> <length>"

def __init__(self, buffer, parameters=[]):
self.valid = False
Expand Down Expand Up @@ -243,6 +244,7 @@ def object(self):
class TBFTLVPackageName(TBFTLV):
TLVID = TBFTLV.HEADER_TYPE_PACKAGE_NAME
NUMBER_PARAMETERS = 1
PARAMETER_HELP = "<name>"

def __init__(self, buffer, parameters=[]):
self.valid = True
Expand Down Expand Up @@ -338,6 +340,7 @@ def object(self):
class TBFTLVFixedAddress(TBFTLV):
TLVID = TBFTLV.HEADER_TYPE_FIXED_ADDRESSES
NUMBER_PARAMETERS = 2
PARAMETER_HELP = "<ram_address> <flash_address>"

def __init__(self, buffer, parameters=[]):
self.valid = False
Expand Down Expand Up @@ -514,6 +517,7 @@ def object(self):
class TBFTLVPersistentACL(TBFTLV):
TLVID = TBFTLV.HEADER_TYPE_PERSISTENT_ACL
NUMBER_PARAMETERS = 3
PARAMETER_HELP = "<write_id> [read_id,read_id,...] [modify_id,modify_id,...]"

def __init__(self, buffer, parameters=[]):
self.valid = False
Expand Down Expand Up @@ -626,7 +630,8 @@ def object(self):

class TBFTLVKernelVersion(TBFTLV):
TLVID = TBFTLV.HEADER_TYPE_KERNEL_VERSION
NUMBER_PARAMETERS = 2
NUMBER_PARAMETERS = 1
PARAMETER_HELP = "<version>"

def __init__(self, buffer, parameters=[]):
self.valid = False
Expand Down Expand Up @@ -695,7 +700,7 @@ def get_addable_tlvs():
addable_tlvs = []
for k, v in TLV_MAPPINGS.items():
try:
addable_tlvs.append((k, v.NUMBER_PARAMETERS))
addable_tlvs.append((k, v.NUMBER_PARAMETERS, v.PARAMETER_HELP))
except:
pass
return addable_tlvs
Expand Down

0 comments on commit a3d173a

Please sign in to comment.