mirror of https://gerrit.osmocom.org/pysim
pysim-prog: add commandline option to probe cards
In some situations it may be helpful to know the card name (type) we deal with in advance. So lets ad an to probe that only detects the card and then exists. - Add commandline option -T --probe Change-Id: I57422d3819d52fd215ac8f13f890729aad2af76f Related: OS#3376
This commit is contained in:
parent
0e3fcaa1bb
commit
ac9dde683f
|
@ -62,6 +62,10 @@ def parse_options():
|
|||
help="Card type (user -t list to view) [default: %default]",
|
||||
default="auto",
|
||||
)
|
||||
parser.add_option("-T", "--probe", dest="probe",
|
||||
help="Determine card type",
|
||||
default=False, action="store_true"
|
||||
)
|
||||
parser.add_option("-a", "--pin-adm", dest="pin_adm",
|
||||
help="ADM PIN used for provisioning (overwrites default)",
|
||||
)
|
||||
|
@ -156,6 +160,9 @@ def parse_options():
|
|||
print kls.name
|
||||
sys.exit(0)
|
||||
|
||||
if options.probe:
|
||||
return options
|
||||
|
||||
if options.source == 'csv':
|
||||
if (options.imsi is None) and (options.batch_mode is False) and (options.read_imsi is False):
|
||||
parser.error("CSV mode needs either an IMSI, --read-imsi or batch mode")
|
||||
|
@ -525,7 +532,7 @@ def card_detect(opts, scc):
|
|||
for kls in _cards_classes:
|
||||
card = kls.autodetect(scc)
|
||||
if card:
|
||||
print "Autodetected card type %s" % card.name
|
||||
print "Autodetected card type: %s" % card.name
|
||||
card.reset()
|
||||
break
|
||||
|
||||
|
@ -540,7 +547,7 @@ def card_detect(opts, scc):
|
|||
card = ctypes[opts.type](scc)
|
||||
|
||||
else:
|
||||
raise ValueError("Unknown card type %s" % opts.type)
|
||||
raise ValueError("Unknown card type: %s" % opts.type)
|
||||
|
||||
return card
|
||||
|
||||
|
@ -589,6 +596,10 @@ if __name__ == '__main__':
|
|||
else:
|
||||
sys.exit(-1)
|
||||
|
||||
# Probe only
|
||||
if opts.probe:
|
||||
break;
|
||||
|
||||
# Erase if requested
|
||||
if opts.erase:
|
||||
print "Formatting ..."
|
||||
|
|
Loading…
Reference in New Issue