Bug #5830
openpySim-prog.py --mnclen=3 buggy / broken
90%
Description
trying to reprogramm a few sja2 i run into --mnclen not working at all for me.
when trying to use it was adamant that "--mnclen=2" is not a valid option and i should select 2 or 3.... something is buggy here.
then i patched the default from 2 to 3 to use the code and it tried writing a 2 digit mnc.
was this feature tested in batch mode?
my command line looked similar to this:
./pySim-prog.py --mnclen=3 --read-iccid --read-csv=simcards_adm.csv -S csv -p 0 --batch --dry-run
after patching mnclen to default to 3 i tried
./pySim-prog.py --mnc=900 --read-iccid --read-csv=simcards_adm.csv -S csv -p 0 --batch --dry-run
but this also prints out 2 digit mnc in the generated output.
Updated by roh about 1 month ago
- Subject changed from pySim-prog.py to pySim-prog.py --mnclen=3 buggy / broken
Updated by laforge about 1 month ago
- Assignee set to dexter
- Priority changed from Normal to Urgent
Updated by dexter about 1 month ago
As far as I can see right now multiple things seem to be broken.
What I need would be the following:
- A commandline (I assume the above are exactly what you have tried)
- A CSV file sample (I think 3 records are enough) to test it. You do not have to do any modifications, I will then just copy+paste the data from my test card)
(In general log output from your system would be very helpful but since you showed my what goes wrong on your machine I know what output I should expect.)
Updated by dexter about 1 month ago
- Status changed from New to Resolved
- % Done changed from 0 to 90
I have fixed the problem now. The --mnclen parameter can now be used again, since our CSV files do not have an mnclen fields the --mnclen parameter also works in CSV mode now. I also checked the dry run and cleaned up the code there a bit but thats not mandatory to get the problem fixed.
https://gerrit.osmocom.org/c/pysim/+/30632
https://gerrit.osmocom.org/c/pysim/+/30634
Updated by dexter about 1 month ago
- Status changed from Resolved to In Progress
The current status can be found on pySim branch: pmaier/mnclen
Updated by roh 15 days ago
thanks for fixing this.
i got a little odd warning from python on debian11:
/home/osmocom/test/pysim/./pySim-prog.py:602: SyntaxWarning: "is" with a literal. Did you mean "=="? if opts.mnclen is "2": /home/osmocom/test/pysim/./pySim-prog.py:604: SyntaxWarning: "is" with a literal. Did you mean "=="? elif opts.mnclen is "3":
not sure if this is the correct fix, but it seems to work:
diff --git a/pySim-prog.py b/pySim-prog.py index b3919ee..448f2a0 100755 --- a/pySim-prog.py +++ b/pySim-prog.py @@ -599,9 +599,9 @@ def read_params_csv(opts, imsi=None, iccid=None): # commandline options we can use that info, otherwise we guess that # the length is 2, which is also the most common case. if opts.mnclen != "auto": - if opts.mnclen is "2": + if opts.mnclen == "2": row['mnc'] = row.get('mnc', mnc_from_imsi(row.get('imsi'), False)) - elif opts.mnclen is "3": + elif opts.mnclen == "3": row['mnc'] = row.get('mnc', mnc_from_imsi(row.get('imsi'), True)) else: raise ValueError("invalid parameter --mnclen, must be 2 or 3 or auto")
provisioning seems to work fine.
Updated by roh 13 days ago
- Status changed from Resolved to In Progress
this seems not fixed completely yet.
i have tried and the sim still has:
MF/ADF.USIM/EF.AD still features a "mnc_len": 2 when read via pysimshell after programming a 3 digit mnc
the phone can register when forced but it assumes it is roaming.
Updated by dexter 10 days ago
I think I found the reason why it still works on my machine. The cards I am using are programmed with a different profile. Apparently the EF.AD in ADF.USIM is now an individual file and not a link to the EF.AD in DF.GSM. I am actually surprised that this is the case. A solution could be to select both files and program them both with the same content.
Updated by dexter 10 days ago
I have now fixed the problem. EF.AD is now also programmed under ADF.USIM:
https://gerrit.osmocom.org/c/pysim/+/31004 cards: also program EF.AD under ADF.USIM [NEW]
I still wonder why EF.AD is no longer linked to a single file. pySim-prog.py relies on the assumption that when the files in DF.GSM are written that then the corresponding files in ADF.USIM are updated as well. There are a few other files where it works the same way. I wonder if those need attention now. I could check it with an experiment, but then I need one of those new cards I can freely experiment with.
Here is a list of the potentially affected files:
EF.IMSI (seems to be ok)
EF.PLMNsel
EF.PLMNwAcT
EF.OPLMNwAcT
EF.HPLMNwAcT
EF.SMSP
Updated by dexter 8 days ago
roh thanks for trying it out.
sysmo-isim-tool_sja2 had the same problem. I have fixed that now as well. I am a bit unsure if we should program all linked files in all locations. Is there any opinion about that? Are we expecting spec changes that require us to unlink files all too soon?
Updated by laforge 8 days ago
On Thu, Jan 19, 2023 at 11:33:30AM +0000, dexter wrote:
sysmo-isim-tool_sja2 had the same problem. I have fixed that now as well. I am a bit unsure if we should program all linked files in all locations. Is there any opinion about that? Are we expecting spec changes that require us to unlink files all too soon?
you could always check the FCP if they are linked or not. That's probably the best approach as it will always work, no matter of the detailed card profile.