<p style="white-space: pre-wrap; word-wrap: break-word;">I think this needs improvement, also I think this may be partially redundant to the generic SIM/USIM support for pySim-shell.py, which I am currently working on.</p><p style="white-space: pre-wrap; word-wrap: break-word;">First of all we consciously decide the APDU parameters for each card and I think it should be kept that way. All those classes have autodetect methods which essentially go by the ATR. I plan to have generic classes SimCard, IsimCard and UsimCard. Those will have autodetect methods that will check weather it is a UICC or not. If it is a UICC it will further check if it is an USIM or ISIM by looking at the app-ids in EF.DIR</p><p style="white-space: pre-wrap; word-wrap: break-word;">I think it makes sense to use detect_card_type() for the first step (distinguishing from UICC), but I think the code is much more readable when the parameter change takes place in the autodetect method.</p><p style="white-space: pre-wrap; word-wrap: break-word;">Once the detection is inside the base classes things will be simpler the code will only call card_detect() and get either a specific card or a generic SimCard, IsimCard or UsimCard back and the APDU parameters will also be adjusted already.</p><p style="white-space: pre-wrap; word-wrap: break-word;">Its not very far yet, but here is the change-id: Id6527254a7305516f2d00876815e46a3c71a81b6</p><p style="white-space: pre-wrap; word-wrap: break-word;">regards.<br>Philipp</p><p>Patch set 2:<span style="border-radius: 3px; display: inline-block; margin: 0 2px; padding: 4px;background-color: #ffd4d4;">Code-Review -1</span></p><p><a href="https://gerrit.osmocom.org/c/pysim/+/24160">View Change</a></p><p>2 comments:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/c/pysim/+/24160/2/pySim-prog.py">File pySim-prog.py:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/pysim/+/24160/2/pySim-prog.py@661">Patch Set #2, Line 661:</a> <code style="font-family:monospace,monospace"></code></p><p style="white-space: pre-wrap; word-wrap: break-word;">This is dangerous. Have a look at the test output from jenkins. You will see that the FairwavesSIM fails. I ran into the same problem recently. This card seems to have a problem when trying to adm-authenticate+program with UICC APDUs.</p><p style="white-space: pre-wrap; word-wrap: break-word;">In cards.py we consciously decide whether to use UICC or the old SIM APDUs. This should be retained - especially for pySim-prog.py</p></li></ul></li><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/c/pysim/+/24160/2/pySim/commands.py">File pySim/commands.py:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/pysim/+/24160/2/pySim/commands.py@124">Patch Set #2, Line 124:</a> <code style="font-family:monospace,monospace"></code></p><p style="white-space: pre-wrap; word-wrap: break-word;">I think it would be a good idea to restore the cla_byte and sel_ctrl after the detection is done. The change should be a conscious decision by the API user.</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.osmocom.org/c/pysim/+/24160">change 24160</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/pysim/+/24160"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: pysim </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I224bd6c91cdaf444e2a94117f64030c024a776a7 </div>
<div style="display:none"> Gerrit-Change-Number: 24160 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Falkenber9 <robert.falkenberg@tu-dortmund.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-Comment-Date: Thu, 06 May 2021 10:11:34 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-Has-Labels: Yes </div>
<div style="display:none"> Gerrit-MessageType: comment </div>