WizziLab's serial protocol library
Dependents: modem_ref_helper_for_v5_3_217 modem_ref_helper
Diff: WizziCom.cpp
- Revision:
- 1:ca1c9bfb1cf4
- Parent:
- 0:95b73d0b37b7
- Child:
- 2:6a00ed67fe29
--- a/WizziCom.cpp Wed Apr 26 12:29:35 2017 +0000 +++ b/WizziCom.cpp Wed May 03 11:30:22 2017 +0000 @@ -177,12 +177,28 @@ KAL_COM_FLOW_FS_RESP }; +uint8_t wizzicom_type_to_flow(uint8_t packet_type) +{ + return g_type_to_flow[packet_type]; +} + +uint8_t wizzicom_flow_to_type(uint8_t flow_id) +{ + // Get packet type from flow_id + uint8_t packet_type = 0; + while ((g_type_to_flow[packet_type] != flow_id) && (packet_type < WIZZICOM_PKT_QTY)) + { + packet_type++; + } + return packet_type; +} + WizziCom::WizziCom(PinName tx, PinName rx, PinName irq_out, PinName irq_in) : _data_parsing(0), _irq_in_int(0), _rx_thread(osPriorityRealtime, 512, NULL), _tx_thread(osPriorityHigh, 512, NULL), -_callback_thread(osPriorityLow, 512, NULL) +_callback_thread(osPriorityLow, 1024, NULL) { _state = SEARCH_HEADER; _skipped_bytes = 0; @@ -268,10 +284,8 @@ msg.pbuf = packet->data; msg.plen = packet->length; msg.alen = 0; - + _post_msg(&msg); - - FREE(packet); } @@ -328,7 +342,7 @@ { COM_FPRINT("\r\n"); - COM_DPRINT("<-- (%02d) %d\r\n", _flow_to_type(tx_buf->buf[4]), (tx_buf->len - KAL_COM_HEADER_LEN)); + COM_DPRINT("<-- (%02d) %d\r\n", wizzicom_flow_to_type(tx_buf->buf[4]), (tx_buf->len - KAL_COM_HEADER_LEN)); if (_irq_out) { @@ -392,17 +406,6 @@ ASSERT(_tx_queue.put(_new_msg(msg)) == osOK, "WizziCom TX queue full!\r\n"); } -uint8_t WizziCom::_flow_to_type(uint8_t flow_id) -{ - // Get packet type from flow_id - uint8_t packet_type = 0; - while ((g_type_to_flow[packet_type] != flow_id) && (packet_type < WIZZICOM_PKT_QTY)) - { - packet_type++; - } - return packet_type; -} - void WizziCom::_new_pkt(WizziComPacket_t* packet) { //COM_COM_FPRINT("\r\n"); @@ -461,7 +464,7 @@ // Fill temp header _msg.blen = header[2]; seqnum = header[3]; - _msg.id = _flow_to_type(header[4]); + _msg.id = wizzicom_flow_to_type(header[4]); // Update seqnum WARNING(_rx_seq == seqnum, "COM Bad seqnum expected:%d got:%d\r\n", _rx_seq, seqnum);