Hello!
Maybe my question will be to the wrong address
I have got some problem with my tcp ip
All works fine but not too long
I send data from STM32 to PC every 1 sec and after 10 minuts it goes to
configASSERT( pxQueue->uxItemSize == 0 ); - stopping after 10 minuts of working via TCP transfer
and stack analyzer shows what Im runnning Ethf task which I didnt find in sources
My code is:
// init //
/* Definitions for networkInit */
osThreadId_t networkInitHandle;
const osThreadAttr_t networkInit_attributes = {
.name = "networkInit",
.stack_size = 256 * 8,//384 * 4,
.priority = (osPriority_t) osPriorityHigh,
};
/* Definitions for TCPProc */
osThreadId_t TCPProcHandle;
const osThreadAttr_t TCPProc_attributes = {
.name = "TCPProc",
.stack_size = 256 * 8,//384 * 10,//8,//4,
.priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for TCPTx */
osThreadId_t TCPTxHandle;
const osThreadAttr_t TCPTx_attributes = {
.name = "TCPTx",
.stack_size = 256 * 8,//384 * 12,//128 * 4,
.priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for TCPip */
osThreadId_t mtcpConHandle;
const osThreadAttr_t mtcpCon_attributes = {
.name = "mtcpCon",
.stack_size = 256 * 8, //384 * 4,
.priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for quTCP */
osMessageQueueId_t quTCPHandle;
const osMessageQueueAttr_t quTCP_attributes = {
.name = "quTCP"
};
void mstartTcpCon(void *argument);
void startNetworkInit(void *argument);
void startTCPProc(void *argument);
void startTCPTx(void *argument);
//osMessageQueueId_t qu = quMsgM3gHandle;
quTCPHandle = osMessageQueueNew (16, sizeof(MessageNode), &quTCP_attributes);
/* creation of networkInit */
networkInitHandle = osThreadNew(startNetworkInit, NULL, &networkInit_attributes);
/* creation of TCPip connection*/
mtcpConHandle = osThreadNew(mstartTcpCon, NULL, &mtcpCon_attributes);
//
// buffer for queues //
#define BUFFER_SIZE 11264
#define Middle_BUFFER_SIZE 1024
typedef struct MessageNode_
{
char* message;//
size_t size;
} MessageNode;
// threads //
void startNetworkInit(void *argument)
{
/* init code for LWIP */
MX_LWIP_Init();
/* USER CODE BEGIN 5 */
/* Infinite loop */
for(;;)
{
osDelay(1000);
}
/* USER CODE END 5 */
}
/* USER CODE BEGIN Header_startTcpConnet */
void mstartTcpCon(void *argument)
{
ip_addr_t server_ip;
ip_addr_t client_ip;
err_t err;
IP4_ADDR(&server_ip, 10, 10, 100, 100);
IP4_ADDR(&client_ip, 10, 10, 100, 99);
conn = netconn_new(NETCONN_TCP);
if (conn != NULL)
{
err = netconn_bind(conn, &client_ip, 6401);
if (err == ERR_OK)
{
while(netconn_connect(conn, &server_ip, 6401) != ERR_OK);
cont = 2;
tcpstatus = 0x01;
vTaskResume(TCPProcHandle);
}
}
vTaskDelete(NULL);
}
void startTCPProc(void *argument)
{
struct netbuf *buffer;
char *data;
for(;;)
{
if (cont == 2)
buffer = netbuf_new();
while ((netconn_err(conn) == ERR_OK) && (netconn_recv(conn, &buffer) == ERR_OK))
{
do
{
if(netbuf_data(buffer, (void *)&data, &lenc)== ERR_OK)
{
switch(tcpstatus){
case 0x01:
if(server_find_unnecessary_info((const char*)data, lenc)==servAuthOk)
{
tcpstatus = 0x02;
vTaskResume(TCPTxHandle);
lenc = 0;
//ppm_send_22();
//netconn_write(conn, Conted, sizeof(Conted), NETCONN_COPY);
vTaskResume(uartPpmProcHandle);///
}
break;
case 0x05:
if(server_auth_recv(ppm_id_get(),(const char* ) data)==servAuthOk)
{
tcpstatus = 0x06;
//netconn_write(conn, Subd, sizeof(Subd), NETCONN_COPY);
vTaskResume(TCPTxHandle);
lenc = 0;
///xTimerStart(tmrInitLTCHandle, portMAX_DELAY);
}
break;
case 0x07:
{
MessageNode msgNode;
msgNode.message = pvPortMalloc(lenc);
memcpy(msgNode.message, data, lenc);
msgNode.message[(size_t)lenc] = '\0';
msgNode.size = lenc -1;//strlen(masf);//msgNode.size = lenc;//
xQueueSendToBack(quMsgPpmHandle, &msgNode, portMAX_DELAY);
tcpstatus = 0x08;
msgNode.message = vPortFree;
vTaskResume(uartPpmTxHandle);
lenc = 0;
}
break;
default:
break;
}
}
}
while (netbuf_next(buffer) >= 0);
netbuf_delete(buffer);
}
}
osDelay(20);
}
}
void startTCPTx(void *argument)
{
static char Conted[] = "Ath OK\r\n";
static char Subd[] = "Sub OK\r\n";
osMessageQueueId_t qu = quTCPHandle;
for(;;)
{
MessageNode msgNode;
switch (tcpstatus)
{
case 0x02:
netconn_write(conn, Conted, sizeof(Conted), NETCONN_COPY);
tcpstatus = 0x03;
break;
case 0x04:
xQueueReceive(qu, &msgNode, portMAX_DELAY);
vPortEnterCritical();
netconn_write(conn, msgNode.message, msgNode.size, NETCONN_COPY);
msg_free(&msgNode);
vPortExitCritical();
tcpstatus = 0x05;
break;
case 0x06:
netconn_write(conn, Subd, sizeof(Subd), NETCONN_COPY);
tcpstatus = 0x07;
logstatus = 0x03;
break;
case 0x10:
while(uxQueueMessagesWaiting( qu )!= 0)
{
xQueueReceive(qu, &msgNode, portMAX_DELAY);
netconn_write(conn, msgNode.message, msgNode.size, NETCONN_COPY);
}
tcpstatus = 0x07;
logstatus = 0x03;
msg_free(&msgNode);
break;
default:
break;
}
vTaskSuspend(NULL);
osDelay(10);
}
}
I use STM32F429 lwip + freertos and use netconn API
Please help, who knows