Skip to content

Commit

Permalink
support detect acks with busy + nack and show in monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
traxanos committed May 23, 2024
1 parent 2adac5e commit a645575
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
13 changes: 8 additions & 5 deletions src/knx/tp_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
#define TP_FRAME_FLAG_ECHO 0b00010000

// Means that the frame is processed by this device
#define TP_FRAME_FLAG_ADDRESSED 0b00000100
#define TP_FRAME_FLAG_ADDRESSED 0b00001000

// Means that the frame has been acked by this device.
#define TP_FRAME_FLAG_ACKING 0b00000010
// Means that the frame has been acked with BUSY
#define TP_FRAME_FLAG_ACK_BUSY 0b00000100

// Means that the frame has been acked by other (Busmontior)
#define TP_FRAME_FLAG_ACKED 0b00000001
// Means that the frame has been acked with NACK
#define TP_FRAME_FLAG_ACK_NACK 0b00000010

// Means that the frame has been acked
#define TP_FRAME_FLAG_ACK 0b00000001

class TpFrame
{
Expand Down
22 changes: 15 additions & 7 deletions src/knx/tpuart_data_link_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
// acknowledge services (device is transparent in bus monitor mode)
#define L_ACKN_IND 0x00
#define L_ACKN_MASK 0x33
#define L_ACKN_BUSY_MASK 0x0C
#define L_ACKN_NACK_MASK 0xC0
#define L_DATA_CON 0x0B
#define L_DATA_CON_MASK 0x7F
#define SUCCESS 0x80
Expand Down Expand Up @@ -139,11 +141,11 @@ void printFrame(TpFrame *tpframe)
print((tpframe->flags() & TP_FRAME_FLAG_INVALID) ? 'I' : '_'); // Invalid
print((tpframe->flags() & TP_FRAME_FLAG_EXTENDED) ? 'E' : '_'); // Extended
print((tpframe->flags() & TP_FRAME_FLAG_REPEATED) ? 'R' : '_'); // Repeat
print((tpframe->flags() & TP_FRAME_FLAG_ECHO) ? 'O' : '_'); // My own
print((tpframe->flags() & 0b00001000) ? 'x' : '_'); // Reserve
print((tpframe->flags() & TP_FRAME_FLAG_ADDRESSED) ? 'D' : '_'); // For me
print((tpframe->flags() & TP_FRAME_FLAG_ACKING) ? 'A' : '_'); // ACK recevied
print((tpframe->flags() & TP_FRAME_FLAG_ACKED) ? 'A' : '_'); // ACK sent
print((tpframe->flags() & TP_FRAME_FLAG_ECHO) ? 'T' : '_'); // Send by me
print((tpframe->flags() & TP_FRAME_FLAG_ADDRESSED) ? 'D' : '_'); // Recv for me
print((tpframe->flags() & TP_FRAME_FLAG_ACK_NACK) ? 'N' : '_'); // ACK + NACK
print((tpframe->flags() & TP_FRAME_FLAG_ACK_BUSY) ? 'B' : '_'); // ACK + BUSY
print((tpframe->flags() & TP_FRAME_FLAG_ACK) ? 'A' : '_'); // ACK
print("] ");
printHex("( ", tpframe->data(), tpframe->size(), false);
print(")");
Expand Down Expand Up @@ -295,7 +297,13 @@ void TpUartDataLinkLayer::processRxByte()
*/
if (_rxFrame->size() > 0)
{
_rxFrame->addFlags(TP_FRAME_FLAG_ACKED);
if (!(byte & L_ACKN_BUSY_MASK))
_rxFrame->addFlags(TP_FRAME_FLAG_ACK_BUSY);

if (!(byte & L_ACKN_NACK_MASK))
_rxFrame->addFlags(TP_FRAME_FLAG_ACK_NACK);

_rxFrame->addFlags(TP_FRAME_FLAG_ACK);
processRxFrameComplete();
}
// println("L_ACKN_IND");
Expand Down Expand Up @@ -414,7 +422,7 @@ void TpUartDataLinkLayer::processRxFrameByte(uint8_t byte)
if (_txState == TX_IDLE)
{
// Speichere das ein Acking erfolgen soll
_rxFrame->addFlags(TP_FRAME_FLAG_ACKING);
_rxFrame->addFlags(TP_FRAME_FLAG_ACK);

// und im TPUart damit dieser das ACK schicken kann
_platform.writeUart(U_ACK_REQ | U_ACK_REQ_ADRESSED);
Expand Down

0 comments on commit a645575

Please sign in to comment.