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.

  • Resolved

Properly connection parameters (TMDSEVM6670L ethernet). Custom socket project

Expert 1730 points

Replies: 28

Views: 2822

Hello again.

Still the same board (TMDSEVM6670L), still the same problems. 

I want to send from the PC (client) the string array to the board (server) and send back the string array, which is declared on board. I use this code on PC (client):

SOCKET mysocket;
  if (INVALID_SOCKET == (mysocket = socket (AF_INET, SOCK_STREAM, 0) ) )
   {
      // Error...
      error = WSAGetLastError();
      // ... 
   }
  sockaddr_in mysocket_addr;
  ZeroMemory (&mysocket_addr, sizeof (mysocket_addr));
  mysocket_addr.sin_family = AF_INET;
   
   mysocket_addr.sin_addr.S_un.S_addr = inet_addr ("192.168.1.200"); 
   mysocket_addr.sin_port = htons (1234);

   if (SOCKET_ERROR == ( connect (mysocket, (sockaddr *) &mysocket_addr, sizeof (mysocket_addr) ) ) )
   {
      // Error...
      error = WSAGetLastError();
      // ... 
   }
   
   if (SOCKET_ERROR == ( send (mysocket, sHELLO, sizeof(sHELLO), 0 ) ) )
   {
      // Error...
      error = WSAGetLastError();
      // ... 
   }
   
     if (SOCKET_ERROR == ( recv (mysocket, (char* ) & buff, sizeof(*buff), 0 ) ) )
   {
      // Error...
      error = WSAGetLastError();
      // ... 
   }
   closesocket(mysocket);

And this code on server (board):

 SOCKET s; 
        SOCKET client_socket;    
        struct sockaddr_in server_addr;
        server_addr.sin_family = AF_INET;
        server_addr.sin_port = htons(1234);
        server_addr.sin_addr.s_addr = inet_addr("192.168.1.200");
        s = socket (AF_INET, SOCK_STREAM, 0);

        bind(s, (struct sockaddr*)& server_addr, sizeof(server_addr));

        struct sockaddr_in client_addr;


        client_addr.sin_addr.s_addr = inet_addr("192.168.1.1");
        int client_addr_size=sizeof(client_addr);
        client_socket=accept(s, (struct sockaddr *)&client_addr, &client_addr_size);

        //connect - bind - accept - send - recieve

       
        listen(s, 0x100);
       for (;;)
        {
         recv(client_socket,&buff[0],sizeof(buff),0);
         send(client_socket,message,sizeof(message),0);
        }


Still i'm thinking that i've done everything completely wrong, so i;m really asking for help. And also, can i use not the "7" port for the connection, because it's using only for testing?

