/*
e2s (c) 2009-always Jan Panteltje

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/



e2s is a small server that provided an internet interface to a serial device.
port, baudrate, and serial device name is selectable from the command line. 


It is possible to run an e2s server for each serial device on different internet ports:

e2s -d /dev/ttyUSB1 -b 19200 -p 8192 
e2s -d /dev/ttyS0   -b 1200  -p 8193 


You can then connect to the server from anywhere over the internet,
The idea is that you write a special application for that.
But it can be tested with telnet in a simple way:

 telnet IP_ADDRES_OF_SERVER 8192

Once connected with telnet, type:
control ]
mode char

Now you have a 1 to 1 connection to /dev/ttyUSB1 as in the above server example.
The connection is 2 ways, the behaviour is pretty much the same as when using telnet
to the server and starting a terminal program.

This was written to remotely control home automation and a radio station.
It is possible to connect from more then one point.
I am not sure what happens then, the last one who types has control :-)

You can log output by redirecting stderr like this:
 e2s -d /dev/ttyUSB1 -b 19200 -p 8192 2>> e2s_log.txt


Restarting the server:

When a fatal error occurs the server will exit.
You can make a script with a retry loop this way:
while true ; do ; e2s -d /dev/ttyUSB1 -b 19200 -p 8192 2>> /root/e2s_ttyUSB1_log  ; sleep 60 ; done &


Compiling for MIPS architecture.
If you have the Linksys source code and compiler installed for the WAP-54-G wireless access point,
then in the Makefile, change the definiton for CC to this:

#CC = gcc
CC = /opt/brcm/hndtools-mipsel-uclibc-3.2.3/bin/mipsel-uclibc-gcc
When compikling with the sources from teh Linksys WAP 54G,
perhaps also comment out the strip statement, and uncommwent the define in e2s.h
Then type 
make

For compiling the mips version on the Linksys WAP, you may want to comment out the call to 'set_port_parmeters(...)' in e2s.c,
as I found that that on my Linksys system causes a segfault.
There is a define for that in e2s.h
Then use the default baudrate of 19200.


