path: root/pySim/transport/__init__.py
diff options
authorHarald Welte <laforge@osmocom.org>2021-04-11 12:19:36 +0200
committerHarald Welte <laforge@osmocom.org>2021-04-11 12:35:25 +0200
commit73ad5b384bbe9917a3db458ae5e0d77f39e24eac (patch)
tree5248e3d98949a27735d04f143fd38bad473664f2 /pySim/transport/__init__.py
parent84724f567c337b11df0f82a46ce660149f5c5a6b (diff)
Move reader related argument parser to transport module
Ideally that shared definition would be used by all programs, rather than copy+pasting it. Unfortunately pySim-{read,prog} are still using optparse and first need to be converted to argparse. Change-Id: If77f53850e1ca65f42cf1dca3e0f460dac1b0d1a
Diffstat (limited to 'pySim/transport/__init__.py')
1 files changed, 25 insertions, 0 deletions
diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py
index 64a06a5..14f5aaf 100644
--- a/pySim/transport/__init__.py
+++ b/pySim/transport/__init__.py
@@ -3,6 +3,7 @@
""" pySim: PCSC reader transport link base
+import argparse
from typing import Optional
from pySim.exceptions import *
@@ -175,6 +176,30 @@ class LinkBase(object):
raise SwMatchError(sw, sw_exp.lower(), self.sw_interpreter)
return (rsp, sw)
+def argparse_add_reader_args(arg_parser):
+ """Add all reader related arguments to the given argparse.Argumentparser instance."""
+ serial_group = arg_parser.add_argument_group('Serial Reader')
+ serial_group.add_argument('-d', '--device', metavar='DEV', default='/dev/ttyUSB0',
+ help='Serial Device for SIM access')
+ serial_group.add_argument('-b', '--baud', dest='baudrate', type=int, metavar='BAUD', default=9600,
+ help='Baud rate used for SIM access')
+ pcsc_group = arg_parser.add_argument_group('PC/SC Reader')
+ pcsc_group.add_argument('-p', '--pcsc-device', type=int, dest='pcsc_dev', metavar='PCSC', default=None,
+ help='PC/SC reader number to use for SIM access')
+ modem_group = arg_parser.add_argument_group('AT Command Modem Reader')
+ modem_group.add_argument('--modem-device', dest='modem_dev', metavar='DEV', default=None,
+ help='Serial port of modem for Generic SIM Access (3GPP TS 27.007)')
+ modem_group.add_argument('--modem-baud', type=int, metavar='BAUD', default=115200,
+ help='Baud rate used for modem port')
+ osmobb_group = arg_parser.add_argument_group('OsmocomBB Reader')
+ osmobb_group.add_argument('--osmocon', dest='osmocon_sock', metavar='PATH', default=None,
+ help='Socket path for Calypso (e.g. Motorola C1XX) based reader (via OsmocomBB)')
+ return arg_parser
def init_reader(opts, **kwargs) -> Optional[LinkBase]:
Init card reader driver