The GP3 is perfect if you want to control or sense the real world from a PC. But the RS232 connection (or USB connection) means that you have to be right next to the part of the world you want to sense, right? Wrong! In this article I'll show you how to use open source tools to connect to a remote PC with a GP3 attached and take control of it. You can use this technique with any of the GP3 libraries or the GP3EZ software.

The basic idea is that we will use com0com, an open source project to create a TCP "server" connected to the GP3's com port. Then we'll use com0com to make a pair of fake ports on the remote PC. One of these fake ports will connect to the GP3 software you want to use. The other fake port will connect to a network client that talks to the server. It sounds more complicated than it is. You need to download com0com and com2tcp from Sourceforge. You might as well install both programs on your client and server machines, although you could get by with just com2tcp on the server if you like.

There is a pretty detailed setup document available, so I won't repeat it step by step. However, here's the basic steps you'll follow (remember, the server has the GP3 connected to it; the client is the remote machine where you want to run the software):

  1. Install com0com on (at least) the client machine. It will offer to make two COM ports for you named CNCA0 and CNCB0. You can allow this, although you'll have to rename them before you are done.
  2. Install com2tcp on both machines. There isn't really an install program (at least not as of version 1.3). You just put the executable somewhere that you can find it.
  3. On the client machine run the com0com setup. Either add a new pair of ports or use the ones that were installed. However, they have to be renamed to be COMXX where XX is some number of your choice (just change the names in the boxes up near the top of the setup program; see the figure below). I used COM90 and COM91 (see below).
  4. Open a command prompt on the server (don't use the Cygwin shell). Run this command:
    com2tcp --telnet --ignore-dsr --baud 57600 \\.\com1 3141
    (Note: You can use any port number, I chose 3141 at random (well, its pi). If you have firewall software or hardware you'll need to open this port for TCP traffic. The example assumes the GP3 is on COM1. If not, change com1 to whatever is right).
  5. Open a command prompt on the client (again, don't use Cygwin). Run:
    com2tcp --telnet --ignore-dsr -baud 57600 \\.\com91 SERVER 3141
    (Note: use the IP address or host name of your server instead of SERVER. The 3141 needs to match the port you used on the server. I'm assuming you named your ports COM90 and COM91 like I did)
  6. Run any software that uses the GP3. For example, GP3EZ. Set its port to use COM90 (assuming you are following the example).

    The setup for the ports ought to look like this:

    Notice the boxes near the top that say COM90 and COM91? That's where you rename the ports. I checked a few of the boxes, but they aren't strictly required. If you let your mouse float over them in the setup program you can read what they do. The com0com software is pretty powerful. You can reroute handshaking signals using this dialog but the defaults are perfect for what we want to do.

    That's it! You can now remotely sense temperatures, operate valves, or do anything else you can do with a GP3 over the network.


Site contents © 1997-2018 by AWC, Houston TX    (281) 334-4341