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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1,150 Views
manjug
Contributor III

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

Labels (1)
0 Kudos
3 Replies

470 Views
UK_CF_FAE
NXP Employee
NXP Employee

Hi Manju G, sorry to hear that you are having problems. Normally RTCS gets up and running with very few problems. Lets try and get you working.

First question - when the cross-over cable is connected, do you get any LED illuminated on the RJ45 connector on the TWR-SER board? There are 2 LEDs - a speed and a newtork LED. With a cross-over cable you should see some LEDs on. Did you check the cable? I've had some TWR-SER boards with faulty cables - they are very cheap.

Did you try setting the gateway IP address? I assume that your PC has a static IP address in the 192.168.1.x domain. When I run RTCS training I always set up the PC for 192.168.0.2 and the TWR board to 192.168.0.3 but the exact IP addresses should not matter, as long as PC and TWR board are in the same domain. Your IPMASK is FF:FF:FF:00 and so the PC and TWR must have 192.168.1.x matching.

Get WireShark and snoop the IP network from your PC - you'll quickly see what traffic is happening on your network. As PING is not working, it is going to be something very fundamental and basic.

Mark

0 Kudos

470 Views
manjug
Contributor III

Hello Mark,

Thanks for reply.

Ans:LEDs keep blinking after connecting my cross cable without loading code.After loading code orange LED is on and green LED keeps blinking.

IP of my PC is static and i configured to 192.168.1.223  and my Board to 192.168.1.224 when i connected directly my PC to board through cross cable.

I connected my PC to router switch and my board too with straight cable and I verified the network activity through wireshark but my board IP 192.168.1.224 is not available in network.

Problem persists for both example code and my simple server application.

0 Kudos

470 Views
UK_CF_FAE
NXP Employee
NXP Employee

Please share with me all the jumper settings on the TWR-SER board, particuclarly J12. I've had those RTCS examples working on Vybrid tower board, so I think that it is somthing easy to fix.

0 Kudos