From 1c53cf83cdaf08bb563c686b5dc862a1281489be Mon Sep 17 00:00:00 2001 From: Bernator Date: Tue, 6 Aug 2019 21:08:06 +0200 Subject: [PATCH 1/2] start confirm timout only after last byte was sent (#25) * bugfix, print not allowed in constructor * Update tpuart_data_link_layer.cpp - start confirm timout only after last byte was sent - increase BYTE_TIMEOUT --- src/knx/tpuart_data_link_layer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/knx/tpuart_data_link_layer.cpp b/src/knx/tpuart_data_link_layer.cpp index 9804701..13b688d 100644 --- a/src/knx/tpuart_data_link_layer.cpp +++ b/src/knx/tpuart_data_link_layer.cpp @@ -80,8 +80,8 @@ #define RX_WAIT_DATA_CON 3 #define TX_FRAME 4 -#define BYTE_TIMEOUT 3 //milli seconds -#define CONFIRM_TIMEOUT 500 //milli seconds +#define BYTE_TIMEOUT 10 //milli seconds +#define CONFIRM_TIMEOUT 500 //milli seconds #define RESET_TIMEOUT 100 //milli seconds void TpUartDataLinkLayer::loop() @@ -107,8 +107,6 @@ void TpUartDataLinkLayer::loop() if (!_waitConfirm && !isTxQueueEmpty()) { loadNextTxFrame(); - _waitConfirm = true; - _waitConfirmStartTime = _platform.millis(); _loopState = TX_FRAME; } } @@ -116,6 +114,8 @@ void TpUartDataLinkLayer::loop() case TX_FRAME: if (sendSingleFrameByte() == false) { + _waitConfirm = true; + _waitConfirmStartTime = _platform.millis(); _loopState = IDLE; } break; From 626d1b73d129c88c3e562849e96e079f6f8fb139 Mon Sep 17 00:00:00 2001 From: Bernator Date: Fri, 9 Aug 2019 17:34:43 +0200 Subject: [PATCH 2/2] bugfix nextAsap, translateAsap, Tx extended frame format (#26) * bugfix, print not allowed in constructor * Update tpuart_data_link_layer.cpp - start confirm timout only after last byte was sent - increase BYTE_TIMEOUT * bugfix nextAsap, translateAsap * bugfix Extended Frame Format TX --- src/knx/association_table_object.cpp | 22 +++++++++++++++------- src/knx/association_table_object.h | 5 +++-- src/knx/tpuart_data_link_layer.cpp | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/knx/association_table_object.cpp b/src/knx/association_table_object.cpp index 926cd9d..ce428ae 100644 --- a/src/knx/association_table_object.cpp +++ b/src/knx/association_table_object.cpp @@ -29,7 +29,7 @@ uint16_t AssociationTableObject::entryCount() return ntohs(_tableData[0]); } -uint16_t AssociationTableObject::operator[](uint16_t idx) +uint16_t AssociationTableObject::getTSAP(uint16_t idx) { if (idx < 0 || idx >= entryCount()) return 0; @@ -37,6 +37,14 @@ uint16_t AssociationTableObject::operator[](uint16_t idx) return ntohs(_tableData[2 * idx + 1]); } +uint16_t AssociationTableObject::getASAP(uint16_t idx) +{ + if (idx < 0 || idx >= entryCount()) + return 0; + + return ntohs(_tableData[2 * idx + 2]); +} + uint8_t* AssociationTableObject::save(uint8_t* buffer) { return TableObject::save(buffer); @@ -53,10 +61,10 @@ uint8_t* AssociationTableObject::restore(uint8_t* buffer) int32_t AssociationTableObject::translateAsap(uint16_t asap) { uint16_t entries = entryCount(); - for (uint16_t i = 0; i < entries * 2; i+=2) + for (uint16_t i = 0; i < entries; i++) { - if (operator[](i + 1) == asap) - return operator[](i); + if (getASAP(i) == asap) + return getTSAP(i); } return -1; } @@ -97,11 +105,11 @@ int32_t AssociationTableObject::nextAsap(uint16_t tsap, uint16_t& startIdx) uint16_t entries = entryCount(); for (uint16_t i = startIdx; i < entries; i++) { - startIdx = i; + startIdx = i+1; - if (operator[](i) == tsap) + if (getTSAP(i) == tsap) { - return operator[](i+1); + return getASAP(i); } } return -1; diff --git a/src/knx/association_table_object.h b/src/knx/association_table_object.h index 7b943ce..b56587c 100644 --- a/src/knx/association_table_object.h +++ b/src/knx/association_table_object.h @@ -21,6 +21,7 @@ class AssociationTableObject : public TableObject private: uint16_t entryCount(); - uint16_t operator[](uint16_t idx); + uint16_t getTSAP(uint16_t idx); + uint16_t getASAP(uint16_t idx); uint16_t* _tableData = 0; -}; \ No newline at end of file +}; diff --git a/src/knx/tpuart_data_link_layer.cpp b/src/knx/tpuart_data_link_layer.cpp index 13b688d..12b45fe 100644 --- a/src/knx/tpuart_data_link_layer.cpp +++ b/src/knx/tpuart_data_link_layer.cpp @@ -235,7 +235,7 @@ void TpUartDataLinkLayer::loop() //Destination Address + payload available _xorSum ^= rxByte; //check if echo - if (!((buffer[0] ^ _sendBuffer[0]) & ~0x20) && !memcmp(buffer + 2, _sendBuffer + 1, 5)) + if (!((buffer[0] ^ _sendBuffer[0]) & ~0x20) && !memcmp(buffer + _convert + 1, _sendBuffer + 1, 5)) { //ignore repeated bit of control byte _isEcho = true; }