jtavares has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-remsim/+/30140 )
Change subject: bankd: edge detect RESET and VCC indications
......................................................................
bankd: edge detect RESET and VCC indications
- perform edge detection on RESET and VCC client indications to filter
out duplicate resets
- prior to this change, unrelated changes in the client slot status
indication (such as CLK change) could trigger duplicate resets
- these resets could happen in rapid succession and lead to reader
libusb communication errors that lock-up the PC/SC daemon
- a drop in VCC will always induce a cold reset, even if a warm
reset is already in progress.
- overall, this change better matches what the hardware would do
Change-Id: I36d30d176c0a03d97554112ca712d658d986c752
---
M src/bankd/bankd.h
M src/bankd/bankd_main.c
2 files changed, 28 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/40/30140/1
diff --git a/src/bankd/bankd.h b/src/bankd/bankd.h
index 0f94818..e340b5a 100644
--- a/src/bankd/bankd.h
+++ b/src/bankd/bankd.h
@@ -96,6 +96,12 @@
uint8_t atr[MAX_ATR_SIZE];
unsigned int atr_len;
} card;
+
+ /* last known state of the SIM card VCC indication */
+ bool last_vccPresent;
+
+ /* last known state of the SIM card reset indication */
+ bool last_resetActive;
};
/* bankd card reader driver operations */
diff --git a/src/bankd/bankd_main.c b/src/bankd/bankd_main.c
index b3b8dff..10334ff 100644
--- a/src/bankd/bankd_main.c
+++ b/src/bankd/bankd_main.c
@@ -115,6 +115,8 @@
worker->bankd = bankd;
worker->num = i;
worker->ops = &pcsc_driver_ops;
+ worker->last_vccPresent = true; /* allow cold reset should first indication be false */
+ worker->last_resetActive = false; /* allow warm reset should first indication be true */
/* in the initial state, the worker has no client.fd, bank_slot or pcsc handle yet */
@@ -774,10 +776,26 @@
sps->clkActive ? *sps->clkActive ? "ACTIVE" : "INACTIVE" : "NULL");
/* perform cold or warm reset */
- if (sps->vccPresent && *sps->vccPresent == 0)
- rc = worker->ops->reset_card(worker, true);
- else if (sps->resetActive)
- rc = worker->ops->reset_card(worker, false);
+ if (sps->vccPresent && *sps->vccPresent == 0) {
+ /* VCC is not present */
+
+ if (worker->last_vccPresent) {
+ /* falling edge detected on VCC; perform cold reset */
+ rc = worker->ops->reset_card(worker, true);
+ }
+ } else if (sps->resetActive) {
+ if (!worker->last_resetActive) {
+ /* VCC is present (or not reported) and rising edge detected on reset; perform warm reset */
+ rc = worker->ops->reset_card(worker, false);
+ }
+ }
+
+ /* update last known states */
+ if (sps->vccPresent) {
+ worker->last_vccPresent = *sps->vccPresent != 0;
+ }
+
+ worker->last_resetActive = sps->resetActive != 0;
return rc;
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/30140
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I36d30d176c0a03d97554112ca712d658d986c752
Gerrit-Change-Number: 30140
Gerrit-PatchSet: 1
Gerrit-Owner: jtavares <jtavares(a)kvh.com>
Gerrit-MessageType: newchange
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-remsim/+/30139 )
Change subject: bankd: Add GSMTAP functionality for SIM traffic
......................................................................
Patch Set 1:
(2 comments)
File src/bankd/bankd.h:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-963):
https://gerrit.osmocom.org/c/osmo-remsim/+/30139/comment/54695fd7_eea74fbc
PS1, Line 136: char* gsmtap_host;
"foo* bar" should be "foo *bar"
File src/bankd/gsmtap.h:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-963):
https://gerrit.osmocom.org/c/osmo-remsim/+/30139/comment/ed07d93c_5fb7ca55
PS1, Line 7: const uint8_t *sim_tpdu, unsigned int sim_tpdu_len);
adding a line without newline at end of file
--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/30139
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I05b599858d8758633aa56c3f12f258c27cf42d08
Gerrit-Change-Number: 30139
Gerrit-PatchSet: 1
Gerrit-Owner: jtavares <jtavares(a)kvh.com>
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Mon, 14 Nov 2022 05:15:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-remsim/+/30138 )
Change subject: rspro_client: implement re-establish delay
......................................................................
Patch Set 1:
(5 comments)
File src/rspro_client_fsm.c:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-962):
https://gerrit.osmocom.org/c/osmo-remsim/+/30138/comment/2fb56f24_41996682
PS1, Line 61: #define REESTABLISH_DELAY_COUNT sizeof(k_reestablish_delay_s)/sizeof(k_reestablish_delay_s[0])
Prefer ARRAY_SIZE(k_reestablish_delay_s)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-962):
https://gerrit.osmocom.org/c/osmo-remsim/+/30138/comment/4ee1174b_e3104353
PS1, Line 216: static int64_t get_monotonic_ms()
Bad function definition - int64_t get_monotonic_ms() should probably be int64_t get_monotonic_ms(void)
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-962):
https://gerrit.osmocom.org/c/osmo-remsim/+/30138/comment/2cac44b3_fe241958
PS1, Line 218: struct timespec t;
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-962):
https://gerrit.osmocom.org/c/osmo-remsim/+/30138/comment/ec1d3112_50da4864
PS1, Line 219: clock_gettime(CLOCK_BOOTTIME, &t);
please, no spaces at the start of a line
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-962):
https://gerrit.osmocom.org/c/osmo-remsim/+/30138/comment/04062233_daaf4329
PS1, Line 220: return ((1000LL * t.tv_sec) + (t.tv_nsec / 1000000));
please, no spaces at the start of a line
--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/30138
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I86cdc3ba37482e6577b429194d273a2399f32208
Gerrit-Change-Number: 30138
Gerrit-PatchSet: 1
Gerrit-Owner: jtavares <jtavares(a)kvh.com>
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Mon, 14 Nov 2022 04:44:31 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment