e01a040.PDF
(
333 KB
)
Pobierz
COM
PUTER
Personal
Mini Webserver (2)
Part 2: the first steps
There are so many different configurations of the SC12 that we only have
space here to cover the basic installation and operation of the Personal
Mini Webserver.
During programming and remote operation of
the Personal Mini Webserver, it is always
helpful to have the Internet site
http://www.bcl-online.de/documentation/
api/index.htm
on hand (
Figure 1
). This contains a
complete, up-to-date index of the
software documentation for the SC12
chip. For more in-depth information
on any of the procedures described
below, this documentation can
always be consulted.
Before the Personal Mini Web-
server can be programmed for its
final application, a few questions
need to be answered:
Is the circuit completely func-
tional?
How will the basic settings be
made?
How will files be transferred to the
Personal Mini Webserver?
How will the Personal Mini Web-
server be provided with a network
address?
Functional test
Once assembly of the Personal Mini
Webserver hardware has been suc-
cessfully completed, a full functional
test should be carried out. First con-
nect the Personal Mini Webserver to
a PC via connector K4 and a
null
modem
cable, and start a terminal
program. This could be HyperTermi-
nal, provided with Windows,
although in principle any terminal
software will work fine, as long as
the communications parameters are
set as follows:
19,200 bits/s
8 data bits
No parity
1 stop bit
40
Elektor Electronics
10/2001
COM
PUTER
format
and so on. The command
help
causes
RTOS to produce a list of all the available
commands, which are described in full, along
with all parameters, in ‘
COMMAND: Descrip-
tion of the command processor
’ at
www.bcl-
online.de/documentation/ api/command.htm
.
Simple I/O test
Next we check that the I/O ports of the SC12
are functioning correctly. The signals on con-
nector K6 correspond to I/O address 0x100,
while those on K7 correspond to address
0x101. On both connectors, the outputs are on
the even-numbered pins, and the inputs are
on the odd-numbered pins. The outputs can
readily be tested by connecting each pin in
turn to +5 V via an LED (and 1 kΩ series cur-
rent-limiting resistor).
In order to activate the ALE and CS signals
of the SC12, the following two commands can
be entered at the prompt:
PCS 1
ALE 1
The outputs can now be switched on and off
using the
OB
(OutByte) command. This com-
mand requires addresses and data in hexa-
decimal format. So, for example, in order to
write the decimal value 170 (or AAh) to con-
nector K6, the following command is required:
A:\OB 100 AA
Figure 1. Index of all documentation of the Application Program Interfaces of the
IPC@Chip.
which elicits the confirmation:
OB address=0x0100 data=0xAA
Table 1.
@CHIP-RTOS
Copyright (c) Beck 1999
SC12
Serialnumber=012BE
Bootstrap version 02.06
Bios version V1.00
LARGE_PPP
Build: May 4 2001
Starting TCPIP
Init network
Open ethernet packet
interface
PPP client
Config server
FTP server
Web server
Telnet server
Ext. disk interface.
No handshake
The
IB
(InByte) command behaves similarly.
The command
As usual, when the IPC@CHIP is
switched on, the LED should flash
three times: one long flash and then
two short. The first messages from
the webserver should appear on the
monitor (Table 1).
A:\IB 100
produces the result
IB 0x0100=0x00,
Press the ENTER key, and in the ter-
minal window you should see the
familiar line:
if all inputs are low.
A:\
Initialisation
Signals such as ALE and PCS, which are
required for LCDs, digital I/Os or other expan-
sion ports, can be activated immediately on
system start-up, either in an
autoexec.bat
file,
or in the file
chip.ini
.
In the first case, we simply require the two
lines
This looks just like a DOS prompt;
and indeed it is. In fact this is a DOS
clone called RTOS. Our readers of
more advanced years, who grew up
with DOS, will have no difficulty in
getting to grips with RTOS com-
mands such as
copy
,
md
,
cd
,
rd
,
del
,
10/2001
Elektor Electronics
41
COM
PUTER
is started, even if the program has
not exited. If this behaviour is not
desired, the following line can be
added to the start of the
autoexec.bat
file:
character R (receive) after the port
identifier COM (K4), indicates the
direction of data transfer. Next (and
without too much delay) the file
must be sent from the terminal pro-
gram using the XModem protocol.
For transfer in the opposite direc-
tion, from Personal Mini Webserver
to PC, the command
Example
CHIP.INI file
[STDIO]
STDIN = EXT COM
STDOUT = EXT COM
BATCHMODE 1
After this command all programs are
executed sequentially. Conversely,
the command
[IP]
ADDRESS=192.168.100.101
NETMASK=255.255.255.0
GATEWAY=192.168.100.254
XTRANS COM S TEST.TXT
BATCHMODE 0
is used. The second serial interface,
K3, has identifier EXT. Normally
(except when a BIOS update is being
carried out) this is where the modem
is connected in a PPP server config-
uration. The configuration and use of
this interface will be described in
more detail later.
[DEVICE]
NAME=WEBIO
allows for a semi-parallel execution
of programs.
Batch mode can also be config-
ured in
chip.ini
, with the two
lines:
[TELNET]
ENABLE=0
[UDPCFG]
LEVEL=0x00
[BATCH]
BATCHMODE = 1
[WEB]
ENABLE=1
MAINPAGE=MAIN.HTM
DRIVE=0
ROOTDIR=\WEB\
Network settings
The most important aspect of the
SC12 is the network connection. For
our first experiments it is easiest to
use Ethernet, since it is fast and
easy to use. To construct the net-
work, all that is required is a
crossover twisted-pair cable with
RJ45 connectors (or two cables and
a hub) and an Ethernet card in the
PC. The Ethernet driver in the SC12
is only compatible with the ‘slow’
10Base-T Ethernet standard, and so
in principle a 10Base-T card will be
adequate. If, however, you are buy-
ing a new Ethernet card, you might
as well purchase a faster 100Base-T
version, since they only cost about
thirty pounds.
We will consider here an existing
network with the following IP set-
tings:
Figure 2
shows a more complete
example of a chip initialisation file.
[FTP]
ENABLE=1
USER0=FTP
PASSWORD0=FTP
Local data transfer over
the COM port
The SC12 chip boasts a flash disk
which is known to DOS as drive A:.
There are two methods available for
transferring data between the Per-
sonal Mini Webserver and the PC,
either over the network connection
or via the COM interface.
The XTRANS command is used to
transfer files over the serial COM
interface. The communication uses
the well-known XModem protocol,
which is available as standard on
most terminal programs. For exam-
ple, to transfer the file
test.txt
from
the PC to the Personal Mini Web-
server, the command
[TELNET]
ENABLE=1
USER0=TEL
PASSWORD0=TEL
Figure 2. A chip initialisation file such as this
contains the basic settings of the Personal Mini
Webserver.
PCS 1
ALE 1
in
autoexec.bat
. If
autoexec.bat
is not
present, for example after a BIOS update, a
suitable file can be created using a text edi-
tor and sent to the SC12 using the XModem
protocol with the terminal program.
Chip.ini
can be compared with the con-
fig.sys file in a DOS system. This text file con-
tains all the settings which the SC12 requires
at start-up. At system start,
autoexec.bat
is
the file processed first. The most significant
difference between the SC12’s operating sys-
tem and ‘normal’ DOS is that DOS is at root a
single-tasking operating system, while the
SC12 always operates by default in multi-
tasking mode. For that reason the prompt
always returns very quickly after a program
IP Adress:
192.168.100.100
Subnet Mask:
255.255.255.0
XTRANS COM R TEST.TXT
is given at the RTOS prompt. The
Table 2.
A:\DHCP 0
Disable automatic network
configuration
A:\IP 192.168.100.101
Set IP address...,
A:\Netmask 255.255.255.0
... net mask...
A:\Gateway 192.168.100.254
... and gateway address
A:\IPETH
Activate new settings
42
Elektor Electronics
10/2001
COM
PUTER
with the command
A:\IPCFG
and obtain the values:
IP=192.168.100.101
Netmask=255.255.255.0
Gateway=192.168.100.254
DHCP=0
MAC= 00 30 56 F0 12 BE
The last line gives the hardware address of
the internal Ethernet controller and cannot be
changed. These settings can also be applied
using Chiptool (
Figure 3
) or, if preferred, as
commands on
autoexec.bat
or entries in
chip.ini
.
Once the Personal Mini Webserver is con-
nected to a network, the connection can be
tested using PING, which is part of RTOS. It
is very easy to use:
Figure 3. Configuration of the IP address using Chiptool.
A:\PING 192.168.100.100
This causes PING to send data from the SC12
to the specified network address (in this case
to the PC). The same can be done from the PC
end, using the PING command, which,
although a DOS program, is provided as part
of Windows (
Figure 4
). Here, of course, the
network address of the Personal Mini Web-
server, and not of the PC, must be specified.
If this all goes well, this indicates that com-
munication has been successfully estab-
lished.
The settings can, as we said above, also
be entered in
chip.ini
, for example as fol-
lows:
work to which the Personal Mini
Webserver is connected, and the
address of the gateway (if present).
The gateway allows devices on dif-
ferent networks to communicate
with one another.
First we enter the settings manu-
ally at the RTOS prompt, as shown in
Table 2.
Gateway:
192.168.100.254
The TCP/IP configuration of the Eth-
ernet card can be found in the Sys-
tem Settings under Network. The
next address after the quoted ‘IP
Address’ (i.e. 192.168.100.101) can-
not already be assigned to a device
on the network.
Before the Personal Mini Web-
server can communicate over the
Ethernet, a number of addresses
must be set. These are its own net-
work address, the address of the net-
To confirm the settings, reply to the
message
Reconfigure IP ethernet -
ok
[IP]
ADDRESS=192.168.100.170
NETMASK=255.255.255.0
GATEWAY=192.168.100.254
DHCP=0
FTP server
Several protocols are built into the SC12 to
enable easy handling of network traffic.
Files can be transferred not only using the
XTRANS command, but also, as might be
expected for a webserver, over the TCP/IP
network using the File Transfer Protocol
(FTP). All that is required is an FTP client,
such as is available in any Windows system
and which can be started using the FTP com-
mand in a DOS window. This command-line
oriented program is, however, not exactly
user friendly. If you are planning to use FTP
extensively, a graphics-oriented program
such as the universally-used WS-FTP pro-
Figure 4. Ping on the PC.
10/2001
Elektor Electronics
43
COM
PUTER
char tmpbuffer[180];
/**********************************/
//building the page
/**********************************/
//insert the head of the page
strcpy(HtmlPage,PageHead);
//append the given request arguments
sprintf(tmpbuffer,”<BR>Method : %02d<BR>”,CgiRequest->fHttpRequest);
strcat(HtmlPage,tmpbuffer);
sprintf(tmpbuffer,”<BR>Url : %s<BR>”,CgiRequest->fPathPtr);
strcat(HtmlPage,tmpbuffer);
sprintf(tmpbuffer,”<BR>Host : %s<BR>”,CgiRequest->fHostPtr);
strcat(HtmlPage,tmpbuffer);
sprintf(tmpbuffer,”<BR>Referer :
%s<BR>”,CgiRequest->fRefererPtr);
strcat(HtmlPage,tmpbuffer);
sprintf(tmpbuffer,”<BR>User Agent :
%s<BR>”,CgiRequest->fAgentPtr);
strcat(HtmlPage,tmpbuffer);
sprintf(tmpbuffer,”<BR>Content :
%s<BR>”,CgiRequest->fLanguagePtr);
strcat(HtmlPage,tmpbuffer);
sprintf(tmpbuffer,”<BR>User :
%s<BR>”,CgiRequest->fUserNamePtr);
strcat(HtmlPage,tmpbuffer);
sprintf(tmpbuffer,”<BR>Password :
%s<BR>”,CgiRequest->fPasswordPtr);
strcat(HtmlPage,tmpbuffer);
if(strlen(CgiRequest->fArgumentBufferPtr))
{
sprintf(tmpbuffer,”<BR>Arguments:
%s<BR>”,CgiRequest->fArgumentBufferPtr);
}
else
{
strcpy(tmpbuffer,”<BR>No arguments<BR>”);
}
strcat(HtmlPage,tmpbuffer);
//append the predefined tail
strcat(HtmlPage,PageEnd);
44
Elektor Electronics
10/2001
Plik z chomika:
TirNaNog
Inne pliki z tego folderu:
bge.jpg
(26 KB)
detail11.htm
(6 KB)
detail1.htm
(5 KB)
detail10.htm
(4 KB)
e011016.PDF
(1901 KB)
Inne foldery tego chomika:
1974
1975
1976
1977
1978
Zgłoś jeśli
naruszono regulamin