Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I have a error: TypeError: decoding with 'gsm0338' codec failed (TypeError: an integer is required (got type NoneType)) #8

Open
bs111 opened this issue Oct 15, 2019 · 6 comments
Labels

Comments

@bs111
Copy link

bs111 commented Oct 15, 2019

I have a Modem Log from Phone. i Open it from Qcom tools.
when i get the hex data to translate it. it has an error.

setp:
1.the TP_user_data is : "6376783E07C500" from the Qcom tools.
2. I used the following :
C:\Users\borla>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import smsutil
hexcode="6376783E07C500"
gsmcode=bytes.fromhex(hexcode)
gsmcode
b'cvx>\x07\xc5\x00'
print(gsmcode.hex())
6376783e07c500
smsutil.decode(gsmcode)
Traceback (most recent call last):
File "D:\Python37\lib\site-packages\smsutil\codecs.py", line 61, in decode
return decode_gsm0338(input, decoding_map)
File "D:\Python37\lib\site-packages\smsutil\codecs.py", line 52, in decode_gsm0338
decoded += chr(d)
TypeError: an integer is required (got type NoneType)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "", line 1, in
File "D:\Python37\lib\site-packages\smsutil_init_.py", line 45, in decode
return bytestring.decode(encoding)
TypeError: decoding with 'gsm0338' codec failed (TypeError: an integer is required (got type NoneType))

expact result
"class 1" as the Qcom tools decode.

version:
C:\Users\borla>pip install -U smsutil
Looking in indexes: https://pypi.douban.com/simple
Requirement already up-to-date: smsutil in d:\python37\lib\site-packages (1.1.1)
Requirement already satisfied, skipping upgrade: future==0.16.0 in d:\python37\lib\site-packages (from smsutil) (0.16.0)
win10 pro 1903
python 3.7

modem information
1.the hex information:
[0x713A/009/001] OTA LOG 01:26:30.978 SMS/CP Data Direction : Network To MSLength: 42 0x10003b003b003a710008cedd4172bf00002a000000690127016f0891683110301405f0001a040ba15156813926f8001121801090625323076376783e07c500
2.the picture decode from QC tools:

@bs111
Copy link
Author

bs111 commented Oct 15, 2019

66733773-2a5f4280-ee93-11e9-8d5c-83e27dc05ccb

@jezeniel
Copy link
Owner

Thank you for this, i will check and fix this as soon as I am available.

@jezeniel
Copy link
Owner

I checked the issue, it seems that based on the right panel the right hex is 63 6c 61 73 73 20 31 which the library can decode, are you using other encodings?

@bs111
Copy link
Author

bs111 commented Nov 14, 2019

no ,Qcom tools says it was encoded by sm_tp_user_data_gsm7.
gsm7 bit.

@jezeniel
Copy link
Owner

jezeniel commented Dec 3, 2019

Apologies for this, this is indeed an issue of the library. Will find a way to fix this ASAP.

@jezeniel jezeniel added the bug label Dec 3, 2019
@jezeniel
Copy link
Owner

Currently just an update, the hex format above is packed to 8 bits, currently there are no methods to unpack it. Most SMSC doesn't even need the packed bytes as per https://github.com/twitter/cloudhopper-commons/blob/master/ch-commons-charset/src/main/java/com/cloudhopper/commons/charset/GSMBitPacker.java#L44

The default unpacked gsm7 encoding would work. But will definitely develop a util to pack and unpack gsm7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants