|
From: | Mike Fleetwood |
Subject: | Re: [lwip-users] Problems with sending UDP packets in FreeRTOS |
Date: | Thu, 28 Jul 2016 11:47:50 +0100 |
User-agent: | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 |
Hi Sylvain, Thanks for your "useful" input. If you read what I posted, you will see that I didn't write the
code snippet included. It was a quick-and-dirty copy from some
demo code in a link that Noam posted. As I said elsewhere, my
code does check that each function completes successfully before
continuing. And, yes, I did spot that it uneccessarily (but
harmless) includes the terminating "null" on the end of the
string. If, by "low level netif driver" you mean the ethernet adaptor
interface driver - that was provided by ST, and is the latest
version they offer - I'm not aware of any reported problems with
it. Everything on top of that is LWIP. Mike. On 28/07/2016 11:16, Sylvain Rochet
wrote:
Hi Mike, On Thu, Jul 28, 2016 at 10:52:50AM +0100, Mike Fleetwood wrote:I tried one of Noam's linked examples (included below) - but that showed exactly the same problem, stopped sending after about 20 minutes (I couldn't tell if it was ERR_USE again, but no reason to think it was any different!).Well, given how much the snippet below is defective, I assume your whole software quality is between poor to critically wrong. Given that, the bug is probably in your low level netif driver.void udp_test2(void *arg) { struct netconn *conn; char msg[]="testing" ; struct netbuf *buf; char * data; conn = netconn_new( NETCONN_UDP );Woah, you REALLY HAVE TO check if netconn_new returns a non NULL conn.netconn_bind(conn, IP_ADDR_ANY, 1234 ); //local portYou also have to check if netconn_bind actually worked…netconn_connect(conn, IP_ADDR_BROADCAST, 1235 );You also have to check if netconn_connect actually worked…for( ;; ) { buf = netbuf_new();Woah, you REALLY HAVE TO check if netbuf_new returns a non NULL buf.data ="" sizeof(msg));Woah, you REALLY HAVE TO check if netbuf_alloc returns a non NULL data.memcpy (data, msg, sizeof (msg));You probably wanted to use sizeof(msg)-1 and not sizeof(msg) here, given you wanted to send a static string.netconn_send(conn, buf); netbuf_delete(buf); // De-allocate packet buffer osDelay(4); //some delay! } }Dear god. Sylvain -- FACE Systems Ltd The Old Boat House Cadgwith Cornwall TR12 7JX T:01326 291031 M:07831 401464 |
[Prev in Thread] | Current Thread | [Next in Thread] |