Thanks,
Anjana Pathak
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.
Thanks,
Anjana Pathak
Hi Anjana,
Yes, you can develop your network application based on EMAC_BasicExample_evmAM572x_armBiosExampleProject. Developing a network application with the NDK software is similar to program with a standard sockets API, please refer to the chapter 3 "Network Application Development" in the TI Network Developer's Kit (NDK) v2.24 User's Guide spru523i.pdf (ndk_2_24_03_35\docs). This chapter describes how to begin developing network applications. It discusses the issues and guidelines involved in the development of network applications using the NDK libraries. Section 3.4 provides an Example Code. For the EMAC_BasicExample_evmAM572x_armBiosExampleProject, the source IP address is defined in nimu_evm.cfg,
if (enableStaticIP)
{
/* Settings for static IP configuration */
Ip.ResolveIP = false;
Ip.CallByIP = false;
Ip.autoIp = false;
Ip.address = "192.168.1.4";
Ip.mask = "255.255.255.0";
Ip.gatewayIpAddr = "192.168.1.1";
}
The destination IP address you specify will need fill in structure sockaddr, and then used by
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *to,
socklen_t tolen);
in the case you send data from EVM to PC, or vice versa,
ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *from,
socklen_t *fromlen);
Regards,
Garrett
Thanks Garett,
but the config file used in EMAC_BasicExample_evmAM572x_armBiosExampleProject is evm_AM572x.cfg and for example project NIMU_BasicExample_evmAM572x_armExampleproject config file used is nimu_evm.cfg In evm_AM572x.cfg no IP address is defined and not able to trace where the IP address is set. In which file the below functions and structure sockaddr is defined?
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *to,
socklen_t tolen);
ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *from,
socklen_t *fromlen);
Regards,
Anjana Pathak
Anjana,
Please refer to section 3.5.1 Troubleshooting Common Problems, in "TI Network Developer's Kit (NDK) v2.24 User's Guide", spru523i.
All socket calls return “error” (-1)
• Make sure there is a call to fdOpenSession() in the Task before it uses sockets, and a call to
fdCloseSession() when the Task terminates
Regards, Garrett
Thanks Garrett,
I did the changes in NIMU example to send data after refering NDK user guide spru523i. But not able to send data. Attaching the code of modified NIMU_BasicExample_evmAM572x_armExampleproject. Configuring NDK with XGCONF. Please suggest where i am going wrong.
Task_Handle main_task;
static int nimu_device_index = 0U;
NIMU_DEVICE_TABLE_ENTRY NIMUDeviceTable[MAX_TABLE_ENTRIES];
void TaskFxn(UArg a0, UArg a1);
extern int CpswEmacInit (STKEVENT_Handle hEvent);
//tagged by anjana
void app_delay(uint32_t delayValue);
void SendDataToPC();
struct sockaddr_in sin1;
//---------------------------------------------------------------------------
// Configuration
//
//char *HostName1 = "tidsp";
char *LocalIPAddr1 = "192.168.1.2";
char *IPAddr = "192.168.1.100";
//char *LocalIPMask1 = "255.255.255.0"; // Not used when using DHCP
//char *GatewayIP1 = "192.168.1.1"; // Not used when using DHCP
//char *DomainName1 = "demo.net"; // Not used when using DHCP
//char *DNSServer1 = "0.0.0.0"; // Used when set to anything but zero
/* ========================================================================== */
/* Function Definitions */
/* ========================================================================== */
/**
* \brief This function returns the MAC address for the EVM
*
* \param addrIdx the MAC address index.
* \param macAddr the Pointer where the MAC address shall be stored
* 'addrIdx' can be either 0 or 1
*
* \return None.
*/
/*void EVMMACAddrGet(uint32_t addrIdx, uint8_t *macAddr)
{
macAddr[0U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_0
>> 16U) & 0xFFU;
macAddr[1U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_0
>> 8U) & 0xFFU;
macAddr[2U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_0)
& 0xFF;
macAddr[3U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_1
>> 16U) & 0xFFU;
macAddr[4U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_1
>> 8U) & 0xFFU;
macAddr[5U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_1)
& 0xFFU;
}commented by anjana*/
int32_t EVMMACAddrGet(uint32_t addrIdx, uint8_t *macAddr)
{
int32_t retVal = 0;
switch(addrIdx)
{
case 1U:
macAddr[0U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_1
>> 16U) & 0xFFU;
macAddr[1U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_1
>> 8U) & 0xFFU;
macAddr[2U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_1)
& 0xFFU;
macAddr[3U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_0
>> 16U) & 0xFFU;
macAddr[4U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_0
>> 8U) & 0xFFU;
macAddr[5U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_0)
& 0xFF;
break;
case 2U:
macAddr[0U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_3
>> 16U) & 0xFFU;
macAddr[1U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_3
>> 8U) & 0xFFU;
macAddr[2U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_3)
& 0xFFU;
macAddr[3U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_2
>> 16U) & 0xFFU;
macAddr[4U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_2
>> 8U) & 0xFFU;
macAddr[5U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_2)
& 0xFF;
break;
default:
retVal = -1;
break;
}
return retVal;
}
/**
* \name main
* \brief Main Function
* \param none
* \return none
*
*/
int main()
{
/* Call board init functions */
Board_initCfg boardCfg;
Task_Params taskParams;
EMAC_HwAttrs_V4 cfg;
boardCfg = BOARD_INIT_PINMUX_CONFIG |
BOARD_INIT_MODULE_CLOCK | BOARD_INIT_UART_STDIO;
Board_init(boardCfg);
CSL_xbarMpuIrqConfigure(CSL_XBAR_INST_MPU_IRQ_92, CSL_XBAR_GMAC_SW_IRQ_RX_PULSE);
CSL_xbarMpuIrqConfigure(CSL_XBAR_INST_MPU_IRQ_93, CSL_XBAR_GMAC_SW_IRQ_TX_PULSE);
/* Select RGMII 2 ports GMIIx_SEL = 2 for RGMII*/
CSL_FINS (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->CONTROL_IO_1,
CONTROL_CORE_CONTROL_IO_1_GMII1_SEL, 2U);
CSL_FINS (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->CONTROL_IO_1,
CONTROL_CORE_CONTROL_IO_1_GMII2_SEL, 2U);
/*GMAC RESET ISOLATION Enable*/
CSL_FINS (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->CONTROL_IO_2,
CONTROL_CORE_CONTROL_IO_2_GMAC_RESET_ISOLATION_ENABLE, 0U);
CSL_FINS (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->CONTROL_IO_2,
CONTROL_CORE_CONTROL_IO_2_GMAC_RESET_ISOLATION_ENABLE, 1U);
EMAC_socGetInitCfg(0, &cfg);
cfg.port[0].phy_addr = EMAC_CPSW_PORT0_PHY_ADDR_EVM;
cfg.port[1].phy_addr = EMAC_CPSW_PORT1_PHY_ADDR_EVM;
EMAC_socSetInitCfg(0, &cfg);
Task_Params_init(&taskParams);
taskParams.priority = 1;
taskParams.stackSize = 0x1400;
main_task = Task_create (TaskFxn, &taskParams, NULL);
//Tagged by anjana
Task_Params_init(&taskParams);
taskParams.priority = 2;
taskParams.stackSize = 0x1400;
main_task = Task_create (SendDataToPC, &taskParams, NULL);
NIMUDeviceTable[nimu_device_index++].init = &CpswEmacInit ;
NIMUDeviceTable[nimu_device_index].init = NULL ;
/* Task_Params_init(&taskParams);
taskParams.priority = 1;
taskParams.stackSize = 0x1400;
main_task = Task_create (TaskFxn, &taskParams, NULL);*/
BIOS_start();
return -1;
}
/**
* \name TaskFxn
* \brief Task which do EIP initialization
* \param a0
* \param a1
* \return none
*
*/
void TaskFxn(UArg a0, UArg a1)
{
NIMU_log("\n\rSYS/BIOS Ethernet/IP (CPSW) Sample application\n\r");
//SendDataToPC();
}
//tagged by anjana
void SendDataToPC()
{
SOCKET s = INVALID_SOCKET;
struct sockaddr_in sin1;
// struct sockaddr_in sin_bind1;
int I,test=125;
char *pBuf = 0;
struct timeval timeout;
// Allocate the file descriptor environment for this Task
fdOpenSession( (HANDLE)Task_self() );
NIMU_log("\n== Start TCP Echo Client Test ==\n");
//NIMU_log("\n== Start UDP Echo Client Test ==\n");
// Create test socket
//s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if( s == INVALID_SOCKET )
{
NIMU_log("failed socket create (%d)\n",fdError());
goto leave;
}
// Prepare address for connect
bzero( &sin1, sizeof(struct sockaddr_in) );
sin1.sin_family = AF_INET;
sin1.sin_addr.s_addr = inet_addr(IPAddr);//inet_addr(SERVER_IP);//htonl(-1);
sin1.sin_port = htons(7);
/*bzero( &sin_bind1, sizeof(struct sockaddr_in) );
sin_bind1.sin_family = AF_INET;
sin_bind1.sin_addr.s_addr = inet_addr(LocalIPAddr1);//IPAddr;
sin_bind1.sin_port = htons(1025);//htons(7);
if( bind( s, (PSA) &sin_bind1, sizeof(sin_bind1) ) < 0 )
{
NIMU_log("failed bind (%d)\n",fdError());
goto leave;
}
else
{NIMU_log("bind succesful\n");}*/
// Configure our Tx and Rx timeout to be 5 seconds
timeout.tv_sec = 5;
timeout.tv_usec = 0;
if(setsockopt( s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof( timeout ) ) < 0 )
{
NIMU_log("failed Socket opt(%d)\n",fdError());
goto leave;
}
else
{NIMU_log("Socket opt succesful\n");}
setsockopt( s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof( timeout ) );
// Connect socket
if( connect( s, (PSA) &sin1, sizeof(sin1) ) < 0 )
{
NIMU_log("failed connect (%d)\n",fdError());
goto leave;
}
// Allocate a working buffer
if( !(pBuf = malloc( 125 )) )
{
NIMU_log("failed temp buffer allocation\n");
goto leave;
}
// Fill buffer with a test pattern
for(I=0; I<125; I++)
*(pBuf+I) = (char)I;
// Send the buffer
/* sin1.sin_family = AF_INET;
sin1.sin_addr.s_addr = inet_addr(SERVER_IP);//htonl(-1);
sin1.sin_port = htons(7);
app_delay(10000000);*/
/*ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *to,
socklen_t tolen);*/
//if(sendto(s, pBuf, 125, 0, (PSA)&sin1,sizeof(sin1)) < 0);
if( send( s, pBuf, 125, 0 ) < 0 )
{
NIMU_log("send failed (%d)\n",fdError());
goto leave;
}
/* for(I=0;I<10;I++)
{
//test=send( s, pBuf, sizeof(pBuf), 0 );
test=sendto(s, pBuf, 125, 0, (PSA)&sin1,sizeof(sin1));
NIMU_log("send result= %d\n",test);
NIMU_log("send failed (%d)\n",fdError());
app_delay(10000000);
}*/
// Try and receive the test pattern back
/*I = recv( s, pBuf, 125, MSG_WAITALL );
if( I < 0 )
{
NIMU_log("recv failed (%d)\n",fdError());
goto leave;
}
// Verify reception size and pattern
if( I != test )
{
NIMU_log("received %d (not %d) bytes\n",I, test);
goto leave;
}
for(I=0; I<test; I++)
if( *(pBuf+I) != (char)I )
{
NIMU_log("verify failed at byte %d\n",I);
break;
}
// If here, the test passed
if( I==test )
NIMU_log("passed\n");*/
leave:
if( pBuf )
free( pBuf );
if( s != INVALID_SOCKET )
fdClose( s );
//NIMU_log("== End UDP Echo Client Test ==\n\n");
NIMU_log("== End TCP Echo Client Test ==\n\n");
// Free the file descriptor environment for this Task
fdCloseSession( (HANDLE)Task_self() );
Task_exit();
}
Please reply.........................waiting for suggestion.
or shall i open a new post for this
I am not able to receive data from evmAm572x on TCPIP to PC(application used is telnet to receive data). I did the changes as you mentioned.
I am getting response as of send(.............) as 4 // Interrupted system call.
1. Please suggest if i need to do any other changes in file(nimu_cfg/other network open or configuration file)
2.Which tool shall i use to test the TCPIP communication?
Attaching my code also
/* ========================================================================== */
/* Include Files */
/* ========================================================================== */
#include <stdio.h>
#include <string.h>
#include <stdlib.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/ndk/inc/stkmain.h>
//tagged by anjana
#include <ti/ndk/inc/netmain.h>
#include <ti/drv/emac/emac_drv.h>
#include <ti/drv/emac/src/v4/emac_drv_v4.h>
#include <ti/csl/soc.h>
#include <ti/csl/cslr_device.h>
#include <ti/board/board.h>
/* TI-RTOS Header files */
#include <ti/drv/i2c/I2C.h>
#include <ti/drv/i2c/soc/I2C_v1.h>
/* UART Header files */
#include <ti/drv/uart/UART.h>
#include <ti/drv/uart/UART_stdio.h>
#include <ti/csl/soc/am572x/src/csl_device_xbar.h>
/* Enable the below macro to have prints on the IO Console */
//#define IO_CONSOLE
#ifndef IO_CONSOLE
#define NIMU_log UART_printf
#else
#define NIMU_log printf
#endif
/* ========================================================================== */
/* Macros */
/* ========================================================================== */
/**Phy address of port 0 */
#define EMAC_CPSW_PORT0_PHY_ADDR_EVM 1
/**Phy address of port 1 */
#define EMAC_CPSW_PORT1_PHY_ADDR_EVM 2
#define MAX_TABLE_ENTRIES 3
/* ========================================================================== */
/* Global Variables */
/* ========================================================================== */
/**Task handle for EIP*/
Task_Handle main_task;
static int nimu_device_index = 0U;
NIMU_DEVICE_TABLE_ENTRY NIMUDeviceTable[MAX_TABLE_ENTRIES];
void TaskFxn(UArg a0, UArg a1);
extern int CpswEmacInit (STKEVENT_Handle hEvent);
//tagged by anjana
void app_delay(uint32_t delayValue);
void SendDataToPC();
struct sockaddr_in sin1;
//---------------------------------------------------------------------------
// Configuration
//
//char *HostName1 = "tidsp";
char *IPAddr = "192.168.0.144";
//char *IPAddr = "255.255.255.255";
//char *LocalIPMask1 = "255.255.255.0"; // Not used when using DHCP
//char *GatewayIP1 = "192.168.1.1"; // Not used when using DHCP
//char *DomainName1 = "demo.net"; // Not used when using DHCP
//char *DNSServer1 = "0.0.0.0"; // Used when set to anything but zero
/* ========================================================================== */
/* Function Definitions */
/* ========================================================================== */
/**
* \brief This function returns the MAC address for the EVM
*
* \param addrIdx the MAC address index.
* \param macAddr the Pointer where the MAC address shall be stored
* 'addrIdx' can be either 0 or 1
*
* \return None.
*/
int32_t EVMMACAddrGet(uint32_t addrIdx, uint8_t *macAddr)
{
int32_t retVal = 0;
switch(addrIdx)
{
case 1U:
macAddr[0U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_1
>> 16U) & 0xFFU;
macAddr[1U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_1
>> 8U) & 0xFFU;
macAddr[2U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_1)
& 0xFFU;
macAddr[3U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_0
>> 16U) & 0xFFU;
macAddr[4U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_0
>> 8U) & 0xFFU;
macAddr[5U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_0)
& 0xFF;
break;
case 2U:
macAddr[0U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_3
>> 16U) & 0xFFU;
macAddr[1U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_3
>> 8U) & 0xFFU;
macAddr[2U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_3)
& 0xFFU;
macAddr[3U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_2
>> 16U) & 0xFFU;
macAddr[4U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_2
>> 8U) & 0xFFU;
macAddr[5U] = (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->MAC_ID_SW_2)
& 0xFF;
break;
default:
retVal = -1;
break;
}
return retVal;
}
/**
* \name main
* \brief Main Function
* \param none
* \return none
*
*/
int main()
{
/* Call board init functions */
Board_initCfg boardCfg;
Task_Params taskParams;
EMAC_HwAttrs_V4 cfg;
boardCfg = BOARD_INIT_PINMUX_CONFIG |
BOARD_INIT_MODULE_CLOCK | BOARD_INIT_UART_STDIO;
Board_init(boardCfg);
CSL_xbarMpuIrqConfigure(CSL_XBAR_INST_MPU_IRQ_92, CSL_XBAR_GMAC_SW_IRQ_RX_PULSE);
CSL_xbarMpuIrqConfigure(CSL_XBAR_INST_MPU_IRQ_93, CSL_XBAR_GMAC_SW_IRQ_TX_PULSE);
/* Select RGMII 2 ports GMIIx_SEL = 2 for RGMII*/
CSL_FINS (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->CONTROL_IO_1,
CONTROL_CORE_CONTROL_IO_1_GMII1_SEL, 2U);
CSL_FINS (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->CONTROL_IO_1,
CONTROL_CORE_CONTROL_IO_1_GMII2_SEL, 2U);
/*GMAC RESET ISOLATION Enable*/
CSL_FINS (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->CONTROL_IO_2,
CONTROL_CORE_CONTROL_IO_2_GMAC_RESET_ISOLATION_ENABLE, 0U);
CSL_FINS (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->CONTROL_IO_2,
CONTROL_CORE_CONTROL_IO_2_GMAC_RESET_ISOLATION_ENABLE, 1U);
EMAC_socGetInitCfg(0, &cfg);
cfg.port[0].phy_addr = EMAC_CPSW_PORT0_PHY_ADDR_EVM;
cfg.port[1].phy_addr = EMAC_CPSW_PORT1_PHY_ADDR_EVM;
EMAC_socSetInitCfg(0, &cfg);
Task_Params_init(&taskParams);
taskParams.priority = 1;
taskParams.stackSize = 0x1400;
main_task = Task_create (TaskFxn, &taskParams, NULL);
NIMUDeviceTable[nimu_device_index++].init = &CpswEmacInit ;
NIMUDeviceTable[nimu_device_index].init = NULL ;
BIOS_start();
return -1;
}
/**
* \name TaskFxn
* \brief Task which do EIP initialization
* \param a0
* \param a1
* \return none
*
*/
void TaskFxn(UArg a0, UArg a1)
{
NIMU_log("\n\rSYS/BIOS Ethernet/IP (CPSW) Sample application\n\r");
SendDataToPC();
}
//tagged by anjana
void SendDataToPC()
{
SOCKET s = INVALID_SOCKET;
struct sockaddr_in sin1;
int j,I,test=256;
int yes1=1;
char *pBuf = 0;
struct timeval timeout;
app_delay(1000000);
fdOpenSession( (HANDLE)Task_self() );
NIMU_log("\n== Start TCP Client Test ==\n");
// Create test socket
s = socket(AF_INET, SOCK_STREAM, 0);
if( s == INVALID_SOCKET )
{
NIMU_log("failed socket create (%d)\n",fdError());
goto leave;
}
// Prepare address for connect
bzero( &sin1, sizeof(struct sockaddr_in) );
sin1.sin_family = AF_INET;
sin1.sin_addr.s_addr = inet_addr(IPAddr);//inet_addr(SERVER_IP);//htonl(-1);
sin1.sin_port = htons(23);//htons(9000);
// Configure our Tx and Rx timeout to be 5 seconds For TCPIP
timeout.tv_sec = 5;
timeout.tv_usec = 0;
if(setsockopt( s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof( timeout ) ) < 0 )
{
NIMU_log("failed Socket opt(%d)\n",fdError());
goto leave;
}
else
{NIMU_log("Socket opt succesful\n");}
setsockopt( s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof( timeout ) );
// Connect socket
if( connect( s, (PSA) &sin1, sizeof(sin1) ) < 0 )
{
NIMU_log("failed connect (%d)\n",fdError());
goto leave;
}
// Allocate a working buffer
if( !(pBuf = malloc( test )) )
{
NIMU_log("failed temp buffer allocation\n");
goto leave;
}
// Fill buffer with a test pattern
for(I=0,j=0; I<85; I++)
{
*(pBuf+I) = (char)I;
}
// Send the buffer
for(I=0;I<100;I++)
{
test=send( s, pBuf, sizeof(pBuf), 0 );
//test=sendto(s, pBuf, 256, 0, (PSA)&sin1,sizeof(sin1));//for UDP
NIMU_log("send result= %d\n",test);
NIMU_log("send failed (%d)\n",fdError());
app_delay(1000000);
}
leave:
if( pBuf )
free( pBuf );
if( s != INVALID_SOCKET )
fdClose( s );
NIMU_log("== End TCP Client Test ==\n\n");
// Free the file descriptor environment for this Task
fdCloseSession( (HANDLE)Task_self() );
Task_exit();
}
void app_delay(uint32_t delayValue)
{
volatile uint32_t delay = delayValue*10;
while (delay--);
}
Hi Garrett,
I developed TCPiP client on the EvM defined port 23 the source code I attaced in my last communication.
When i run this code using target debugger. i got send(..) response as number of bytes send, means it trys to send data for approx 20 iterration but after that the response of send(..) changes to error code 35 /* Operation would block */ and then 57 /*Socket is not connected */ .
The window socket apps in C:\ti\ndk_2_24_03_35\packages\ti\ndk\winapps recv.c and send.c both are prograamed as TcPIP client. when i am trying to run recv.exe (cmd: recv.exe 192.168.0.254 23 ) it is giving failed connect error 10060.
I am attaching the NIMU system overview
Is the configuration is correct. Hre telnet is selcted what dose this means?
Hi Garrett,
Why Tcp.transmitBufSize is set to 8192? Is there any specific reason.
Thanks,
Anjana Pathak
Anjana,
It doesn't have to be 8192 for Tcp.transmitBufSize, but we observed better throughput with it in ftp application, see e2e.ti.com/.../2002191
Regards,
Garrett
1. What should be TCP transmit buffer size for TCPIP communication protocol?
2. I am sending the data of length 1400 bytes on tcpip through a client application running on evmam572x target to a server application running on PC. I am getting different result(bytes Received) of recv() function in server app.i.e.
byte received:1400bytes
byte received:1300bytes
byte received:100bytes
byte received:1400bytes
byte received:1200bytes
byte received:100bytes
It should be of length 1400 bytes always.
3.Also Why i am getting TCPIP retransmission issue as shown in 
sorry i attached wrong slide.......
but if i want to transfer 2700 bytes in one packet in send command, the tcpip transmit buffer size will not effect the speed of transmission if the packets are repeatedly transmitted.
8192 is the minimum of TCP transmit buffer size?
Thanks,
Anjana Pathak