[En-Nut-Discussion] Problem with NutUdpReceiveFrom

Ralph Mason ralph.mason at telogis.com
Thu Jul 10 22:14:37 CEST 2003


Does the HeapAlloc succeed?

sizeof(buf) will b 2 so you will never receive more than 2 bytes.

Ralph


> -----Original Message-----
> From: en-nut-discussion-admin at egnite.de
> [mailto:en-nut-discussion-admin at egnite.de]On Behalf Of Petr Halas
> Sent: Friday, 11 July 2003 7:51
> To: en-nut-discussion at egnite.de
> Subject: [En-Nut-Discussion] Problem with NutUdpReceiveFrom
> 
> 
> Hi,
> I have this code on Ethernut OS 3.2.1:
> 
> --- snip ----------------------------------------------
> THREAD(UDPsetup, arg)
> {
>      UDPSOCKET    *sock;
>      char         *buf;
>      int          len;
>      u_long       address;
>      u_short      port;
> 
>      NutSleep(2000);
>      sock = NutUdpCreateSocket(9999);
>      buf = NutHeapAlloc(512);
> 
>      for(;;) {
>          if((len = NutUdpReceiveFrom(sock, &address, &port, buf,
> sizeof(buf), 50000)) > 0) {
>              buf[len] = 0;
> 	    fprintf(uart0,"%s\n",buf);
>      	}
> 
>          NutThreadYield();
>      }
> 
>      NutHeapFree(buf);
> }
> 
> --- snip ----------------------------------------------
> 
> When any UDP packet arrive Ethernut OS do reboot.
> Can anybody help me with this problem?
> 
> Thanks Petr
> 
> 
> 
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo/en-nut-discussion
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.491 / Virus Database: 290 - Release Date: 18/06/2003
> 
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.491 / Virus Database: 290 - Release Date: 18/06/2003




More information about the En-Nut-Discussion mailing list