add normalizer reset from etcp connection reset
This commit is contained in:
1 parent
b3c9ad5a01
commit
388fa6a1e1
4 files changed
+35
-223073
No files matched your search
@@ -248,6 +248,7 @@ void etcp_connection_close(struct ETCP_CONN* etcp) {
|
||||
void etcp_conn_reset(struct ETCP_CONN* etcp) {
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "");
|
||||
// Reset IDs
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Resetting ETCP instance [%d]", etcp->log_name);
|
||||
etcp->next_tx_id = 1;
|
||||
etcp->last_rx_id = 0;
|
||||
etcp->last_delivered_id = 0;
|
||||
@@ -275,6 +276,12 @@ void etcp_conn_reset(struct ETCP_CONN* etcp) {
|
||||
// Reset timers (just clear the pointers - timers will expire naturally)
|
||||
etcp->retrans_timer = NULL;
|
||||
etcp->ack_resp_timer = NULL;
|
||||
|
||||
// Reset normalizer (packer/unpacker state for reconnection)
|
||||
if (etcp->normalizer) {
|
||||
pn_reset(etcp->normalizer);
|
||||
}
|
||||
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "end");
|
||||
}
|
||||
|
||||
|
||||
@@ -132,6 +132,30 @@ void pn_unpacker_reset_state(struct PKTNORM* pn) {
|
||||
}
|
||||
}
|
||||
|
||||
// Reset packer and unpacker state (for reconnection)
|
||||
void pn_reset(struct PKTNORM* pn) {
|
||||
if (!pn) return;
|
||||
|
||||
// Cancel flush timer
|
||||
if (pn->flush_timer) {
|
||||
uasync_cancel_timeout(pn->ua, pn->flush_timer);
|
||||
pn->flush_timer = NULL;
|
||||
}
|
||||
|
||||
// Reset packer state
|
||||
if (pn->data) {
|
||||
memory_pool_free(pn->etcp->instance->data_pool, pn->data);
|
||||
pn->data = NULL;
|
||||
}
|
||||
pn->data_ptr = 0;
|
||||
pn->data_size = 0;
|
||||
pn->pending = NULL;
|
||||
pn->pending_in_ptr = 0;
|
||||
|
||||
// Reset unpacker state
|
||||
pn_unpacker_reset_state(pn);
|
||||
}
|
||||
|
||||
// Send data to packer (copies and adds to input queue or pending, triggering callback)
|
||||
void pn_packer_send(struct PKTNORM* pn, uint8_t* data, uint16_t len) {
|
||||
if (!pn || !data || len == 0) return;
|
||||
|
||||
@@ -51,7 +51,10 @@ struct PKTNORM* pn_init(struct ETCP_CONN* etcp);// все что нужно (в
|
||||
// Деинициализация пары
|
||||
void pn_deinit(struct PKTNORM* pn);
|
||||
|
||||
// Сброс состояния (для unpacker)
|
||||
// Сброс состояния (для переподключения)
|
||||
void pn_reset(struct PKTNORM* pn);
|
||||
|
||||
// Сброс состояния unpacker (для unpacker)
|
||||
void pn_unpacker_reset_state(struct PKTNORM* pn);
|
||||
|
||||
// создаёт malloc data, копирует, помещает в input.
|
||||
|
||||
Reference in new issue
Block a user