Quality ready made and affordable custom software



PHP Serial
Easy Control
Rack Designer

Quick Texts
Wallpaper Slideshow


All articles
WS2300 weather station PHP project
Your own terminal in 17 lines
PC PIC Voltmeter
Network messenger in 22 lines
Phone Dialer




Copyright 2001-2024
© Cosmin Buhu

  Network link

Linking a microcontroller with a PC over a complicated network

Example for TCP/IP and serial communications.

In this article I will show how I established a link over a pretty complicated network from
my home PC to a microcontroller connected on a serial port of a PC in my office. This link
involves 4 different kinds of data transfers. Take a look:
My home PC is connected through dial-up to my ISP. At office I have a Linux server connected
with a leased line to the ISP.The office PC is on an internal ethernet branch and has a microcontroller
connected on COM1.

Let see one by one:

Home PC: On this PC I run Easy Control version 1.4 with this little script.
Very simple, listen on port 8090 and it transmits a query to the microcontroller, wait for the response,
send query again, and again... See below what the microcontroller does when it receives this query.
Please note: because I have a dynamic assigned IP address I must include this address in the query,
at the other end this address will be extracted and used to send responses.
Also note that the query will be sent to the Linux machine see below why. The format of the query is:
"IP port queryCRLF"
For testing purposes the script saves received data in a file.

ISP: Nothing to say, they do their job :)

Linux server: (at the office) It has a nice redir software, all data received from the ISP on
port 8090 is redirected to the internal PC. Also it acts as a masquerade machine, all internal PCs has
Internet access through it.

Internal PC (at the office): Again Easy Control, with this script.
It is a bidirectional TCP/IP to serial bridge.
Note the script part that extracts the remote address IP and the query.

Microcontroller: when it receives the "?ic" query it increments an internal 8 bits
counter and sends the counter value in this form:
"c valueCRLF"

This is a working example, I had a good and stable link, with 1-2 readings per second.
Of course there are other things to do, implementing timeouts, error checking and correction,
the microcontroller can do a lot more useful jobs, etc. But this is an example, just to start with.