# using a tcp port in RCM5700

**URL:** <https://forums.digi.com/t/using-a-tcp-port-in-rcm5700/9372>\
**Category:** Rabbit\
**Created:** [August 9, 2009, 7:09pm UTC](https://forums.digi.com/t/using-a-tcp-port-in-rcm5700/9372 "2009-08-09T19:09:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![guachi](https://avatars.discourse-cdn.com/v4/letter/g/f4b2a3/32.png) [@guachi](https://forums.digi.com/u/guachi)\
**Post date:** [August 9, 2009, 7:09pm UTC](https://forums.digi.com/t/using-a-tcp-port-in-rcm5700/9372/1 "2009-08-09T19:09:37Z")

</div>

HI:  
I need to do a project where I obtain some data in the port RS-232 and I have to send that data from the TCP-IP using the RCM 5700 to a LAN,

The first thing that I`m trying is to stablish a communication within the RCM5700 and the PC, but I still getting bad results… if anyone can help me with this project I really apreciate it… 😉

---

<div class="post-metadata">

**Author:** ![tmorton](https://avatars.discourse-cdn.com/v4/letter/t/df788c/32.png) [@tmorton](https://forums.digi.com/u/tmorton)\
**Post date:** [August 13, 2009, 5:45pm UTC](https://forums.digi.com/t/using-a-tcp-port-in-rcm5700/9372/2 "2009-08-13T17:45:02Z")

</div>

Several of the samples that ship with Dynamic C do exactly this. Take a look at Samples\RCM5700\TCPIP\ethernet\_to\_serial.c for a complex example of how to do it.

If you need just a serial-to-ethernet bridge (and none of the fancy web stuff), just use the vserial library. Here’s an example of how I use it:

```auto

#define TCPCONFIG 1

#define _PRIMARY_STATIC_IP "10.10.8.4"
#define _PRIMARY_NETMASK "255.255.255.0"
#define MY_GATEWAY "10.10.8.2"
//other TCP settings

#define VSERIAL_DEBUG
#define VSERIAL_NUM_GATEWAYS 2 // forward two serial ports

#define SERE_TXPORT PEDR // serial port E requires custom configuration
#define SERE_RXPORT PEDR

#use "dcrtcp.lib"
#use "vserial.lib"
#use "rcm56xxw.lib" // i'm using the RCM5600W, modify as needed

#define GATEWAY_PORTE 1
#define GATEWAY_PORTD 2
#define EINBUFSIZE 511
#define EOUTBUFSIZE 511

// configuration table for vserial
const VSerialSpec VSerialSpecTable[] = {
   VSERIAL_PORTE(GATEWAY_PORTE),
   VSERIAL_PORTD(GATEWAY_PORTD)
};

void main(void) {
   int bad;
   brdInit();

   // these may not be necessary for your board and/or may be different
   BitWrPortI(PCDDR, &amp;PCDDRShadow, 0, 3); // set serial port C Rx as input
   BitWrPortI(PCDDR, &amp;PCDDRShadow, 0, 1); // set serial port D Rx as input
   BitWrPortI(PEDDR, &amp;PEDDRShadow, 0, 7); // set serial port E Rx as input
   BitWrPortI(PEDDR, &amp;PEDDRShadow, 1, 6); // set serial port E Tx as output

   sock_init_or_exit(1);

   if (vserial_init()) {
   	printf("Error starting vserial library
");
      exit(-1);
   }

   // vserial_listen allows the computer to open a telnet connection
   // on port 2000. use vserial_open() if you want the rabbit to establish
   // a connection to a running server.
   if (vserial_listen(GATEWAY_PORTE, 19200, 2000, 0L, 1)) {
   	printf("Error opening on port E");
      exit(-1);
   }

   if (vserial_keepalive(GATEWAY_PORTE,10)) {
   	printf("Error setting vserial keepalve!
");
      exit(-1);
   }

   if (vserial_listen(GATEWAY_PORTD, 19200, 2001, 0L, 1)) {
   	printf("Error opening on port D");
      exit(-1);
   }

   if (vserial_keepalive(GATEWAY_PORTD,10)) {
   	printf("Error setting vserial keepalve!
");
      exit(-1);
   }

   while(1) {
   	vserial_tick();
   }
}

```

Hope that helps!

- Taj

---

<div class="post-metadata">

**Author:** ![guachi](https://avatars.discourse-cdn.com/v4/letter/g/f4b2a3/32.png) [@guachi](https://forums.digi.com/u/guachi)\
**Post date:** [August 13, 2009, 5:56pm UTC](https://forums.digi.com/t/using-a-tcp-port-in-rcm5700/9372/3 "2009-08-13T17:56:19Z")

</div>

Thank you tmorton… that exactly what I need to do…Today I will try the code and if I have some cuestions I will ask again… I apreciate your help…Guachi

---

<div class="post-metadata">

**Author:** ![guachi](https://avatars.discourse-cdn.com/v4/letter/g/f4b2a3/32.png) [@guachi](https://forums.digi.com/u/guachi)\
**Post date:** [August 16, 2009, 5:20pm UTC](https://forums.digi.com/t/using-a-tcp-port-in-rcm5700/9372/4 "2009-08-16T17:20:41Z")

</div>

I have another question… Where did you use the code that you send me… I’m trying to prove it but I still without having any result…what i need to do is: receive some data from 4 parameters of a power transformer and sending over ethernet where another program(labview) will receive the information and analized it… if you have some ideas I will apreciate them…

---

<div class="post-metadata">

**Author:** ![tmorton](https://avatars.discourse-cdn.com/v4/letter/t/df788c/32.png) [@tmorton](https://forums.digi.com/u/tmorton)\
**Post date:** [August 17, 2009, 9:58pm UTC](https://forums.digi.com/t/using-a-tcp-port-in-rcm5700/9372/5 "2009-08-17T21:58:36Z")

</div>

I used the program to take data from underwater sensors and output it to a telnet client (I used Teraterm).

I’d try running the Samples\RCM5700\TCPIP\ethernet\_to\_serial.c sample program and see if that does what you want, since it was written explicitly for your board.

- Taj
