From eb18a3f06bd04ba2a280748cd5b6f8cee4e8a3a6 Mon Sep 17 00:00:00 2001 From: adrcs Date: Wed, 5 Feb 2025 20:24:56 -0700 Subject: [PATCH] Fixed length and zero payload bug --- code/IP400/Src/chat.c | 8 ++++++-- code/IP400/Src/frame.c | 24 ------------------------ 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/code/IP400/Src/chat.c b/code/IP400/Src/chat.c index 89af8c4..9bc6582 100644 --- a/code/IP400/Src/chat.c +++ b/code/IP400/Src/chat.c @@ -206,8 +206,12 @@ BOOL Chat_Task_exec(void) strncpy(dest_call, keyBuffer, cpyLen); destEnt = FALSE; } else { + if(keyPos != 0) { keyBuffer[keyPos++] = '\0'; sendLine(keyBuffer, keyPos); + } else { + USART_Print_string(">>>not sent\r\n"); + } } keyPos = 0; break; @@ -238,7 +242,7 @@ BOOL Chat_Task_exec(void) // send a line of text void sendLine(char *buffer, int len) { - SendTextFrame(setup_memory.params.setup_data.stnCall, TEXT_TYPE, dest_call, TEXT_TYPE, buffer, len, repeat); + SendTextFrame(setup_memory.params.setup_data.stnCall, TEXT_TYPE, dest_call, TEXT_TYPE, buffer, len, repeat); } /* @@ -280,7 +284,7 @@ void PrintFrame(IP400_FRAME *FrameBytes) USART_Print_string("[%d:%04d]:", FrameBytes->flagfld.flags.hop_count, FrameBytes->seqNum); // now dump the data - memcpy(printBuf, FrameBytes->buf, dataLen); + memcpy(printBuf, FrameBytes->buf, dataLen+3); printBuf[dataLen] = '\0'; USART_Print_string("%s\r\n", printBuf); diff --git a/code/IP400/Src/frame.c b/code/IP400/Src/frame.c index a8e96e7..a668944 100644 --- a/code/IP400/Src/frame.c +++ b/code/IP400/Src/frame.c @@ -242,16 +242,6 @@ void RepeatFrame(IP400_FRAME *frame) */ void QueueTxFrame(IP400_FRAME *txframe) { - /* - FRAME_QUEUE *f; - if((f = malloc(sizeof(FRAME_QUEUE))) == NULL) - return; - - // set the frame buffer and sequence number - f->frame = txframe; - - insque((QUEUE_ELEM *)f, (QUEUE_ELEM *)txQueue.q_back); - */ enqueFrame(&txQueue, txframe); } @@ -284,20 +274,6 @@ void Frame_Txtask_exec(void) // idle: waiting for work case TX_IDLE: - /* - // wait for a frame to send - if(txQueue.q_back == &txQueue) - return; - - // get a frane from the top of the queue - FRAME_QUEUE *f = txQueue.q_forw; - remque((struct qelem *)f); - - // this would be better as a union.. - int frameLen = f->length; - tFrame = f->frame; - */ - tFrame = dequeFrame(&txQueue); uint8_t *rawFrame = (uint8_t *)rawTxFrame;