-
Notifications
You must be signed in to change notification settings - Fork 306
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
PDU creates invalid messages when > allowed length #81
Comments
Hi! |
chunks calculation in divideTextUcs2 should be:
fullChunksCount = int((len(plainText) -1) / MAX_MULTIPART_MESSAGE_LENGTH[0x08])
From: tomchy [mailto:notifications@github.com]
Sent: March-07-17 2:04 PM
To: faucamp/python-gsmmodem <python-gsmmodem@noreply.github.com>
Cc: Matthews Brian BRMA <Brian.Matthews@vaisala.com>; Author <author@noreply.github.com>
Subject: Re: [faucamp/python-gsmmodem] PDU creates invalid messages when > allowed length (#81)
Hi!
could you test if this issue occurs inside following updated fork<https://github.com/babca/python-gsmmodem> ?
It has several updates and fixes, including long PDUs 🙂.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#81 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AYTpQ9ngp03HlSJfa0b7LWwRT2pvkHkcks5rjdQ_gaJpZM4MWDqh>.
|
Could you explain that/provide an example? Current implementation passes following unit tests (last test inside def test_encode_Ucs2_divideSMS(self):
""" Tests whether text will be devided into a correct number of chunks while using UCS-2 alphabet"""
text = "12345-010 12345-020 12345-030 12345-040 12345-050 12345-060"
self.assertEqual(len(gsmmodem.pdu.divideTextUcs2(text)), 1)
text = "12345-010 12345-020 12345-030 12345-040 12345-050 12345-060 1234567"
self.assertEqual(len(gsmmodem.pdu.divideTextUcs2(text)), 1)
text = "12345-010 12345-020 12345-030 12345-040 12345-050 12345-060 12345678"
self.assertEqual(len(gsmmodem.pdu.divideTextUcs2(text)), 2)
text = "12345-010 12345-020 12345-030 12345-040 12345-050 12345-060 123456["
self.assertEqual(len(gsmmodem.pdu.divideTextUcs2(text)), 1)
text = "12345-010 12345-020 12345-030 12345-040 12345-050 12345-060 1234567["
self.assertEqual(len(gsmmodem.pdu.divideTextUcs2(text)), 2)
text = "12345-010,12345-020,12345-030,12345-040,12345-050,12345-060,123456 12345-010,12345-020,12345-030,12345-040,12345-050,12345-060,1234567"
self.assertEqual(len(gsmmodem.pdu.divideTextUcs2(text)), 2) |
Hi,
I think it is OK as is.
if a ucs-2 buffer is exactly 134 bytes long, your calc results in 2 fullChunks and no remainder, whereas my pedantically correct way results in 1 fullChunk and 67 remainder.
Either way it works.
I will try your code tomorrow. It looks OK to me, as it handles the shortened buffer size it needs to once it is chunked.
Brian
From: tomchy [mailto:notifications@github.com]
Sent: March-07-17 4:23 PM
To: faucamp/python-gsmmodem <python-gsmmodem@noreply.github.com>
Cc: Matthews Brian BRMA <Brian.Matthews@vaisala.com>; Author <author@noreply.github.com>
Subject: Re: [faucamp/python-gsmmodem] PDU creates invalid messages when > allowed length (#81)
Could you explain that/provide an example?
Current implementation passes following unit tests (last test inside test_pdu.py):
def test_encode_Ucs2_divideSMS(self):
""" Tests whether text will be devided into a correct number of chunks while using UCS-2 alphabet"""
text = "12345-010 12345-020 12345-030 12345-040 12345-050 12345-060"
self.assertEqual(len(gsmmodem.pdu.divideTextUcs2(text)), 1)
text = "12345-010 12345-020 12345-030 12345-040 12345-050 12345-060 1234567"
self.assertEqual(len(gsmmodem.pdu.divideTextUcs2(text)), 1)
text = "12345-010 12345-020 12345-030 12345-040 12345-050 12345-060 12345678"
self.assertEqual(len(gsmmodem.pdu.divideTextUcs2(text)), 2)
text = "12345-010 12345-020 12345-030 12345-040 12345-050 12345-060 123456["
self.assertEqual(len(gsmmodem.pdu.divideTextUcs2(text)), 1)
text = "12345-010 12345-020 12345-030 12345-040 12345-050 12345-060 1234567["
self.assertEqual(len(gsmmodem.pdu.divideTextUcs2(text)), 2)
text = "12345-010,12345-020,12345-030,12345-040,12345-050,12345-060,123456 12345-010,12345-020,12345-030,12345-040,12345-050,12345-060,1234567"
self.assertEqual(len(gsmmodem.pdu.divideTextUcs2(text)), 2)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#81 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AYTpQ900A5D322NO7lsEdNZWI7Pnr-utks5rjfTXgaJpZM4MWDqh>.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The pdu.py splits long messages up depending on the type of string (GSM-7, UCS2,8-bit)
But the calculated lengths are wrong and cause modem errors.
attached is a fixed version that works with Multitech MTD-H5
pdu.py.txt
The text was updated successfully, but these errors were encountered: