JPM has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/38992?usp=email )
Change subject: Handling Long APDU response
......................................................................
Handling Long APDU response
Change-Id: I3c09d4dd1ed68bb982e23c90a6762fd9c2dfdd7f
---
M pySim/transport/modem_atcmd.py
1 file changed, 22 insertions(+), 13 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/92/38992/1
diff --git a/pySim/transport/modem_atcmd.py b/pySim/transport/modem_atcmd.py
index e7614c0..340ed92 100644
--- a/pySim/transport/modem_atcmd.py
+++ b/pySim/transport/modem_atcmd.py
@@ -86,6 +86,8 @@
if res == b'ERROR' or res.startswith(b'+CME ERROR:'):
log.error('Command failed with result: %s', res)
break
+ if lines[-1].startswith(b'+CSIM:'): # Sequans Monarch GM02S Long APDU response is OK and then all multiple +CSIM
+ t_start = time.time() # Reset the timer on each additional +CSIM received
if time.time() - t_start >= timeout:
log.info('Command finished with timeout >= %ss', timeout)
@@ -155,22 +157,29 @@
# Send AT+CSIM command to the modem
rsp = self.send_at_cmd(cmd)
- if rsp[-1].startswith(b'+CME ERROR:'):
- raise ProtocolError('AT+CSIM failed with: %s' % str(rsp))
- if len(rsp) != 2 or rsp[-1] != b'OK':
- raise ReaderError('APDU transfer failed: %s' % str(rsp))
- rsp = rsp[0] # Get rid of b'OK'
- # Make sure that the response has format: b'+CSIM: %d,\"%s\"'
- try:
- result = re.match(b'\+CSIM: (\d+),\"([0-9A-F]+)\"', rsp)
- (_rsp_tpdu_len, rsp_tpdu) = result.groups()
- except Exception as exc:
- raise ReaderError('Failed to parse response from modem: %s' % rsp) from exc
+ # AT+CSIM works with APDU, but returns the TPDU in multiple +CSIM answers (at least Sequans does it)
+ # In that case, the answer starts with OK, and then multiple +CSIM answers
+ rsp_apdu = b''
+ for r in rsp:
+ if r.startswith(b'+CSIM:'):
+ try:
+ result = re.match(b'\+CSIM: (\d+),\"([0-9A-F]+)\"', r)
+ (_rsp_tpdu_len, _rsp_tpdu) = result.groups()
+ rsp_apdu = rsp_apdu + _rsp_tpdu
+ except Exception as exc:
+ raise ReaderError('Failed to parse response from modem: %s' % rsp) from exc
+ elif r.startswith(b'CME ERROR:'):
+ raise ProtocolError('AT+CSIM failed with: %s' % str(rsp))
+ elif r == b'OK':
+ continue
+ else:
+ raise ReaderError('APDU transfer failed: %s' % str(rsp))
+
# TODO: make sure we have at least SW
- data = rsp_tpdu[:-4].decode().lower()
- sw = rsp_tpdu[-4:].decode().lower()
+ data = rsp_apdu[:-4].decode().lower()
+ sw = rsp_apdu[-4:].decode().lower()
log.debug('Command response: %s, %s', data, sw)
return data, sw
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/38992?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I3c09d4dd1ed68bb982e23c90a6762fd9c2dfdd7f
Gerrit-Change-Number: 38992
Gerrit-PatchSet: 1
Gerrit-Owner: JPM <jean-pierre.marcotte.1(a)ens.etsmtl.ca>
Attention is currently required from: daniel, jolly, laforge, pespin.
Hello Jenkins Builder, daniel, fixeria, jolly, laforge,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/libosmo-netif/+/38987?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review+1 by laforge, Verified+1 by Jenkins Builder
Change subject: stream_cli: Fix discard 1st msg received quick after connect
......................................................................
stream_cli: Fix discard 1st msg received quick after connect
Even if setting osmo_iofd_notify_connected(), it may happen that a read
call-back is triggered towards the user before this
special write-callback is triggered.
stream_cli was already accounting for that in stream_cli_iofd_read_cb()
state STREAM_CLI_STATE_CONNECTING, but was discarding the msgb instead
of pushing it upwards towards the user through read_cb after
transitioning to STREAM_CLI_STATE_CONNECTED.
As a result, eg when an ipaccess client using stream_cli (BTS, liboamo-abis
e1_line ipaccess driver) connected to an ipaccess server (BSC) and the
server quickly transmitted an IPA ID GET, it would get lost.
Related: libosmocore.git Change-Id Ica20a050b98d117995a5b625b23ab9faa61aabee
Change-Id: I98cd51d4bb87d3572245446648ced44a23a622ef
---
M src/stream_cli.c
1 file changed, 50 insertions(+), 31 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/87/38987/2
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/38987?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I98cd51d4bb87d3572245446648ced44a23a622ef
Gerrit-Change-Number: 38987
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: jolly <andreas(a)eversberg.eu>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>
Attention is currently required from: daniel, jolly, pespin.
fixeria has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/libosmo-netif/+/38987?usp=email )
Change subject: stream_cli: Fix discard 1st msg received quick after connect
......................................................................
Patch Set 1:
(1 comment)
File src/stream_cli.c:
https://gerrit.osmocom.org/c/libosmo-netif/+/38987/comment/7cb430ae_2579510… :
PS1, Line 615: LOGL_NOTICE
Are you sure it's worth logging this as NOTICE, maybe DEBUG?
Looks like a debugging leftover...
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/38987?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I98cd51d4bb87d3572245446648ced44a23a622ef
Gerrit-Change-Number: 38987
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: jolly <andreas(a)eversberg.eu>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>
Gerrit-Comment-Date: Sat, 30 Nov 2024 08:20:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No