mirror of https://gerrit.osmocom.org/pysim
pySim-shell: Add 'switch_channel' command
We've already had the 'open_channel' and 'close_channel' commands, which were sent to (and acknowledged by) the card. However, those commands didn't affect the pySim-shell state, i.e. all communication would still happen through the default channel '0'. With this patch we introduce a 'switch_channel' command, using which the user can determine which of the (previously opened) logical channels shall be used by pySim-shell. Change-Id: Ia76eb45c4925882ae6866e50b64d9610bd4d546d Closes: OS#6230
This commit is contained in:
parent
6dd6f3e12c
commit
20650997e8
|
@ -199,6 +199,12 @@ close_channel
|
||||||
:module: pySim-shell
|
:module: pySim-shell
|
||||||
:func: Iso7816Commands.close_chan_parser
|
:func: Iso7816Commands.close_chan_parser
|
||||||
|
|
||||||
|
switch_channel
|
||||||
|
~~~~~~~~~~~~~~
|
||||||
|
.. argparse::
|
||||||
|
:module: pySim-shell
|
||||||
|
:func: Iso7816Commands.switch_chan_parser
|
||||||
|
|
||||||
|
|
||||||
TS 102 221 commands
|
TS 102 221 commands
|
||||||
-------------------
|
-------------------
|
||||||
|
|
|
@ -963,6 +963,18 @@ class Iso7816Commands(CommandSet):
|
||||||
# this is executed only in successful case, as unsuccessful raises exception
|
# this is executed only in successful case, as unsuccessful raises exception
|
||||||
self._cmd.rs.del_lchan(opts.chan_nr)
|
self._cmd.rs.del_lchan(opts.chan_nr)
|
||||||
|
|
||||||
|
switch_chan_parser = argparse.ArgumentParser()
|
||||||
|
switch_chan_parser.add_argument(
|
||||||
|
'chan_nr', type=int, default=0, help='Channel Number')
|
||||||
|
|
||||||
|
@cmd2.with_argparser(switch_chan_parser)
|
||||||
|
def do_switch_channel(self, opts):
|
||||||
|
"""Switch currently active logical channel."""
|
||||||
|
self._cmd.lchan._select_pre(self._cmd)
|
||||||
|
self._cmd.lchan = self._cmd.rs.lchan[opts.chan_nr]
|
||||||
|
self._cmd.lchan._select_post(self._cmd)
|
||||||
|
self._cmd.update_prompt()
|
||||||
|
|
||||||
def do_status(self, opts):
|
def do_status(self, opts):
|
||||||
"""Perform the STATUS command."""
|
"""Perform the STATUS command."""
|
||||||
fcp_dec = self._cmd.lchan.status()
|
fcp_dec = self._cmd.lchan.status()
|
||||||
|
|
Loading…
Reference in New Issue