This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/PROCESSOR-SDK-AM335X: BSD socket errors

Part Number: PROCESSOR-SDK-AM335X
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hello,

I am having a problem when trying to use the BSD sockets.     Attached is a small test program  (test.c) that demonstrates what I am seeing.    The problem is that I get CONFLICTING TYPE errors for IP6N and for select.     

I have set an include path in my project to the NDK BSD directory.     The INCLUDE PATHS FOR THE PROJECT:

The COMPILER OUTPUT:

and the test.c program:

 

/*
 * test.c
 *
 *  Created on: Feb 21, 2018
 *      Author: MSTEINMETZ_LA
 */


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdbool.h>
#include <xdc/std.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/knl/Mailbox.h>
#include <xdc/cfg/global.h>

#include <ti/ndk/inc/usertype.h>   // need this for osif.h ????   HANDLE,


#include <sys/socket.h>         // include for BSD sockets

#include <ti/ndk/inc/os/osif.h>
#include "assert.h"


int BSD_test(void)  {

    int SocketHandle;

    int rslt;
    int rtn_addrlen;
    struct sockaddr_in addr;
    int sockAddrSize;
    int msglen;
    struct sockaddr from;
    unsigned char buf[1024];


    /* create the socket -- for UDP messaging */
    SocketHandle = socket(AF_INET,SOCK_DGRAM,0);

    if (-1 == SocketHandle)
    {
         /* could not create socket...report problem and then kill task */

        xdc_runtime_System_printf("SOCKET CREATE FAIL\n");
        xdc_runtime_System_flush();

    }
        /* next bind the socket to an IP address and Port */

    sockAddrSize = sizeof(struct sockaddr_in);
    memset( (char *) &addr, 0, sockAddrSize);
    addr.sin_family=AF_INET;
    addr.sin_port = htons(123);
    addr.sin_addr.s_addr = htonl(INADDR_ANY);   /* should this be any or the local IP???*/

    rslt = bind (SocketHandle, (struct sockaddr *) &addr, sockAddrSize);

    if (-1 == rslt)
    {
        /* could not bind port...report problem and then kill task */
        //Fatal_error("UDP ADDR Binding ERROR");
        //taskDelete(taskIdSelf());
        xdc_runtime_System_printf("SOCKET BIND FAIL\n");
        xdc_runtime_System_flush();

    }


    /* next, park on the socket waiting for a PEER PRIM UDP */


    rtn_addrlen = sizeof(struct sockaddr_in);

    msglen = recvfrom(SocketHandle, buf, 1024, 0,  &from, &rtn_addrlen);

    return msglen;

}

If I remove the usertype.h include,  then the missing typedef's generate errors in the osif.h file.

I am unsure what includes I need to resolve the CONFLICTING TYPE errors and also satisfies the necessary typedef's for the osif.h.

Any help you can provide would be greatly appreciated.     Note that I did search the forum and found another thread about CONFLICTING TYPES,  but it seemed that there was no clear answer and the person just hacked things to make it work.   I am hoping there is a cleaner answer.

thanks,

Mark

  • The RTOS team have been notified. They will respond here.
  • Hi Mark,

    It looks like you have followed the steps in section "3.4.1 Using the BSD Sockets Compatibility Layer" of NDK API reference guide.

    For 'IP6N' conflict, it should be resolved if you comment out the followings:

    #include <ti/ndk/inc/usertype.h>

    #include <ti/ndk/inc/os/osif.h>

    in your bsd_test.c.

    And add the include path '"C:\ti\ndk_2_26_00_08\packages\ti\ndk\inc\bsd"' for the bsd_test.c file only.

    The 'select' conflict seems to be introduced in the sys/select.h from GCC v6.3.1.  With the '__INSIDE_CYGWIN_NET__' symbol defined in the bsd_test.c, the select() function from the GCC sys/select.h can be disabled. There maybe other options to resolve the 'select' conflict.

    #if !defined (__INSIDE_CYGWIN_NET__)

    __BEGIN_DECLS

    int select __P ((int __n, fd_set *__readfds, fd_set *__writefds,

    fd_set *__exceptfds, struct timeval *__timeout));

    #if __POSIX_VISIBLE >= 200112

    int pselect __P ((int __n, fd_set *__readfds, fd_set *__writefds,

     fd_set *__exceptfds, const struct timespec *__timeout,

     const sigset_t *__set));

    #endif

    __END_DECLS

    #endif /* !__INSIDE_CYGWIN_NET__ */

    Regards,

    Garrett

  • Thanks Garrett,   did as you suggested and that resolved things.

    Mark