AnsweredAssumed Answered

MQX:Ethernet to serial bridge application communication on TWRVF65GS10 starter kit module fails

Question asked by manjug on Aug 28, 2013
Latest reply on Aug 30, 2013 by UK_CF_FAE
Branched to a new discussion

Hi all,

I have purchased TWRVF65GS10 starter kit which includes tower-primary and secondary boards along with main board(TWRVF65GS10) and one TWR-SER peripheral board(Ethernet-fixed mac address,serial,CAN and USB) plugin modules.

 

I imported the Ethernet to serial example application from rtcs folder and built completely and made to run on tower module(TWRVF65GS10 which has TWR-SER peripheral board attached to tower system) and tried to communicate from my PC communication failed at 'n' times.I have connected cross cable RJ-45 between my PC and tower system and connected at 100Mbps.

 

Then i created simple TCP server application below is the code :

#define ENET_IPADDR  IPADDR(192,168,1,224)

  #define ENET_IPMASK  IPADDR(255,255,255,0)

  #define ENET_IPGATEWAY  IPADDR(0,0,0,0)

 

  sockaddr_in localaddr, remote_addr;

  uint_16 remote_addr_len=sizeof(remote_addr);

  uint_32 sock, listensock;

  int_32 length;

  char buffer[]={0};

  uint_32 buffer_len=sizeof(buffer);

  uint_32 error;

  char* cmd;

  int_32 error;

  IPCFG_IP_ADDRESS_DATA ip_data;

  _enet_address enet_mac_address={0x00,0x04,0x9F,0x01,0x65,0xE3};

 

  /* Initialize RTCS */

  _RTCSPCB_init = 4;

  _RTCSPCB_grow = 2;

  _RTCSPCB_max  = 8;

    _RTCSTASK_stacksize = 4500;

 

    error = RTCS_create();

  if (error== RTCS_OK)

  {

  ip_data.ip = ENET_IPADDR;

  ip_data.mask = ENET_IPMASK;

  ip_data.gateway = ENET_IPGATEWAY;

  printf("ip_data INTIALISATION COMPLETE IP=%X\n",ip_data.ip);

  _IP_forward = TRUE;

 

 

  error = ipcfg_init_device (BSP_DEFAULT_ENET_DEVICE, enet_mac_address);

  if (error != IPCFG_OK)

  {

  printf("IPCFG: Device init failed. Error = 0x%X\n",error);

  _task_set_error(MQX_OK);

  }

  error = ipcfg_bind_staticip (BSP_DEFAULT_ENET_DEVICE, &ip_data);

 

 

  if (error != IPCFG_OK)

  {

  printf("IPCFG: Failed to bind IP address. Error = 0x%X\n", error);

  _task_block();

  }

  }

 

 

  /* Create a stream socket: */

  localaddr.sin_family = AF_INET;

  localaddr.sin_port = IPPORT_TELNET;//

  localaddr.sin_addr.s_addr = INADDR_ANY;

 

  listensock = socket(PF_INET, SOCK_STREAM, 0);

  if (listensock == RTCS_SOCKET_ERROR) {

  printf("Failed to create the stream socket\n");

  _task_block();

  }

 

 

  /* Bind the stream socket to a TCP port: */

  error = bind(listensock, &localaddr, sizeof(localaddr));

  if (error != RTCS_OK) {

  printf("Failed to bind the stream socket - 0x%lx\n", error);

  _task_block();

  }

 

 

  /* Set up the stream socket to listen on the TCP port: */

  error = listen(listensock, 0);

  if (error != RTCS_OK) {

  printf("listen() failed - 0x%lx\n", error);

  _task_block();

  }

  printf("TCP Server is active on port %2d.\n",IPPORT_TELNET);

 

 

  /* Connection requested; accept it.*/

  memset(&remote_addr, 0, sizeof(remote_addr));

  sock = accept(listensock, &remote_addr, &remote_addr_len);

  if (sock == RTCS_SOCKET_ERROR) {

  printf("\n accept() failed, error 0x%lx",

  RTCS_geterror(listensock));

  _task_block();

  }

 

  printf("Connected to %d.%d.%d.%d:%d",IPBYTES(remote_addr.sin_addr.s_addr),remote_addr.sin_port);

 

  while(1)

  {

  /* socket received data.*/

  length = recv(sock, &buffer, buffer_len, 0);

  if (length == RTCS_ERROR){

  printf("\nError %x receiving from %d.%d.%d.%d,%d",RTCS_geterror(sock), IPBYTES(remote_addr.sin_addr.s_addr),remote_addr.sin_port);

  }

  printf("\n Received %ld bytes of data", length);

  }

 

I builded above code and did ddr-debug same ethernet communication problem not able to reply for ping command and telnet program also.please help me on this

Outcomes