And also... I must use "sendto" and "recvfrom", or simple "send" and "recieve" would be enough?

  • Hi,
    Which example are you using ?
    hello world or client ?
    Can you please refer to the following post.

    e2e.ti.com/.../1397057

     

    Regards,

    Titus S.

    Please use the latest processor SDK package for your platform (K2H,K2E,C665x,C667x etc.,)

    http://www.ti.com/lsds/ti/tools-software/processor_sw.page

  • In reply to Titusrathinaraj Stalin:

    Hello Titus. I'm using client example.
  • In reply to Titusrathinaraj Stalin:

    Hello again.

    I've followed the thread and got some problems. Debug stops at the 

    rSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP );
                if( rSocket == INVALID_SOCKET )
                	printf("FATAL ERROR! SOCKET IS NOT CREATED \n");


    And returns this in the console:

    00000.000 llEnter: Illegal priority call to llEnter()
    00000.000 llExit: Illegal call to llExit()

    What's wrong with this thing? If i'm using only recieve section, it's working, but when i add send section, this error appears. Is that a memory configuration issue or i've just mistaked in the socket creation code?

  • In reply to Taras Kolesko:

    BTW: you've refered me once to the MCSDK "Helloworld" example. But neither there nor there i've not found the socket creation mechanism. Certain projects Daemon-functions are using sockets, but there are no functions of initiating socket. I'm really confused about how i can combine simple project and the 

     thread project.

    And the last question. Which port is good for the transmission? I've tryed many and the board says me, that all of them are unreachable.

  • In reply to Taras Kolesko:

    Hi Taras,

    I have used "hello world" NDK example code which receive the UDP packets and send back to the same IP address.

    So, you can use the function "dtask_udp_hello" from "udpHello.c" then create socket to do that....

    You can also change the port no as your wish.

    Here, 7 is the port no...

    Ex:

    static void NetworkOpen()

    {

       // Create our local server

       hHello = DaemonNew( SOCK_DGRAM, 0, 7, dtask_udp_hello,

                          OS_TASKPRINORM, OS_TASKSTKNORM, 0, 1 );

    }

     

    I have used packet sender to send UDP packets from PC (10.100.1.94) to C6678 EVM board (10.100.1.17) and able to get the same packet to my PC (echoed back).

    I hope, that's what you need right ?

    I have used the following code from C6678 hello world example.

    int dtask_udp_hello( SOCKET s, UINT32 unused )
    {
        struct sockaddr_in sin1;
        struct timeval     to;
        int                i,tmp;
        char               *pBuf;
        HANDLE             hBuffer;
    
        printf("########### UDP HELLO EXE ########### \n");
    
        (void)unused;
    
        // Configure our socket timeout to be 3 seconds
        to.tv_sec  = 3;
        to.tv_usec = 0;
        setsockopt( s, SOL_SOCKET, SO_SNDTIMEO, &to, sizeof( to ) );
        setsockopt( s, SOL_SOCKET, SO_RCVTIMEO, &to, sizeof( to ) );
    
        for(;;)
        {
            tmp = sizeof( sin1 );
            i = (int)recvncfrom( s, (void **)&pBuf, 0, (PSA)&sin1, &tmp, &hBuffer );
    
            printf("UDP PACKET RECEIVED from port 5555 : %p\n",*pBuf);
    
            // Spit any data back out
            if( i >= 0 )
            {
                sendto( s, pBuf, i, 0, (PSA)&sin1, sizeof(sin1) );
                recvncfree( hBuffer );
            }
            else
    
                break;
        }
    
        // Since the socket is still open, return "1"
        // (we need to leave UDP sockets open)
        return(1);    
    }

    It is the same for C6670 hello world application too.

    Please let me know if any issues.

    I have send UDP packet from PC to board through "packetsender" and captured the packet in PC which I received from board.

     

    Regards,

    Titus S.

    Please use the latest processor SDK package for your platform (K2H,K2E,C665x,C667x etc.,)

    http://www.ti.com/lsds/ti/tools-software/processor_sw.page

  • In reply to Titusrathinaraj Stalin:

    Hi Taras,
    Also, if you would like me to do the same on C6670 EVM board with client example, surely I can do that for you and update.

     

    Regards,

    Titus S.

    Please use the latest processor SDK package for your platform (K2H,K2E,C665x,C667x etc.,)

    http://www.ti.com/lsds/ti/tools-software/processor_sw.page

  • In reply to Titusrathinaraj Stalin:

    Well i thank you very much, that really helps a lot. But that's not all what i need to do. I've created C++ application, which must send a string like "Hello Board" to the board. Board must recieve this, and spit the "Hello PC" String. In my case it look like even the infinte cycle of recv with "break" is not helping, i can't recieve this data. If i will fix and understand that, hope i'll can do sending to PC by myself.

    UPD: Program runs out of memory when i'm launching the C++ application. Problems with heap or something like that:

    [C66xx_0] ti.sysbios.heaps.HeapMem: line 294: out of memory: handle=0xc1f00b0, size=4096

  • In reply to Taras Kolesko:

    Hi,

    I have added one more screen shot for your reference in previous post..

    I would like you to suggest to use the "packetsender" to send the packet and use the "wireshark" to capture and analyse (whats going on network) the packets over network.


    UPD: Program runs out of memory when i'm launching the C++ application. Problems with heap or something like that:
    [C66xx_0] ti.sysbios.heaps.HeapMem: line 294: out of memory: handle=0xc1f00b0, size=4096


    Try to increase the heap memory in *.cfg file.

    /*
    ** Create a Heap.
    */
    var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
    var heapMemParams = new HeapMem.Params();
    heapMemParams.size = 0x300000;
    heapMemParams.sectionName = "systemHeap";
    Program.global.heap0 = HeapMem.create(heapMemParams);


    Try to use the packet sender and set the break point in function to ensure.
    Else, if you don't have emulator, put some console print.

    Note:
    Try to use "TCP" option too if its not working UDP option in "packet sender" app.

    Please let me know if any issues.

     

    Regards,

    Titus S.

    Please use the latest processor SDK package for your platform (K2H,K2E,C665x,C667x etc.,)

    http://www.ti.com/lsds/ti/tools-software/processor_sw.page

  • In reply to Titusrathinaraj Stalin:

    It's sad, but i can't increase the Heap size, because my programm is barely allocated with that configuration:

    Memory.defaultHeapInstance  =   Program.global.heap0;
    Program.sectMap["sharedL2"] = "MSMCSRAM"; 
    Program.sectMap["systemHeap"] = "MSMCSRAM";
    Program.sectMap[".sysmem"]  = "MSMCSRAM";
    Program.sectMap[".args"]    = "MSMCSRAM";
    Program.sectMap[".cio"]     = "MSMCSRAM";
    Program.sectMap[".far"] 	= 	"MSMCSRAM";
    Program.sectMap[".rodata"] 	= 	"MSMCSRAM";
    Program.sectMap[".neardata"]= 	"MSMCSRAM";
    Program.sectMap[".cppi"] 	= 	"L2SRAM";
    Program.sectMap[".init_array"] 	= 	"MSMCSRAM";
    Program.sectMap[".qmss"] 	= 	"L2SRAM";
    Program.sectMap[".cinit"] 	= 	"L2SRAM";
    Program.sectMap[".bss"]		=	"MSMCSRAM";
    Program.sectMap[".const"]	=	"MSMCSRAM";
    Program.sectMap[".text"]	=	"MSMCSRAM";
    Program.sectMap[".code"]	=	"MSMCSRAM";
    Program.sectMap[".switch"]	=	"MSMCSRAM";
    Program.sectMap[".data"]	=	"MSMCSRAM";
    Program.sectMap[".fardata"] = 	"MSMCSRAM";
    Program.sectMap[".args"] 	= 	"MSMCSRAM";
    Program.sectMap[".cio"] 	= 	"MSMCSRAM";
    Program.sectMap[".vecs"] 	= 	"MSMCSRAM";
    Program.sectMap["platform_lib"] 	= 	"L2SRAM";
    Program.sectMap[".DbgSection"]  = "L2SRAM";
    Program.sectMap[".far:NDK_PACKETMEM"] = {loadSegment: "MSMCSRAM", loadAlign: 128};
    Program.sectMap[".far:taskStackSection"] = "L2SRAM";
    Program.sectMap[".stack"]	=	"L2SRAM";
    Program.sectMap[".nimu_eth_ll2"] = "L2SRAM";
    Program.sectMap[".resmgr_memregion"] = {loadSegment: "L2SRAM", loadAlign:128};	/* QMSS descriptors region 	*/
    Program.sectMap[".resmgr_handles"] = {loadSegment: "L2SRAM", loadAlign:16};	/* CPPI/QMSS/PA Handles			*/
    Program.sectMap[".resmgr_pa"]	= {loadSegment: "L2SRAM", loadAlign:8};		/* PA Memory					*/
    Program.sectMap[".far:IMAGEDATA"] = {loadSegment: "L2SRAM", loadAlign: 8};
    Program.sectMap[".far:NDK_OBJMEM"] = {loadSegment: "L2SRAM", loadAlign: 8};
    

    If you still remember my DDR3 problems, you would understand this "crutch" :) Still, i will try to add another internal memory region, such as L1DSRAM or something. Please, can you provide links to examples of ad sizes of memory regions and the regions themselves.

  • In reply to Titusrathinaraj Stalin:

    UPD:

    [C66xx_0] ti.sysbios.heaps.HeapMem: line 294: out of memory: handle=0xc1f0080, size=4096
    [C66xx_0] xdc.runtime.Error.raise: terminating execution


    begins to appear, when i'm trying send packet with PacketSender, as you said. I've added the transmission task function

    /*
     * retrans.c
     *
     *  Created on: 11.08.2015
     *      Author: KolesTaras
     */
    
    #include <ti/ndk/inc/netmain.h>
    
    //
    // dtask_udp_hello() - UDP Echo Server Daemon Function
    // (SOCK_DGRAM, port 7)
    //
    // Returns "1" if socket 's' is still open, and "0" if its been closed
    //
    int dtask_udp_transmit( SOCKET s, UINT32 unused )
    {
    	SOCKET sUDP;
        struct sockaddr_in sin1;
        struct timeval     to;
        int                i,tmp;
        char               *pBuf;
        HANDLE             hBuffer;
    
        (void)unused;
    
     
        // Configure our socket timeout to be 3 seconds
        to.tv_sec  = 3;
        to.tv_usec = 0;
        setsockopt( sUDP, SOL_SOCKET, SO_SNDTIMEO, &to, sizeof( to ) );
        setsockopt( sUDP, SOL_SOCKET, SO_RCVTIMEO, &to, sizeof( to ) );
    
        for(;;)
        {
            tmp = sizeof( sin1 );
            i = (int)recvncfrom( sUDP, (void **)&pBuf, 0, (PSA)&sin1, &tmp, &hBuffer );
    
            // Spit any data back out
           /* if( i >= 0 )
            {
                sendto( sUDP, "Hello PC!", i, 0, (PSA)&sin1, sizeof(sin1) );
                recvncfree( hBuffer );
            }
            else*/
                break;
        }
    
        // Since the socket is still open, return "1"
        // (we need to leave UDP sockets open)
        return(1);
    }
    

    and declared it as follows:

    static void NetworkOpen()
    {
        // Create our local servers
        hEcho = DaemonNew( SOCK_STREAMNC, 0, 7, dtask_tcp_echo,
                           OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3 );
        hEchoUdp = DaemonNew( SOCK_DGRAM, 0, 7, dtask_udp_echo,
                              OS_TASKPRINORM, OS_TASKSTKNORM, 0, 1 );
        hData = DaemonNew( SOCK_STREAM, 0, 1000, dtask_tcp_datasrv,
                           OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3 );
        hNull = DaemonNew( SOCK_STREAMNC, 0, 1001, dtask_tcp_nullsrv,
                           OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3 );
        hOob  = DaemonNew( SOCK_STREAMNC, 0, 999, dtask_tcp_oobsrv,
                           OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3 );
        hRetr = DaemonNew(SOCK_DGRAM, 0, 5555, dtask_udp_transmit,
                OS_TASKPRINORM, OS_TASKSTKNORM, 0, 1 );
    
    /* ....*/
    }


    the Full picture of an issue:

    Also, can you please link me your *.cfg file memory map allocation?

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.