diff options
author | Harald Welte <laforge@osmocom.org> | 2022-07-30 16:30:33 +0200 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2022-07-30 16:37:01 +0200 |
commit | 51b3abb0006ed3fd7ce797b4e59cdd74ee2ac57b (patch) | |
tree | 315ba04de0839f380954b1acb73d6aad44152c75 | |
parent | 7416d463a4081cfbfdd681db22650dd6c5b7a2b9 (diff) |
ts_31_102: Fix terminal_profile, envelope and envelope_sms commands
In commit Ib88bb7d12faaac7d149ee1f6379bc128b83bbdd5 I accidentially
broke those commands by adding argparse definitions for better
documentation. When adding the @cmd2.with_argparser decorator,
the method argument changes from the raw string to an argparse.Namespace
object.
This patch fixes the below exception:
pySIM-shell (MF/ADF.USIM)> terminal_profile ffffffff
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/cmd2/cmd2.py", line 2129, in onecmd_plus_hooks
stop = self.onecmd(statement, add_to_history=add_to_history)
File "/usr/local/lib/python3.10/dist-packages/cmd2/cmd2.py", line 2559, in onecmd
stop = func(statement)
File "/usr/local/lib/python3.10/dist-packages/cmd2/decorators.py", line 336, in cmd_wrapper
return func(*args_list, **kwargs)
File "/space/home/laforge/projects/git/pysim/pySim/ts_31_102.py", line 1274, in do_terminal_profile
(data, sw) = self._cmd.card._scc.terminal_profile(arg)
File "/space/home/laforge/projects/git/pysim/pySim/commands.py", line 583, in terminal_profile
data_length = len(payload) // 2
TypeError: object of type 'Namespace' has no len()
Change-Id: Ia861eeb2970627d3ecfd0ca73f75ca571c6885b2
Fixes: Ib88bb7d12faaac7d149ee1f6379bc128b83bbdd5
-rw-r--r-- | pySim/ts_31_102.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py index 7850459..02ef005 100644 --- a/pySim/ts_31_102.py +++ b/pySim/ts_31_102.py @@ -1264,40 +1264,40 @@ class ADF_USIM(CardADF): term_prof_parser.add_argument('PROFILE', help='Hexstring of encoded terminal profile') @cmd2.with_argparser(term_prof_parser) - def do_terminal_profile(self, arg): + def do_terminal_profile(self, opts): """Send a TERMINAL PROFILE command to the card. This is used to inform the card about which optional features the terminal (modem/phone) supports, particularly in the context of SIM Toolkit, Proactive SIM and OTA. You must specify a hex-string with the encoded terminal profile you want to send to the card.""" - (data, sw) = self._cmd.card._scc.terminal_profile(arg) + (data, sw) = self._cmd.card._scc.terminal_profile(opts.PROFILE) self._cmd.poutput('SW: %s, data: %s' % (sw, data)) envelope_parser = argparse.ArgumentParser() envelope_parser.add_argument('PAYLOAD', help='Hexstring of encoded payload to ENVELOPE') @cmd2.with_argparser(envelope_parser) - def do_envelope(self, arg): + def do_envelope(self, opts): """Send an ENVELOPE command to the card. This is how a variety of information is communicated from the terminal (modem/phone) to the card, particularly in the context of SIM Toolkit, Proactive SIM and OTA.""" - (data, sw) = self._cmd.card._scc.envelope(arg) + (data, sw) = self._cmd.card._scc.envelope(opts.PAYLOAD) self._cmd.poutput('SW: %s, data: %s' % (sw, data)) envelope_sms_parser = argparse.ArgumentParser() envelope_sms_parser.add_argument('TPDU', help='Hexstring of encoded SMS TPDU') @cmd2.with_argparser(envelope_sms_parser) - def do_envelope_sms(self, arg): + def do_envelope_sms(self, opts): """Send an ENVELOPE(SMS-PP-Download) command to the card. This emulates a terminal (modem/phone) having received a SMS with a PID of 'SMS for the SIM card'. You can use this command in the context of testing OTA related features without a modem/phone or a cellular netwokr.""" tpdu_ie = SMS_TPDU() - tpdu_ie.from_bytes(h2b(arg)) + tpdu_ie.from_bytes(h2b(opts.TPDU)) dev_ids = DeviceIdentities( decoded={'source_dev_id': 'network', 'dest_dev_id': 'uicc'}) sms_dl = SMSPPDownload(children=[dev_ids, tpdu_ie]) |