Simulating
the Sweex "web page to serial port control" using a Linux PC
WARNING - UNSUPPORTED CODE!!!
The following is based, with thanks, on software published by J
Domburg under GPL for the Elektor Magazine projects of February and March
2006 and modified by a Linux expert to whom I am very grateful and with whom
I am in email contact but who prefers to remain anonymous on the Web.
This note and associated files are provided to give those not yet expert in Linux the chance to build and test web pages that can be used to send data strings to the serial port and so control external circuits.
The author cannot offer support and I ("Sunspot") am not yet a Linux expert. The notes and software are offered for experiment and in the hope that those more expert than I am will offer to help me and other new users to experiment with the code. Please use the forum for this debate.
INSTRUCTIONS
(this is what I did so I include my own directory name "graham" in
the home file - please modify for your system)
This note tries to use the Linux Gnome GUI desktop whenever possible and assumes
the reader has only just started to learn Linux.
Obtain a copy of Busybox (busybox-1.1.0-pre1.tar.bz2) from
http://www.busybox.net/downloads/busybox-1.1.0-pre1.tar.bz2
and rs232ws.tgz from here
I did the download with
my Mac and used a memory stick (standard FAT file structure) to transfer the
files to the Linux PC
I installed Fedora Core (free version of Red Hat Linux) on an old 6Gig hard
disk at IDE0 on a 386 PC
(I use a cassette system to let me change the root hard dive quickly from Linux
to Windows 2000
- an Ebuyer Extra Value Hard Drive Plastic Caddy with 2 Fan and Lock £3.39
+VAT)
Open Linux with Gnome desk top
log in as root to avoid file permission problems
(but only do this if you are prepared to lose all your files and the civilized
world as we know it - I only use Linux for this task so can afford to re-install)
Create a folder named graham (in my case) in the home folder (right click on
the open home folder)
Plug in the memory stick - you have to double click on it in the Computer folder
- Gnome says it can't mount it but then mounts it OK on the desk top
Create a new folder temp in the graham folder
Drag rs232ws.tgz into temp
Right click on rs232ws.tgz and "extract here"
you get a folder "rs232ws.tgz_FILES"
inside it find a folder "rs232ws" drag this into graham
Open temp again, empty it of files
drag "busybox-1.1.0-pre1.tar.bz2" into temp.
Right click on "busybox-1.1.0-pre1.tar.bz2" and "extract here"
open the new folder "busybox-1.1.0-pre1.tar.bz2_FILES"
drag folder "busybox-1.1.0-pre1" into "/home/graham/rs232ws/"
Delete the temp folder.
Now open Applications / System Tools / Terminal
(if you are a Mac user try to smile and look like this is fun - The Linux experts
say it will be one day -
Windows user enjoy pain, so no problem for you).
Type in
cd /home/graham/rs232ws/busybox-1.1.0-pre1 (return)
gmake menuconfig
You see a pretty menu headed "BusyBox Configuration"
Scroll down (with the arrow key) to
"Networking Utilities" (below the bottom of the screen)
<select> it
scroll down to "httpd" and push the "Space Bar" to select
it ([*]).
leave the options that appear as they are
than, <exit> this window ("Tab" key), and
back in the "BusyBox Configuration" window, <exit> again and
select <Yes>.
That's all for the configuration (Busybox loads the defaults PLUS httpd)
type
gmake (Return)
loads of stuff scrolls up
type
gmake install (Return)
loads of stuff scrolls up again
You now have a new folder
/home/graham/rs232ws/busybox-1.1.0-pre1/_install/bin
look at it in the GNOME desktop
and at
/home/graham/rs232ws/busybox-1.1.0-pre1/_install/usr/sbin
where there is a file "httpd"
Open the window /home/graham/rs232ws/src
and open Makefile in the text editor
modify - about line 6 BBR := etc to the correct path to "busybox-1.1.0-pre1"
also - about 12 lines from
the end add a # to comment out the line starting
@xterm -title etc to get the data strings to come out of COM1
otherwise they go to a terminal on the screen
Build the
code
cd /home/graham/rs232ws/src
type
gmake
this will compile/link htrs232io and htrs232dev
Try it out
type
gmake starthttpd
Then in a browser
http://yourhost:8080 in my case http://192.168.0.204:8080
Stop the server with
gmake stophttpd
If you want to see the web pages from another PC on your LAN you may have to turn off the firewall that seems to be a default in Fedora Core
type
/etc/init.d/iptables stop
You need a cross over RS232 cable from COM1 on the Linux box to Com1 on a second
PC running Windows and Hyperterminal
set 9600Baud/8 Data bits/No parity/One stop bit/No flow control
A note based on an email from the author
The source is set-up to use the
"emulation device", you cannot get your
data to the serial port without some
small mods
A 3 wire RS232 cable works
Do the following test:
First stop the httpd server (gmake stophttpd)
than "cd /home/graham/rs232ws/busybox-1.1.0-pre1/_install/bin" and
check that
htrs232io is there:
"file htrs232io" should give you
htrs232io: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for
GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped
than do:
echo /dev/ttyS0 > /tmp/rs232dev (this
creates a text file called rs232dev containing only /dev/ttyS0)
this file will be read by htrs232io to know which serial port to use.
than do:
./htrs232io test
and if you see test on your Hyperterminal it will mean that htrs232io
does it's job.
Don't forget, this file will be overwritten by the htrs232dev when you
launch it with (gmake starthttpd).
You must edit the Makefile and "comment out" the line
@xterm -title 'htrs232dev' -e $(BBR)/bin/htrs232dev &
to avoid that.
Now modify for your own use and please copy to me with lots of comment lines!
To help me improve this
note please email
me
- but for support use the forum
if I can help
there I will but it is more likely that someone else will!