mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-24 14:28:32 +03:00
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
This commit is contained in:
@@ -1264,40 +1264,40 @@ class ADF_USIM(CardADF):
|
|||||||
term_prof_parser.add_argument('PROFILE', help='Hexstring of encoded terminal profile')
|
term_prof_parser.add_argument('PROFILE', help='Hexstring of encoded terminal profile')
|
||||||
|
|
||||||
@cmd2.with_argparser(term_prof_parser)
|
@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.
|
"""Send a TERMINAL PROFILE command to the card.
|
||||||
This is used to inform the card about which optional
|
This is used to inform the card about which optional
|
||||||
features the terminal (modem/phone) supports, particularly
|
features the terminal (modem/phone) supports, particularly
|
||||||
in the context of SIM Toolkit, Proactive SIM and OTA. You
|
in the context of SIM Toolkit, Proactive SIM and OTA. You
|
||||||
must specify a hex-string with the encoded terminal profile
|
must specify a hex-string with the encoded terminal profile
|
||||||
you want to send to the card."""
|
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))
|
self._cmd.poutput('SW: %s, data: %s' % (sw, data))
|
||||||
|
|
||||||
envelope_parser = argparse.ArgumentParser()
|
envelope_parser = argparse.ArgumentParser()
|
||||||
envelope_parser.add_argument('PAYLOAD', help='Hexstring of encoded payload to ENVELOPE')
|
envelope_parser.add_argument('PAYLOAD', help='Hexstring of encoded payload to ENVELOPE')
|
||||||
|
|
||||||
@cmd2.with_argparser(envelope_parser)
|
@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
|
"""Send an ENVELOPE command to the card. This is how a
|
||||||
variety of information is communicated from the terminal
|
variety of information is communicated from the terminal
|
||||||
(modem/phone) to the card, particularly in the context of
|
(modem/phone) to the card, particularly in the context of
|
||||||
SIM Toolkit, Proactive SIM and OTA."""
|
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))
|
self._cmd.poutput('SW: %s, data: %s' % (sw, data))
|
||||||
|
|
||||||
envelope_sms_parser = argparse.ArgumentParser()
|
envelope_sms_parser = argparse.ArgumentParser()
|
||||||
envelope_sms_parser.add_argument('TPDU', help='Hexstring of encoded SMS TPDU')
|
envelope_sms_parser.add_argument('TPDU', help='Hexstring of encoded SMS TPDU')
|
||||||
|
|
||||||
@cmd2.with_argparser(envelope_sms_parser)
|
@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.
|
"""Send an ENVELOPE(SMS-PP-Download) command to the card.
|
||||||
This emulates a terminal (modem/phone) having received a SMS
|
This emulates a terminal (modem/phone) having received a SMS
|
||||||
with a PID of 'SMS for the SIM card'. You can use this
|
with a PID of 'SMS for the SIM card'. You can use this
|
||||||
command in the context of testing OTA related features
|
command in the context of testing OTA related features
|
||||||
without a modem/phone or a cellular netwokr."""
|
without a modem/phone or a cellular netwokr."""
|
||||||
tpdu_ie = SMS_TPDU()
|
tpdu_ie = SMS_TPDU()
|
||||||
tpdu_ie.from_bytes(h2b(arg))
|
tpdu_ie.from_bytes(h2b(opts.TPDU))
|
||||||
dev_ids = DeviceIdentities(
|
dev_ids = DeviceIdentities(
|
||||||
decoded={'source_dev_id': 'network', 'dest_dev_id': 'uicc'})
|
decoded={'source_dev_id': 'network', 'dest_dev_id': 'uicc'})
|
||||||
sms_dl = SMSPPDownload(children=[dev_ids, tpdu_ie])
|
sms_dl = SMSPPDownload(children=[dev_ids, tpdu_ie])
|
||||||
|
|||||||
Reference in New Issue
Block a user