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.

DATA COMMUNICATION BETWEEN PC AND OMAP L138 via ETHERNET

Other Parts Discussed in Thread: OMAP-L138

Hi,

I am planning to transmit 300 bytes of data from PC to OMAP L138 and 500 bytes of data from OMAP L138 to PC (having windows 7 os). I am using  CCS V5.1 and NDK  V2.21. I am not using any OS for my OMAP L138 hardware and i will be using only C6748 for data reception and transmission.

Can you suggest me any sample example code that suits this requirement (either TCP or UDP). Also let me know where i need to make modification in the sample code to meet my data byte size requirement.

Regards,

Kumar

  • Kumar,
    You can use the NDK and NSP release for OMAP-L138/ C6748. Please see this wiki page,
    http://processors.wiki.ti.com/index.php/Network_Developers_Kit_Licensing_and_Availability
    http://processors.wiki.ti.com/index.php/Category:NDK

    And also you should download NDK Support Package NSP from - nsp_x_x_x_x\packages\ti\ndk\examples
    In this package have the "helloWorld" test project for UDP.
    http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/ndk/index.html

    The below code for UDP receive and send for your reference only.

    #include <netmain.h>
    
    SOCKET   sudp;
    unsigned char packetBuf[200];
    unsigned char packetSendBuf[200];
    int QuerySet = 0;
    
    //This recvUDP should be called as task.
    void recvUDP()
    {
    	struct   sockaddr_in sin1;
    	struct	 sockaddr_in sendAddr;
    	struct   sockaddr_in recvAddr;
    	struct   timeval timeout;
    	int      size, retvalue, fdvalue;
    	int 	 pktsize;
    	int 	 pbufsize;
    	unsigned int pbuf[128];
    
    
    	retvalue = fdOpenSession( TaskSelf() );
    
    	sudp = INVALID_SOCKET;
    	sudp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    	if( sudp == INVALID_SOCKET )
    	{
    		printf("Socket creation failed \n");
    		goto leave;
    	}
    
    	bzero( &sin1, sizeof(struct sockaddr_in) );
    	sin1.sin_family 	 = AF_INET;
    	sin1.sin_len    	 = sizeof( sin1 );
    	sin1.sin_port   	 = htons(16400);
    	sin1.sin_addr.s_addr = inet_addr("234.5.5.5");
    
    	pbufsize = 128;
    
    	retvalue = 0;
    	retvalue = setsockopt( sudp, SOL_SOCKET, SO_REUSEPORT, (void *) pbuf, pbufsize);
    	if(retvalue < 0)
    		printf("REUSEPORT = %d\n",fdError());
    
    	retvalue = 0;
    	retvalue = setsockopt( sudp, SOL_SOCKET, SO_REUSEADDR, (void *) pbuf, pbufsize);
    	if(retvalue < 0)
    		printf("REUSEADDR = %d\n",fdError());
    
    	if ( bind( sudp, (PSA) &sin1, sizeof(sin1) ) < 0 )
    	{
    		retvalue = fdError();
    		printf("data bind error=%d\n",retvalue);
    		goto leave;
    	}
    
    	bzero( &sendAddr, sizeof(struct sockaddr_in) );
    	sendAddr.sin_family      = AF_INET;
    	sendAddr.sin_len         = sizeof(sendAddr);
    	sendAddr.sin_port        = htons(16400);
    
    	timeout.tv_sec  =  0;
    	timeout.tv_usec =  100;
    	setsockopt( sudp, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof( timeout ) );
    
    	size = sizeof( recvAddr );
    
    	while(1)
    	{
    		fd_set readfds, writefds, xfds;
    
    		FD_ZERO(&readfds);
    		FD_ZERO(&writefds);
    		FD_ZERO(&xfds);
    
    		FD_SET(sudp, &readfds);
    
    		fdvalue = fdSelect( 4, &readfds, &writefds, &xfds, &timeout );
    		if(fdvalue < 0)
    			 printf("No incoming data:\n %d",fdvalue);
    
    		if (FD_ISSET(sudp, &readfds) )
    		{
    			pktsize = recvfrom(sudp, packetBuf, 200, 0, &recvAddr, &size);
    			if(pktsize < 0)
    				printf("Error in Quary Recv %d", fdError());
    			else
    			{
    				printf("Quary Recd = %d\n", pktsize);
    				QuerySet = 1;
    			}
    		}
    
    
    		if(QuerySet == 1)
    		{
    			sendAddr.sin_addr.s_addr = recvAddr.sin_addr.s_addr;
    
    			pktsize = sendto(sudp, packetSendBuf, 200, 0, &sendAddr, sizeof(sendAddr));
    			if(pktsize < 0)
    				printf("Error in Quary send %d", fdError());
    
    
    		}
    	}
    
    leave:
       printf("leave in\n");
    
    
    }

  • Dear Pubesh,

    Thanks for your reply and code. As I am new to ethernet configuration and programing, I am not able to understand much from the code sent by you. I need following support from you:

    1) As this code can not be directly compiled, can you send me the complete project related to it at my mails id sksinha_dsp@rediffmail.com, so that at least I can compile and execute this data transmission and reception code and understand it.

    2) You are also requested to kindly tell me where the destination IP address and source ( in this case omap l138evm) IP address and socket address is defined.

    3) Can you tell me what data this program is transmitting and it is mentioned in which section of the code.

    I tried to make use of  "helloworld" test program but the document SPRU523H does not explain above points.

    At the PC end, code is written in VC++ to transmit and receive data through ethernet but we are facing alot of problem at OMAP end. We request your help.

    Regards,

    Kumar