To prevent missunderstandings when using enc_plmn(), specify the input
and return parameters as Hexstr.
Change-Id: I57cf8e2de357650aef2a06fbffc7615ccb2a45b4
Related: OS#4963
Previous implementation waits 300ms for response after
each command issued. But many commands finish earlier.
This patch improves the command execution time by frequently
checking for the response to complete (i.e. ends with
OK or ERROR), or the occurence of a timeout (default 200ms).
Timeout can be adapted per command to support long response
times of certain commands like AT+COPS=? (network search)
Execution time benchmark (20 AT commands/responses):
Previous: 6.010s (100.0%)
New code: 0.045s ( 0.7%)
Change-Id: I69b1cbc0a20d54791e5800bf27ebafc2c8606d93
Let's just use the scope limited TemporaryDirectory() instead, so
the temporary directory will be removed by Python automatically.
pySim/filesystem.py:679:16: E0602: Undefined variable 'shutil' (undefined-variable)
Change-Id: I4ea833fd79f4342c33899124379be509ba1e35ed
pySim/transport/__init__.py:86:15: E1101:
Instance of 'LinkBase' has no '_send_apdu_raw' member;
maybe 'send_apdu_raw'? (no-member)
Change-Id: I14fcdceca5d1e35491b6ad98f96b4276b69b2fc1
This method has been removed [1] in Python 3.0:
pySim/cards.py:581:14: E1101: Instance of 'dict' has no 'iteritems' member (no-member)
pySim/cards.py:591:24: E1101: Instance of 'dict' has no 'iteritems' member (no-member)
[1] https://wiki.python.org/moin/Python3.0#Built-In_Changes
Change-Id: Iba7ad9ed2a9b197ecedaaed1c6744fe1c721515a
Fixes the following pylint's warnings:
pySim/cards.py:494:18: E1101: Class '_MagicSimBase' has no '_files' member (no-member)
pySim/cards.py:509:6: E1101: Instance of '_MagicSimBase' has no '_files' member (no-member)
pySim/cards.py:529:26: E1101: Instance of '_MagicSimBase' has no '_files' member (no-member)
pySim/cards.py:537:5: E1101: Instance of '_MagicSimBase' has no '_ki_file' member (no-member)
pySim/cards.py:547:5: E1101: Instance of '_MagicSimBase' has no '_ki_file' member (no-member)
pySim/cards.py:548:8: E1101: Instance of '_MagicSimBase' has no '_ki_file' member (no-member)
pySim/cards.py:559:26: E1101: Instance of '_MagicSimBase' has no '_files' member (no-member)
pySim/cards.py:560:11: E1101: Instance of '_MagicSimBase' has no '_files' member (no-member)
pySim/cards.py:576:14: E1101: Instance of '_MagicSimBase' has no '_files' member (no-member)
Change-Id: I4db9d21258d6e04140962134c540e36631466322
pySim/card_key_provider.py:67:2: E1111:
Assigning result of a function call, where the function
has no return (assignment-from-no-return)
Change-Id: I43bab69f53300fbe837944735cd999fab5405d7a
Some modems may reject AT+CSIM if PDU contains lower
case hex digits [a-f]. Modem response is "ERROR"
without any error code.
This patch converts each PDU to upper case.
Tested with Sierra Wireless EM7565.
Example:
AT+CSIM=14,"00a40004023F00"
ERROR
AT+CSIM=14,"00A40004023F00"
+CSIM: 4,"612F"
OK
Change-Id: I318e36abc7ae975c62d32b7fe0ec949bf5997d13
The json input that is used with EF.MSISDN seems to be somewhat
ambigious. The original code accepts {"msisdn": "+4916012345678"}
only while the output is {"msisdn": [1, 1, "+4916012345678"]}. Lets
add a check and also accept the latter version.
Change-Id: I8f8dd68aac25d3fa3bc1aab06b855f8ec6640258
Related: OS#4963
* 'String' class renamed to 'PaddedString' in construct v2.9
* 'CommandSet' was introduced with with cmd2 v1.3.0
Change-Id: I170a9e896612086c4b0535cd6d950346897abc3b
I always assumed BER-TLV files are transparent EF with BER-TLV contents.
However, this is wrong. ETS TS 102 221 Section 8.2.2.4 specifies them.
TS 102 221 Section 11.3 describes the specific RETRIEVE DATA, SET DATA
commands, which are not yet implemented in pySim.
Change-Id: Ie4701d9f72b05c8a5810e287e55a20f6ea86a574
The encoding of EF.MSISDN is a bit unstrutured. The encoder function
does not return a valid result since it lacks the parameters
Capability/Configuration2 Record Identifier and Extension5 Record
Identifier, which are mandatory but can be set to 0xFF. Also the
encoder gets its input from pySim-shell, so it should have some
more input validation, especially when the user encodes an empty
string. The encoder and decoder function also do not have unit-tests.
Since the encoder now adds the missing two bytes by isself this does
not have to be done manually anymore, so cards.py needs to be
re-aligned.
For pySim-shell.py the encoder is used from ts_51_011.py. Unfortunately
it is used wrongly there. The optional Alpha Identifier is required
here as well.
Related: OS#4963
Change-Id: Iee5369b3e3ba7fa1155facc8fa824bc60e33b55b
Now that we have a shared argparse definition for all reader related
options in the transport module, use that.
Change-Id: I12ca1a484a5d6e84820d9761c9701f8a94381f66
Ideally that shared definition would be used by all programs,
rather than copy+pasting it. Unfortunately pySim-{read,prog}
are still using optparse and first need to be converted to
argparse.
Change-Id: If77f53850e1ca65f42cf1dca3e0f460dac1b0d1a
the helpstring of update_record_decoded mentions hex bytes for the data
parameter, but it should be mentioned as abstract json data like in
update_binary_decoded
Change-Id: Ibae2ab49054ac5dd6fcccddd28c98d886403dac9
Related: OS#4963
the export summary is printed after the log entry for the last file
without separation. This is confusing because it looks like if the
summary would refer to the last file only. Lets add a headline to make
clear that the last few lines are the "Export summary"
Change-Id: I90771e525b2b114bdb41a8e90d298ca991c09c3d
Related: OS#4963
The sysmo-usim-sja2 which is currently used for testing somewhat old. In
order to have a defined state here lets exchange it with a new card.
This will also ensure that we have a card with the most recent card
profile in the tester.
Change-Id: Ife13823d0b0a16b1f327dd882f91d0c95af65e43
Also serves as example for RFU (reserved for future use) fields
which should not always be reset to zero in case they have been
set on the uSIM for some reason.
See pySim/ts_51_011.py, class EF_AD.
* Add definitions for RFU {Flag, Bits, Byte, Bytes}
* Use IntEnum for OP_MODE (convenient auto completion)
* Remove obsolete definitions and imports
* Update test results for all SIMs (opmode strings are shortened)
Change-Id: I65e0a426f80a619fec38856a30e590f0e726b554
We're using argparse internally for all shell commands, and can
use that to auto-generate command reference in the manual.
Let's switch to argparse for the main program, too - and generate
the related reference in the manual.
Change-Id: I77c946dbeb9f746fe3d8051173e59462dc2fb5e2
This adds support for AUTHENTICATE to the USIM and ISIM application,
based on the newly-introduced 'construct' encoder/decoder support.
Change-Id: Id5697463e29c3dceff98bcf80f5400f7f2bcaa6c
'construct' is a declarative symmetric encoder/decoder for user
specified binary formats. It should come in extremely handy in
tools like pySim.
We start the integration by adding transport methods for transceiving
APDUs with built-in encoding of the command data and decoding of the
response data.
Change-Id: Ibf457aa8b9480a8db5979defcfafd67674303f6c
Use ``--opmode=OPMODE`` in cmdline mode or column ``OPMODE`` in csv mode
to specify OPMODE as listed below.
Details:
The ``EF_AD`` field contains administrative data (AD).
It consists of four bytes ``B1``, ``B2``, ``B3``, ``B4``,
and optionally further bytes for future use.
Previous implementation only sets the MNC field appropriately
(located in `B4`) and sets all other bits/bytes to 0.
However, `B1` also defines the *UE operation mode* (see below).
For type approval operations, such as testing with a test uSIM,
this value could be set to `0x80` rather than `0x00`(= normal operation).
This may unlock some UE capabilities that are restricted in
normal operation mode.
Excerpt from [ETSI TS 131 102, 4.2.18](https://www.etsi.org/deliver/etsi_ts/131100_131199/131102/04.15.00_60/ts_131102v041500p.pdf):
```
B1 - UE operation mode:
Coding:
Initial value
- '00' normal operation.
- '80' type approval operations.
- '01' normal operation + specific facilities.
- '81' type approval operations + specific facilities.
- '02' maintenance (off line).
- '04' cell test operation.
B2 - Additional information:
Coding:
Reserved for future use
B3 - Additional information:
Coding:
- B3.b1: OFM setting (Ciphering Indicator)
- B3.others: Reserved for future use
B4 - Length of MNC in the IMSI:
Coding:
- B4.b4..B4.b1: length: '0010' (= 2) or '0011' (=3)
- B4.others: Reserved for future use
```
**Legend:** Byte X, bit Y: BX.bY
Further reading: https://nickvsnetworking.com/usim-basics/
Change-Id: Ie9040c6b127c268878a0845ed73d0918ec6bbb08