[En-Nut-Discussion] Problem with NutUdpReceiveFrom
Petr Halas
petr.halas at seznam.cz
Fri Jul 11 13:06:31 CEST 2003
Thanks to all for advices ...
I change code to:
-- snip ---------------------------------------------------
while((buf = NutHeapAlloc(DATA_BUF)) == 0) {
fprintf(uart0,"heap is full\n");
}
fprintf(uart0,"buf: 0x%04x\n", buf);
fprintf(uart0,"sizeof(buf): 0x%04x\n", DATA_BUF);
for(;;) {
if((len = NutUdpReceiveFrom(sock, &address, &port, buf,
DATA_BUF-1, 50000)) > 0) {
fprintf(uart0,"len: 0x%04x\n", len);
buf[len] = 0;
fprintf(uart0,"%s\n",buf);
}
NutThreadYield();
} // end for
--- snip --------------------------------------------------------
In OS version 3.2.1 not working (when arrive packet, not return from
NutUdpReceiveFrom and reboot)
In OS 3.0.1 working fine.
Thanks Petr
Petr Halas wrote:
> 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
>
>
More information about the En-Nut-Discussion
mailing list