GlobalPlatform ADF.SD: Add command line reference + error message

The get_data shell command didn't have any interactive help / syntax,
and no meaningful error message in case an unknown data object name
was specified by the user.  Let's fix that.

Change-Id: I09faaf5d45118635cf832c8c513033aede1427e5
This commit is contained in:
Harald Welte 2023-07-11 08:52:39 +02:00
parent a1561fe9ae
commit fdcf3c5702
2 changed files with 17 additions and 4 deletions

View File

@ -795,8 +795,9 @@ projects like GlobalPlatformPro meanwhile.
Performs the GET DATA command as specified by GlobalPlatform.
.. argparse::
:module: pySim.global_platform
:func: ADF_SD.AddlShellCommands.get_data_parser
cmd2 settable parameters

View File

@ -223,9 +223,21 @@ class ADF_SD(CardADF):
def __init__(self):
get_data_parser = argparse.ArgumentParser()
get_data_parser.add_argument('data_object_name', type=str,
help='Name of the data object to be retrieved from the card')
def do_get_data(self, opts):
tlv_cls_name = opts.arg_list[0]
tlv_cls = DataCollection().members_by_name[tlv_cls_name]
"""Perform the GlobalPlatform GET DATA command in order to obtain some card-specific data."""
tlv_cls_name = opts.data_object_name
tlv_cls = DataCollection().members_by_name[tlv_cls_name]
except KeyError:
do_names = [camel_to_snake(str(x.__name__)) for x in DataCollection.possible_nested]
self._cmd.poutput('Unknown data object "%s", available options: %s' % (tlv_cls_name,
(data, sw) = self._cmd.card._scc.get_data(cla=0x80, tag=tlv_cls.tag)
ie = tlv_cls()