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.

How to telnet from one C66xx to another

Hi

I would like to know how I can open a telnet from one dsp board to another, without the use of a PC?

I am running the Client example project on a C6655 custom board.

I am using bios_6_41_00_26 and ndk_2_24_00_11

I am able to open a telnet console from my PC to both of the boards, and from these I can tell the boards to ping each other, so that is all very fine. But in order to qualify the performance of the board in EMC test, I need to remove the PC from the setup. Therefore I would like to open a (telnet) connection from the first board to the second board and then e.g ask the second board to ping the first board, which will create some trafic on the Ethernet interface. 

It should be noted that It does not have to be a telnet connection, it could be any connection between two DSP boards that can generate trafic on the Ethernet.

I would appreciate it if you could provide some example code for such a setup

Best

Jens

  • Hi Jens,
    We don't have a example for telnet client activity.
    You have to write your own code to do that ping from one DSP board to another board via telnet.
    Actually the current implementation has support for telnet server.
  • You may have to rebuild the NDK.
    processors.wiki.ti.com/.../Rebuilding_the_NDK_Core

    C:\ti\ndk_2_21_02_43\packages\ti\ndk\tools\console\console.c
  • Thanks for the replies; I do not mean to sound ungreatfull or rude but I must say they are not very usefull :-(

    I asked how to open a telnet connection from my DSP using the NDK, and you answer "we do not have example code for that - do it your self"

    I do expect to get a complete telnet application that runs out of the box, but surely you can give some information about how to open a telnet connection, and send a ping?

    /Jens

  • Hi Jens,
    I will give my support to you in best.
    Already I asked one of my colleague to support here. No worries.
    Thanks for your patience.
  • Hi

    I have made some progress in the matter of getting two boards to communicate over the ethernet, but I still have little way to go.

    I decided to setup a UDP connection between the two boards instead of the Telnet, so I use the example given by the Helloworld test project.

    When I use this example out-of-the-box and run the windows test application testudp.exe I can send and recieve Packets between my PC and both of the boards, but I still need a way to make one of the boards send to the other board.

    To do that I found an example here in the forum where a user set up a UDP-socket and sends a packet to his PC.

    I have integrated this into my code so now on one board (the master) I spawn a task that opens a socket and sends a UDP message to the other board (the slave). On the slave I just run the udp-deamon that recieves a message and echos it back to the master.

    I can see that the slave recieves the data from the master, and tries to send it back, but on the master I do not recieve anything.

    I have pasted the code below, and hope you can see what I am doing wrong

    Thanks

    Jens

    #include <stdio.h>
    #include <ti/ndk/inc/netmain.h>
    
    #include "myconsole.h"
    #include "client.h"
    #include "phy_if.h"
    #include "framework.h"
    
    /* BIOS6 include */
    #include <ti/sysbios/BIOS.h>
    
    /* Platform utilities include */
    #include <ti/platform/platform.h>
    
    void cbServiceReport( void);
    void hookThreadBegin(void);
    void hookThreadInit(void);
    void hookThreadDelete(void);
    void hookStatusReport(uint Item, uint Status, uint Report, HANDLE h);
    void hookNetworkOpen(void);
    void hookNetworkClose(void);
    void hookNetworkIP(void);
    int dtask_udp_echo( SOCKET s, UINT32 unused );
    int sendFirst(void);
    static void SendUdp(UArg arg0, UArg arg1);
    
    char *VerStr = "\nTCP/IP Stack Example Client\n";
    
    static OS_HSem semaphore;
    static HANDLE hHello = 0;
    static HANDLE hSendUdp = 0;
    int udp_master = 0;
    
    //---------------------------------------------------------------------
    // Main Entry Point
    //---------------------------------------------------------------------
    int init_client(void)
    {
      return(0);
    }
    
    void start_client(int master)
    {
      udp_master = master;
      OS_SemGive(semaphore);
    }
    
    void   cbServiceReport( void)
    {
      printf("cbServiceReport\n");
    }
    
    void hookThreadBegin(void)
    {
      semaphore = OS_SemCreate(0);
      OS_SemTake(semaphore, OS_TIMEOUT_FOREVER);
      printf("void hookThreadBegin \n");
    }
    
    void hookThreadInit(void)
    {
      TaskSleep(2000);
      printf("void hookThreadInit \n ");
    }
    void hookThreadDelete(void)
    {
      printf("void hookThreadDelete\n");
    }
    void hookStatusReport(uint Item, uint Status, uint Report, HANDLE h)
    {
      printf("void hookStatusReport\n");
    }
    void hookNetworkOpen(void)
    {
      AddWebFiles();
      // Create our local server
      if (!udp_master)
      {
        hHello = DaemonNew( SOCK_DGRAM, 0, 7, dtask_udp_echo, OS_TASKPRINORM, OS_TASKSTKNORM, 0, 1 );
      }
      else
      {
        hSendUdp = TaskCreate( SendUdp, "SendUdp", OS_TASKPRINORM, 0x1000, 0, 0, 0 );
      }
          
      printf("void hookNetworkOpen \n");
    }
    void hookNetworkClose(void)
    {
      printf("void hookNetworkClose\n");
    }
    void hookNetworkIP(void)
    {
      printf("void hookNetworkIP   \n");
    }
    
    int dtask_udp_echo( SOCKET s, UINT32 unused )
    {
      struct sockaddr_in sin1;
      struct timeval     to;
      int                i, tmp;
      char               *pBuf;
      HANDLE             hBuffer;
      static int cnt   = 0;
      (void)unused;
    
      for (;;)
      {
        // Configure our socket timeout to be 10 seconds
        to.tv_sec  = 10;
        to.tv_usec = 0;
        setsockopt( s, SOL_SOCKET, SO_SNDTIMEO, &to, sizeof( to ) );
        setsockopt( s, SOL_SOCKET, SO_RCVTIMEO, &to, sizeof( to ) );
        tmp = sizeof( sin1 );
        i = (int)recvncfrom( s, (void **) & pBuf, 0, (PSA) & sin1, &tmp, &hBuffer );
    
        // Spit any data back out
        if ( i >= 0 )
        {
          ConPrintf("Got UDP message, data=%s counter=%d\n", pBuf, cnt++);
          sendto( s, pBuf, i, MSG_DONTWAIT, (PSA)&sin1, sizeof(sin1) );
          recvncfree( hBuffer );
        }
        else
        {
          ConPrintf("Got nothing error %d\n", fdError());
          //break;
        }
      }
    
      // Since the socket is still open, return "1"
      // (we need to leave UDP sockets open)
      return(1);
    }
    
    // task that runs on master board to send udp messages to slave
    static void SendUdp(UArg arg0, UArg arg1)
    {
      struct sockaddr_in destAddr;
      struct sockaddr_in myAddr;
      struct timeval     to;
      SOCKET sock;
      int i, tmp;
      int retval;
      int cnt = 0;
      char               *rxBuf;
      HANDLE             hBuffer;
      char txBuf[] = "hello world";
    
      fdOpenSession( (HANDLE)Task_self() );
      sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    
      if (socket == INVALID_SOCKET)
      {
        printf("socket error: %d\n", fdError());
      }
      else
      {
        printf("socket handle: 0x%x\n", (unsigned)sock);
      }
    
      getsockname(sock, (PSA)&myAddr, &tmp);
    
     
      if (!(rxBuf = malloc(100)))
      {
        printf("failed temp buffer allocation\n");
      }
    
      bzero((void*)&destAddr, sizeof(destAddr));
      destAddr.sin_addr.s_addr = inet_addr("192.168.0.188");
      destAddr.sin_port = htons(7);
      destAddr.sin_family = AF_INET;
    
     // Configure our socket timeout to be 1 seconds
      to.tv_sec  = 1;
      to.tv_usec = 0;
      setsockopt( sock, SOL_SOCKET, SO_SNDTIMEO, &to, sizeof( to ) );
      setsockopt( sock, SOL_SOCKET, SO_RCVTIMEO, &to, sizeof( to ) );
    
      for(;;)
      {
        // send message to slave board 
        retval = sendto( sock,  (void*)txBuf, 12, MSG_DONTWAIT, (PSA) & destAddr, sizeof(destAddr) );
    
        // wait for response from slave
        tmp = sizeof( destAddr );
        i = (int)recvncfrom( sock, (void **) & rxBuf, 0, (PSA) & destAddr, &tmp, &hBuffer );
    
    
        if ( i >= 0 )
        {
          ConPrintf("Got UDP message, data=%s counter=%d\n", rxBuf, cnt++);
          recvncfree( hBuffer );
        }
        else
        {
          ConPrintf("Got no reply bytes=%d error=%d\n", i, fdError());
        }
    
        TaskSleep(10);
        //ENOBUFS
      }
      fdCloseSession((HANDLE)Task_self());
    
    }