[En-Nut-Discussion] Help ! UDP problem in NutOS 2.5.0

Avex avexwu at yahoo.com.tw
Tue Sep 17 05:40:59 CEST 2002


Hi all,


I got a problem using function 'NutUdpSendTo' in NutOS 2.5.0.
I wrote a test program like below:

//   ========= start ========
THREAD(NutMain, arg)
{
    UDPSOCKET* sock;
    NUTDEVICE *uart;
    u_long baud = 9600;

    // Register Realtek controller at address 8300 hex
    // and interrupt 5 and configure lan interface.

    NutRegisterDevice(&devUart0, 0, 0);
    uart = NutDeviceOpen("uart0");
    NutDeviceIOCtl(uart, UART_SETSPEED, &baud);

    NutPrintFormat(uart, "program started!");
    NutPrintFlush(uart);


    NutRegisterDevice(&devEth0, 0x8300, 5);
    NutNetAutoConfig("eth0");

    // Create a socket.
    sock = NutUdpCreateSocket(0);

    while(1)
    {
        // if not using this command
//        NutUdpSendTo(sock, inet_addr("255.255.255.255"), 1234, "test\r\n",
6);

        NutPrintFormat(uart, "Data sent!");
        NutPrintFlush(uart);

        NutSleep(5000);
    }

    NutUdpDestroySocket(sock);

}
//   ========= end ========

1>  if  NOT  using command NutUdpSendTo, uart can sent data correctly every
5 seconds.
[begin what I changed]
//        NutUdpSendTo(sock, inet_addr("255.255.255.255"), 1234, "test\r\n",
6);
        NutPrintFormat(uart, "Data sent!");
        NutPrintFlush(uart);
[end what I changed]

program started!

Data sent!
Data sent!
Data sent!
Data sent!
Data sent!
Data sent!
................
2>  if using command NutUdpSendTo, uart fails to send data out and I got 2
bytes '0x00'.
[begin what I changed]
        NutUdpSendTo(sock, inet_addr("255.255.255.255"), 1234, "test\r\n",
6);
//        NutPrintFormat(uart, "Data sent!");
//        NutPrintFlush(uart);
[end what I changed]
program started!
            // <-- 2 0x00 bytes
            // <-- 2 0x00 bytes
            // <-- 2 0x00 bytes
            // <-- 2 0x00 bytes
....................

after doing the testing , I knew NutUdpSendTo causes something wrong and
sent 2 bytes '0x00' data to uart.
It runs very well at NutOS 233, Did I do something wrong ?Anyone met the
same problem ?

Help !

Avex

-----------------------------------------------------------------
< ¨C¤Ñ³£ Yahoo!©_¼¯ >  www.yahoo.com.tw



More information about the En-Nut-Discussion mailing list