Serial port forwarding

From RoboCup

Jump to: navigation, search


We now have several Cerebot devices, and for each of them we also have the wireless BlueTooth module Bluesmirf and a cable so that we can see the debugging information printed on the screen and interact with a program running on the Cerebot from a PC remotely. Normally, this works as follows:


However, we only have two USB BlueTooth dongles - the devices that allow PC workstations to communicate with the BlueTooth modules connected to Cerebot boards. However, we want to connect to BlueTooth modules from all PC workstations, including those that do not have USB dongles connected. The PC workstations are all connected using TCP/IP network:


What we need is a small utility that will connect to BlueSmirf module using the BT dongle, and forward the sent and received data to the network and back to the BT virtual serial port. In this way, we will be able to connect to BlueTooth modules from all PCs, and in fact one BT dongle will be sufficient.

An easy solution would be using Linux operating system, which can connect to all BT modules, and terminal program for connecting to the Linux workstation from the remaining PCs running Windows (our current development platform). However, this will require that one of the PCs will be permanently in Linux and cannot be used as development workstation.

Since we found no freeware utitilies for Windows that provide this functionality, we implemented our own console utility.

COM2TCP utility

The use of the utility is very simple. On the machine with the BlueTooth Dongle, we first install the virtual serial ports for all BlueTooth devices we want to connect in a usual way. Then, from the command window, we run the utility, for example to publish the serial port COM6 to be accessible as TCP/IP port 1234, we would run:

com2tcp -s COM6 1234 -t

From another - remote machine, we can then communicate with the port by running (for example, if the IP address of the first machine is

com2tcp -c 1234

At this point of time, the COM6 will be open, and we are talking directly to the device connected to the COM6 (for example Cerebot's UART1).

The following picture explains the situation:


To stop communicating, we can press the CTRL-Z (or even CTRL-C), and the connection (and the COM6 port) will be closed. Nothing needs to be done on the server, and we can connect the same way again, and again.

If you prefer to have a program talking to your Cerebot instead of interactive communication using command window, you can start a program with its standard input and output connected to the remote port as follows:

com2tcp -c 1234 -e your_app.exe argument1 argument2...

This will execute your_app.exe. When your_app.exe will be reading from standard input, it will in fact read data from the remote COM6 port, and similarly, when printing data on its standard output, the data will be instead sent to the remote COM6 port.

The following picture depicts this configuration:



The source-code and WIN32 executable is available for download here: (54 KB). See also: readme.txt file.


Please send your feedback to Pavel at ppetrovic Image:zavinac.gif

Personal tools