You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by vi...@apache.org on 2021/06/29 21:15:14 UTC
[mynewt-core] branch master updated: net/osdp: Ignore reply packets
from another PD
This is an automated email from the ASF dual-hosted git repository.
vipulrahane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 005eba2 net/osdp: Ignore reply packets from another PD
new 4919feb Merge pull request #2636 from vikrant-proxy/osdp-ignore-reply
005eba2 is described below
commit 005eba2c29e411473ba057f93c5531cb80d2205c
Author: Vikrant More <vi...@proxy.com>
AuthorDate: Sat Jun 26 13:24:59 2021 -0700
net/osdp: Ignore reply packets from another PD
If there is more data the 'skipped' packet than the entire packet itself, store this in rx_buf_len and adjust state based on it.
---
net/osdp/src/osdp_pd.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/net/osdp/src/osdp_pd.c b/net/osdp/src/osdp_pd.c
index dac9775..0eab223 100644
--- a/net/osdp/src/osdp_pd.c
+++ b/net/osdp/src/osdp_pd.c
@@ -52,6 +52,7 @@
#define OSDP_PD_ERR_GENERIC -1
#define OSDP_PD_ERR_REPLY -2
#define OSDP_PD_ERR_EMPTY_Q -3
+#define OSDP_PD_ERR_IGNORE -4
/* Implicit cababilities */
static struct osdp_pd_cap osdp_pd_cap[] = {
@@ -963,6 +964,9 @@ pd_receive_packet(struct osdp_pd *pd)
if (err == OSDP_ERR_PKT_FMT) {
return OSDP_PD_ERR_GENERIC;
}
+ if (err == OSDP_ERR_PKT_SKIP) {
+ err = OSDP_PD_ERR_IGNORE;
+ }
if (err == OSDP_ERR_PKT_NONE) {
pd->reply_id = 0; /* reset past reply ID so phy can send NAK */
pd->ephemeral_data[0] = 0; /* reset past NAK reason */
@@ -980,8 +984,12 @@ pd_receive_packet(struct osdp_pd *pd)
remaining = pd->rx_buf_len - len;
if (remaining) {
memmove(pd->rx_buf, pd->rx_buf + len, remaining);
- pd->rx_buf_len = remaining;
}
+ /**
+ * Store remaining length that needs to be processed.
+ * State machine will be updated accordingly.
+ */
+ pd->rx_buf_len = remaining;
return err;
}
@@ -1019,6 +1027,15 @@ osdp_update(struct osdp_pd *pd)
osdp_millis_since(pd->tstamp) < MYNEWT_VAL(OSDP_RESP_TOUT_MS)) {
break;
}
+ if (ret == OSDP_PD_ERR_IGNORE) {
+ /* Process command if non-empty */
+ if (pd->rx_buf_len > 0) {
+ pd->state = OSDP_PD_STATE_PROCESS_CMD;
+ } else {
+ pd->state = OSDP_PD_STATE_IDLE;
+ }
+ break;
+ }
if (ret != OSDP_PD_ERR_NONE && ret != OSDP_PD_ERR_REPLY) {
OSDP_LOG_ERROR("osdp: pd: CMD receive error/timeout - err:%d\n", ret);
pd->state = OSDP_PD_STATE_ERR;