laforge submitted this change.

View Change

Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved msuraev: Looks good to me, but someone else must approve
pySim-prog: make dry-run more realistic

The process_card function has a dry-run mode where one can test
parameters without actually writing to the card. However, the dry-run
feature also does not perform read operations and connects to the card
reader at a different point in time. Lets be more accurate here and
perform all operations a normal programming cycle would perform but
without calling the card.program() method.

Change-Id: I3653bada1ad26bcf75109a935105273ee9d1525c
---
M pySim-prog.py
1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/pySim-prog.py b/pySim-prog.py
index 1ea1425..dbf1148 100755
--- a/pySim-prog.py
+++ b/pySim-prog.py
@@ -718,22 +718,21 @@

def process_card(opts, first, ch):

+ # Connect transport
+ ch.get(first)
+
+ # Get card
+ card = card_detect(opts.type, scc)
+ if card is None:
+ print("No card detected!")
+ return -1
+
+ # Probe only
+ if opts.probe:
+ return 0
+
+ # Erase if requested (not in dry run mode!)
if opts.dry_run is False:
- # Connect transport
- ch.get(first)
-
- if opts.dry_run is False:
- # Get card
- card = card_detect(opts.type, scc)
- if card is None:
- print("No card detected!")
- return -1
-
- # Probe only
- if opts.probe:
- return 0
-
- # Erase if requested
if opts.erase:
print("Formatting ...")
card.erase()
@@ -746,15 +745,9 @@
imsi = None
iccid = None
if opts.read_iccid:
- if opts.dry_run:
- # Connect transport
- ch.get(False)
(res, _) = scc.read_binary(['3f00', '2fe2'], length=10)
iccid = dec_iccid(res)
elif opts.read_imsi:
- if opts.dry_run:
- # Connect transport
- ch.get(False)
(res, _) = scc.read_binary(EF['IMSI'])
imsi = swap_nibbles(res)[3:]
else:

To view, visit change 30636. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I3653bada1ad26bcf75109a935105273ee9d1525c
Gerrit-Change-Number: 30636
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: msuraev <msuraev@sysmocom.de>
Gerrit-MessageType: merged