dexter has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/30636 )


Change subject: pySim-prog: make dry-run more realistic
......................................................................

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(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/36/30636/1

diff --git a/pySim-prog.py b/pySim-prog.py
index 5b452ee..d980901 100755
--- a/pySim-prog.py
+++ b/pySim-prog.py
@@ -738,22 +738,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()
@@ -766,15 +765,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 https://gerrit.osmocom.org/c/pysim/+/30636
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I3653bada1ad26bcf75109a935105273ee9d1525c
Gerrit-Change-Number: 30636
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <[email protected]>
Gerrit-MessageType: newchange

Reply via email to