init_reader: Print device name/number of chosen reader

It's sometimes not clear what automatic defaults are chosen when
starting a pySim program; let's inform the user of the chosen reader.

Change-Id: I87fd934243bc3556fd6db0ce6d219c22a60c2db4
laforge/bertlv
Harald Welte 2 years ago
parent 6e70660b5c
commit 1d56c7a411
  1. 4
      contrib/jenkins.sh
  2. 5
      pySim/tests/test_utils.py
  3. 9
      pySim/transport/__init__.py
  4. 4
      setup.py

@ -24,9 +24,11 @@ pip install jsonpath-ng
pip install construct
pip install bidict
pip install gsm0338
pip install nose
# Execute automatically discovered unit tests first
python -m unittest discover -v -s tests/
# - cannot use "python -m ./setup.py test" here as that somehow doesn't work in venv
nosetests
# Run pylint to find potential errors
# Ignore E1102: not-callable

@ -1,5 +1,3 @@
#!/usr/bin/env python3
import unittest
from pySim import utils
from pySim.ts_31_102 import EF_SUCI_Calc_Info
@ -201,6 +199,3 @@ class TestComprTlv(unittest.TestCase):
self.assertEqual(res, b'\x7f\x12\x34')
res = utils.comprehensiontlv_encode_tag({'tag': 0x1234, 'comprehension':True})
self.assertEqual(res, b'\x7f\x92\x34')
if __name__ == "__main__":
unittest.main()

@ -217,19 +217,20 @@ def init_reader(opts, **kwargs) -> Optional[LinkBase]:
sl = None # type : :Optional[LinkBase]
try:
if opts.pcsc_dev is not None:
print("Using PC/SC reader interface")
print("Using PC/SC reader interface (dev_number=%u)" % opts.pcsc_dev)
from pySim.transport.pcsc import PcscSimLink
sl = PcscSimLink(opts.pcsc_dev, **kwargs)
elif opts.osmocon_sock is not None:
print("Using Calypso-based (OsmocomBB) reader interface")
print("Using Calypso-based (OsmocomBB) reader interface (sock='%s')" % opts.osmocon_sock)
from pySim.transport.calypso import CalypsoSimLink
sl = CalypsoSimLink(sock_path=opts.osmocon_sock, **kwargs)
elif opts.modem_dev is not None:
print("Using modem for Generic SIM Access (3GPP TS 27.007)")
print("Using modem for Generic SIM Access (3GPP TS 27.007) (dev='%s', baud=%u)" %
(opts.modem_dev, opts.modem_baud))
from pySim.transport.modem_atcmd import ModemATCommandLink
sl = ModemATCommandLink(device=opts.modem_dev, baudrate=opts.modem_baud, **kwargs)
else: # Serial reader is default
print("Using serial reader interface")
print("Using serial reader interface (dev='%s', baud=%u)" % (opts.device, opts.baudrate))
from pySim.transport.serial import SerialSimLink
sl = SerialSimLink(device=opts.device, baudrate=opts.baudrate, **kwargs)
return sl

@ -22,5 +22,7 @@ setup(
'pySim-prog.py',
'pySim-read.py',
'pySim-shell.py'
]
],
test_suite='nose.collector',
tests_require=['nose'],
)

Loading…
Cancel
Save