简体   繁体   English

freeRTOS +带线程/任务的LwIP的TCP问题

[英]TCP issues with freeRTOS + LwIP with threading/tasks

As above, having issues using FreeRTOS+LwIP on a Zedboard, with the board just crashing and needing a power reset. 如上所述,在Zedboard上使用FreeRTOS + LwIP时出现问题,该板只是崩溃了,需要重启电源。 I think it's to do with the network connections, I have two, one for incoming traffic and one for outgoing, both connect fine, however data seems a bit, odd. 我认为这与网络连接有关,我有两个,一个用于传入流量,一个用于传出,两者都可以正常连接,但是数据似乎有点奇怪。

Here's the function I'm using to receive data from the PC: 这是我用来从PC接收数据的功能:

while (ntotal < size)
{
    n = lwip_read(connection_descriptor, (buffer+ntotal), size - ntotal);
    if (n < 0)
    {
        printf("Failed receiving frame, received %i bytes\n", ntotal);
        return -1;
    }
    ntotal = ntotal + n;
}

And here's for the outgoing: 这是传出的:

int bytesSent = 0;
int bytesSentTotal = 0;
int lengthToSend = 0;
int lengthToSendTotal = 0;

lengthToSendTotal = Size;
lengthToSend = 1460;
printf("Processed frame about to be sent from obin%d\n", binNO);


while (bytesSentTotal + lengthToSend < lengthToSendTotal)
{
    //lengthToSend = lengthToSendTotal - bytesSentTotal;
    bytesSent = lwip_write(connection_descriptor, &(buffer[bytesSentTotal]), lengthToSend);
    if (bytesSent < 0)
    {
        printf("ERROR writing frame to socket\n");
        return -1;
    }
    else
    {
        bytesSentTotal += bytesSent;
        //printf("Data sent: %d\n", bytesSentTotal);
    }
}
lengthToSend = lengthToSendTotal - bytesSentTotal;
bytesSent = lwip_write(connection_descriptor, &(buffer[bytesSentTotal]), lengthToSend);

I tried changing it to send smaller amount of data per call as I wondered if trying to send a large amount at once was causing the issues (looking to send 900kb+ each time). 我尝试将其更改为每个呼叫发送少量数据,因为我想知道一次尝试发送大量数据是否会引起问题(希望每次发送900kb +)。 However the behaviour seems to be the same regardless, it will start fine, with data being received, then it will freeze, often partway through sending data back, until finally the client code on my PC will fail at the write command due to non responding network connection (or something similar). 但是,无论如何,行为似乎都是相同的,它会从接收数据开始就正常运行,然后会冻结,通常是在回传数据的途中,直到最后由于无响应,我的PC上的客户端代码将无法执行write命令网络连接(或类似的内容)。

So I'm just wondering if there's anything obvious I'm doing wrong? 所以我只是想知道我做错了什么吗?

What happens when it crashes? 当它崩溃时会发生什么? Where does the program end up (in an assert(), in an exception handler, etc.)? 程序在哪里结束(在assert()中,在异常处理程序中等)? Which version of FreeRTOS are you using - if it is a new-ish version then to you have configASSERT() defined, which could help highlight integration issues with FreeRTOS? 您正在使用哪个版本的FreeRTOS-如果它是新版本,那么您已经定义了configASSERT() ,这可以帮助您重点说明与FreeRTOS的集成问题?

Was your project based on the following reference? 您的项目是否基于以下参考? http://www.freertos.org/RTOS-Xilinx-Zynq.html - if not maybe looking at that code could provide a hint as to what the problem might be. http://www.freertos.org/RTOS-Xilinx-Zynq.html-如果不这样看,可能会提示您问题所在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM