Hello!
I have got STM32F429, CubeIDE and FreeRTOS
I use UART, Ethernet(netconn API), SDIO
I
#define configMINIMAL_STACK_SIZE (4096)
#define configTOTAL_HEAP_SIZE 65536
#define TCPIP_THREAD_STACKSIZE 4096
#define DEFAULT_THREAD_STACKSIZE 4096
#define TCP_MSS 4096
#define DEFAULT_TCP_RECVMBOX_SIZE 2048
#define INTERFACE_THREAD_STACK_SIZE (4096)
I use appropriate queues to each peripheral
I have got the following queue structure
typedef struct MesNode_
{
char* message;
size_t size;
} MesNode;
I have got the following buffers
#define BUFFER_SIZE 4096
#define Middle_BUFFER_SIZE 1024
char uartBuffer[BUFFER_SIZE];
char TCPBuffer[BUFFER_SIZE];
Im tryng to use queues with circular with the following circular buffer
MesNode make_msg_circ(const char* buffer, const char* begin, const char* end)
{
MesNode mNode;
mNode.size = (end > begin) ? end - begin: BUFFER_SIZE - (begin - end);
mNode.message = pvPortMalloc(msgNode.size + 1);
if (end > begin) {
memcpy(msgNode.message, begin, msgNode.size);
}
else {
size_t tailSize = buffer + BUFFER_SIZE - begin;
size_t headSize = end - buffer;
memcpy(msgNode.message, begin, tailSize);
memcpy(msgNode.message + tailSize, buffer, headSize);
}
mNode.message[msgNode.size] = '\0';
return mNode;
}
I applicate buffer in the following function of data processing. What function get last adress of pointer in buffer
typedef void (*process_fa)(MesNode* mNode);
char* data_process(osThreadId_t thread, char* beginBuffer)
{
DMA_HandleTypeDef* dmaRx;
char* uartBuffer;
process_fa process_func;
find_circ_fa find_func;
uint16_t dmaRxv;
if (thread == uartHandle) {
dmaRx = dmaRxPpm;
uartBuffer = uartPpmBuffer;
process_func = data_process_ppm;
find_func = find_circ_end_lsn;
}
else if (thread == TCPTxHandle) {
dmaRx = dmaRxPpm;
if(!tcpbuf)
{
uartBuffer = uartPpmBuffer;
process_func = data_process_ttcp;
find_func = find_circ_end_lsn;
}
else
{
uartBuffer = TCPBuffer;
dmaRxv = rx_size;
process_func = data_process_ftcp2;
find_func = find_circ_end_lsn;//find_circ_end_line;
}
}
else if (thread == TCPProcHandle) {
dmaRxv = lenc;//dmaTCP.length;
uartBuffer = TCPBuffer;
process_func = data_process_ftcp;
find_func = find_circ_end_line;
}
else {
return beginBuffer;
}
vPortEnterCritical();
size_t dmaRxSize;
if(tcpbuf)
dmaRxSize = BUFFER_SIZE - dmaRxv;
else
dmaRxSize = BUFFER_SIZE - dmaRx->Instance->NDTR;
char* endRxDmaBuffer = uartBuffer + dmaRxSize;
size_t lenRxData = (endRxDmaBuffer >= beginBuffer) ? endRxDmaBuffer - beginBuffer:
dmaRxSize + uartBuffer + BUFFER_SIZE - beginBuffer;
vPortExitCritical();
char* startPosition = beginBuffer;
char* endPosition;
char* startFind = beginBuffer;
size_t lenTail = lenRxData;
while (1) {
endPosition = find_func(uartBuffer, startFind, lenTail);
if (endPosition) {
MesNode mNode = make_msg_circ(uartBuffer, startPosition, endPosition);
lenTail -= mNode.size;
process_func(&mNode);
startPosition = endPosition;
startFind = endPosition;
continue;
}
break;
}
return startFind;
}
I suppose what portmalloc problem cause definition of mNode.size but still found the reason
Can anybody help to clarify this moment?
I operate the 1K data and tranfer it