Fixed bug in missing characters

This commit is contained in:
adrcs 2025-02-09 10:44:35 -07:00 committed by GitHub
parent a7b2b63790
commit 742a9bd1e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 38 additions and 40 deletions

View file

@ -212,7 +212,7 @@ void Beacon_Task_exec(void)
buf[pos++] = '\0'; // null terminated buf[pos++] = '\0'; // null terminated
// time to send a beacon frame.. // time to send a beacon frame..
SendBeaconFrame(setup_memory.params.setup_data.stnCall, bcnPayload, pos); SendBeaconFrame(setup_memory.params.setup_data.stnCall, bcnPayload, pos+1);
} }
/* /*

View file

@ -102,7 +102,7 @@ void Chat_Task_welcome(void)
* place a frame on the queue frame content is copied * place a frame on the queue frame content is copied
* to alloc'd memory * to alloc'd memory
*/ */
BOOL EnqueChatFrame(void *raw, int length) BOOL EnqueChatFrame(void *raw)
{ {
IP400_FRAME *qFrame, *SrcFrame = (IP400_FRAME *)raw; IP400_FRAME *qFrame, *SrcFrame = (IP400_FRAME *)raw;
uint8_t *frameBuffer; uint8_t *frameBuffer;
@ -284,7 +284,7 @@ void PrintFrame(IP400_FRAME *FrameBytes)
USART_Print_string("[%d:%04d]:", FrameBytes->flagfld.flags.hop_count, FrameBytes->seqNum); USART_Print_string("[%d:%04d]:", FrameBytes->flagfld.flags.hop_count, FrameBytes->seqNum);
// now dump the data // now dump the data
memcpy(printBuf, FrameBytes->buf, dataLen+3); memcpy(printBuf, FrameBytes->buf, dataLen);
printBuf[dataLen] = '\0'; printBuf[dataLen] = '\0';
USART_Print_string("%s\r\n", printBuf); USART_Print_string("%s\r\n", printBuf);

View file

@ -276,43 +276,44 @@ void Frame_Txtask_exec(void)
tFrame = dequeFrame(&txQueue); tFrame = dequeFrame(&txQueue);
uint8_t *rawFrame = (uint8_t *)rawTxFrame; uint8_t *rawFrame = (uint8_t *)rawTxFrame;
if(tFrame != NULL) { if(tFrame == NULL)
frameLen = tFrame->length; return;
/* frameLen = tFrame->length;
* Build the raw frame bytes: see IP400_FRAME struct
*/
// Source call + port (6 bytes)
memcpy(rawFrame, (uint8_t *)&tFrame->source, IP_400_CALL_SIZE);
rawFrame += IP_400_CALL_SIZE;
// Dest call + port (6 bytes)
memcpy(rawFrame, (uint8_t *)&tFrame->dest, IP_400_CALL_SIZE);
rawFrame += IP_400_CALL_SIZE;
// flag byte (2 byte)
memcpy(rawFrame, (uint8_t *)&tFrame->flagfld, IP_400_FLAG_SIZE);
rawFrame += IP_400_FLAG_SIZE;
// frame sequence number (4 bytes)
memcpy(rawFrame, (uint32_t *)&tFrame->seqNum, sizeof(uint32_t));
rawFrame += sizeof(uint32_t);
// frame length (2 bytes)
memcpy(rawFrame, (uint8_t *)&tFrame->length, sizeof(uint16_t));
rawFrame += IP_400_LEN_SIZE;
// and now the data... /*
if((tFrame->buf != NULL) && (tFrame->length != 0)) * Build the raw frame bytes: see IP400_FRAME struct
memcpy(rawFrame, tFrame->buf, tFrame->length); */
} // Source call + port (6 bytes)
memcpy(rawFrame, (uint8_t *)&tFrame->source, IP_400_CALL_SIZE);
rawFrame += IP_400_CALL_SIZE;
// Dest call + port (6 bytes)
memcpy(rawFrame, (uint8_t *)&tFrame->dest, IP_400_CALL_SIZE);
rawFrame += IP_400_CALL_SIZE;
// flag byte (2 byte)
memcpy(rawFrame, (uint8_t *)&tFrame->flagfld, IP_400_FLAG_SIZE);
rawFrame += IP_400_FLAG_SIZE;
// frame sequence number (4 bytes)
memcpy(rawFrame, (uint32_t *)&tFrame->seqNum, sizeof(uint32_t));
rawFrame += sizeof(uint32_t);
// frame length (2 bytes)
memcpy(rawFrame, (uint8_t *)&tFrame->length, sizeof(uint16_t));
rawFrame += IP_400_LEN_SIZE;
// and now the data...
if((tFrame->buf != NULL) && (tFrame->length != 0))
memcpy(rawFrame, tFrame->buf, tFrame->length);
// free the allocations in the reverse order... // free the allocations in the reverse order...
if(tFrame != NULL) { if(tFrame->buf != NULL)
if(tFrame->buf != NULL) free(tFrame->buf);
free(tFrame->buf);
free(tFrame); free(tFrame);
} else {
return; // nothing to send... // ensure packet length is a multiple of 4 bytes
} int pktLen = (rawFrame - rawTxFrame) + frameLen;
pktLen += (pktLen % 4);
int pktLen = rawFrame - rawTxFrame;
HAL_MRSubG_PktBasicSetPayloadLength(frameLen + pktLen); HAL_MRSubG_PktBasicSetPayloadLength(frameLen + pktLen);
// abort the current rx operation // abort the current rx operation
@ -408,9 +409,6 @@ void Frame_Rxtask_exec(void)
rFrame.buf = RxRaw; rFrame.buf = RxRaw;
// only interested in the 'to' port at this point...
uint32_t length = __HAL_MRSUBG_GET_DATABUFFER_SIZE();
// find a reason to reject a frame... // find a reason to reject a frame...
BOOL isMine, isUniqueFrame; BOOL isMine, isUniqueFrame;
isMine = FrameisMine(&rFrame); isMine = FrameisMine(&rFrame);
@ -428,13 +426,13 @@ void Frame_Rxtask_exec(void)
case ICMP_TYPE: case ICMP_TYPE:
Mesh_ProcessBeacon((void *)&rFrame, Stats.lastRSSI); Mesh_ProcessBeacon((void *)&rFrame, Stats.lastRSSI);
#if __DUMP_BEACON #if __DUMP_BEACON
EnqueChatFrame((void *)&rFrame, length+3); EnqueChatFrame((void *)&rFrame);
#endif #endif
Stats.nBeacons++; Stats.nBeacons++;
break; break;
case TEXT_TYPE: case TEXT_TYPE:
EnqueChatFrame((void *)&rFrame, length); EnqueChatFrame((void *)&rFrame);
Stats.framesOK++; Stats.framesOK++;
break; break;