Programmers Guide6500
Programmers Guide6500
CoBox
Version 6500
05-17-2007
Contents
Before starting
Hardware requirements........................................................................................................7
Software requirements .........................................................................................................7
General
CPK Introduction.................................................................................................................8
CoBox Family......................................................................................................................8
CoBOS Introduction ............................................................................................................8
CoBOS Tasks ......................................................................................................................8
CoBOS Serial Channel Control ...........................................................................................9
Steps to writing and checking CoBox programs..................................................................9
Hardware Overview
10
Hardware ...........................................................................................................................10
Chipsets ...............................................................................................................10
CPU Register Usage ............................................................................................11
Memory Maps....................................................................................................................12
DSTni Based Products.........................................................................................12
RAM3..................................................................................................................16
RAM2..................................................................................................................16
RAM1 (64 Kbytes) ..............................................................................................16
RAM0 (lower 64 Kbytes)....................................................................................16
XPort & Micro-100 Serial Flash Page Map ........................................................17
TFTP Firmware area............................................................................................17
Programming Environment
18
Operating System...............................................................................................................18
Directory Structure ............................................................................................................18
Environment Variables ......................................................................................................18
Compiling ..........................................................................................................................19
Compiler..............................................................................................................19
Libraries ..............................................................................................................19
Makefile ..............................................................................................................19
Version File (VERSION) ....................................................................................19
Linker File (.LK) .................................................................................................20
Batch Files (.BAT) ..............................................................................................20
Make Commands.................................................................................................20
Firmware Support of various Products and Password .........................................21
Restrictions..........................................................................................................21
Programming .....................................................................................................................22
Multitasking.........................................................................................................22
Watchdog ............................................................................................................22
How to Send a Ping .............................................................................................23
TCP Connections.................................................................................................24
How to open, close and re-open sockets..............................................................24
UDP Data Transfer ..............................................................................................25
Queues / FIFOs....................................................................................................26
2 Before starting
Timer ...................................................................................................................27
LED Control ........................................................................................................27
Tasks....................................................................................................................27
Streams ................................................................................................................28
HTTP Server Control ..........................................................................................28
Hardware Detection.............................................................................................28
Debugging .........................................................................................................................29
Serial Port............................................................................................................29
Syslog ..................................................................................................................30
UDP.....................................................................................................................30
ProMon................................................................................................................31
Telnet...................................................................................................................31
How to upgrade a project from 4.3 to 4.5 ..........................................................................31
Changes in the programming environment..........................................................31
How to upgrade a project from 4.5 to 5.0 ..........................................................................32
Changes in the programming environment..........................................................32
How to upgrade a project from 5.0 to 5.2 ..........................................................................33
Changes in the programming environment..........................................................33
How to upgrade a project from 5.2 to 5.5 ..........................................................................34
Changes in the programming environment..........................................................34
How to upgrade a project from 5.5 to 5.51 ........................................................................34
Changes in the programming environment..........................................................34
How to upgrade a project from 5.51 to 5.8 ........................................................................35
Changes in the programming environment..........................................................35
How to upgrade a project from 5.8 to 6.1 ..........................................................................35
Changes in the programming environment..........................................................35
How to upgrade a project from 6.1 to 6.5 ..........................................................................36
Changes in the programming environment..........................................................36
Additional Notes................................................................................................................37
Library Functions ................................................................................................37
Tools....................................................................................................................37
Input and Output Functions ...............................................................................................38
FlushIn.................................................................................................................38
fprintf...................................................................................................................38
getch ....................................................................................................................38
get_int..................................................................................................................38
get_ips .................................................................................................................38
gethex ..................................................................................................................39
gethex8 ................................................................................................................39
getint....................................................................................................................39
getint8..................................................................................................................39
getip.....................................................................................................................40
getstr ....................................................................................................................40
getyn ....................................................................................................................40
getynt...................................................................................................................40
kbhit.....................................................................................................................41
OutBuf.................................................................................................................41
printf ....................................................................................................................41
putch ....................................................................................................................42
putcstr ..................................................................................................................42
putcstn .................................................................................................................43
putyn....................................................................................................................43
sendblk ................................................................................................................43
sprintf ..................................................................................................................44
Format Conversions...........................................................................................................45
a2toh ....................................................................................................................45
a2toi.....................................................................................................................45
atoi.......................................................................................................................45
decodeBase64......................................................................................................45
encodeBase64......................................................................................................46
Before starting 3
4 Before starting
error .....................................................................................................................64
Serial Port Control .............................................................................................................65
InitLocalChan......................................................................................................65
InitLocalIO ..........................................................................................................65
lio_cts ..................................................................................................................65
lio_dcd.................................................................................................................65
lio_tx....................................................................................................................66
lio_rts...................................................................................................................66
lio_cok.................................................................................................................66
lio_rva..................................................................................................................66
LIOObuf ..............................................................................................................67
LioBrk .................................................................................................................67
EEPROM Functions ..........................................................................................................68
EE_Read..............................................................................................................68
EE_Write .............................................................................................................68
StoreCMOS .........................................................................................................68
Flash Functions..................................................................................................................69
CopyEEPR ..........................................................................................................69
flsh_clr.................................................................................................................69
flsh_pgm..............................................................................................................70
flsh_typ................................................................................................................70
Flash File System Functions ..............................................................................................71
get_file_curr_pos.................................................................................................71
get_file_len..........................................................................................................71
get_file_start_pos ................................................................................................71
r_close .................................................................................................................71
r_open..................................................................................................................72
r_read...................................................................................................................72
set_file_curr_pos .................................................................................................72
Random Generator Functions ............................................................................................73
rand......................................................................................................................73
srand ....................................................................................................................73
Encryption Functions.........................................................................................................74
tf_byte_stream .....................................................................................................74
tf_block_decrypt..................................................................................................74
tf_block_encrypt..................................................................................................74
tf_key_prep..........................................................................................................75
Debug Functions................................................................................................................76
Monitor................................................................................................................76
syslog...................................................................................................................76
SNMP
77
Introduction .......................................................................................................................77
CoBox SNMP structure.......................................................................................77
SNMP environment ...........................................................................................................79
Enterprise ID .......................................................................................................79
SNMP object .......................................................................................................79
Traps variables ....................................................................................................79
Checking access rights ........................................................................................81
Private MIB .......................................................................................................................82
MIB tree definition ..............................................................................................82
Read-only variables .............................................................................................83
Variable type descriptors.....................................................................................84
Read/write variables ............................................................................................85
Tables ..................................................................................................................86
Utility Programs
88
cbxfilt.................................................................................................................................88
Program Description............................................................................................88
Before starting 5
91
Introduction .......................................................................................................................91
Demo 1 ................................................................................................................91
Demo 2 ................................................................................................................91
Demo 3 ................................................................................................................91
Demo 4 ................................................................................................................91
Demo 5 ................................................................................................................91
Demo 6 ................................................................................................................91
Demo 7 ................................................................................................................92
Demo 8 ................................................................................................................92
Demo 9 ................................................................................................................92
Demo 10 ..............................................................................................................92
Demo 11 ..............................................................................................................92
Demo 12 ..............................................................................................................92
Demo13 ...............................................................................................................92
Demo14 ...............................................................................................................92
Demo15 ...............................................................................................................92
Demo16 ...............................................................................................................92
93
96
Introduction .......................................................................................................................96
CoBOS Loading.................................................................................................................96
6 Before starting
98
Before starting
Before starting, it is recommended to read the Users Manual of the particular hardware platform
you will use in development. Once you thoroughly understand how to use, configure, and load
firmware onto the device, you can begin software development. The programmer should also
become very familiar with the standard functionality of the device.
Hardware requirements
You need a PC with two serial ports and a connection to a local area network (LAN). In some
cases, a single serial port will suffice. The best setup is to have a second PC for a separate
connection to the second serial port of the device, as well as for independently capturing network
packets. You will also need the correct RS-232 serial cables with the corresponding connectors
DB-9 or DB-25 and network RJ-45 cable. The appropriate power supply will also be required.
Software requirements
On your PC, you must have MS-DOS or MS-Windows (NT, 2000, XP, etc) with access to the
Command Prompt or DOS prompt. Your computer must also have a LAN connection with
TCP/IP protocol. The best approach is to have static IP addresses on both your PC and your device
server ask your LAN administrator for details. All necessary software for developing a custom
program for the CoBox is available with the CPK (CoBox Programming Kit), except the necessary
compiler.
You may also need some additional software programs. To analyze a serial ports data flow, you
will need to use a terminal program. If you do not have another preference, you can use the
standard Windows Hyperterminal. Configure the terminal program the same as your Coboxs
serial ports default 9600 Baud, 8 data bits, no parity bit, and 1 stop bit.
You must also have a network terminal program. For TCP connection, you can use the standard
Windows Telnet. For UDP connection, Windows has no terminal client. Lantronix has provided an
additional utility UDPCBXTest.exe as part of the CPK.
Next, to download your program into your CoBox, you will need any TFTP client. Use the tftp.exe
of standard Windows NT or another client that you are comfortable using. For monitoring
network activity, you may want some sort of network sniffer. However this particular utility is
not included in the CPK, you would have to provide one of your own means. (Various network
analyzers can easily be found on the internet)
For compiler tool information, see the Programming Environment section.
Before starting 7
General
CPK Introduction
The CoBox Programmers Kit is a specific set of libraries and utilities produced by developers at
Lantronix. The main purpose of the CPK is for the development of Lantronix Device Servers. The
underlying operating system of the CPK is CoBOS, or CoBox Operating System.
The CPK is an internal tool of Lantronix, and is NOT readily available. Your protection of this
software is required.
Occasionally customer requirements drive the need for custom applications. For those specific
cases, Lantronix has allowed customers to write their own application upon the Lantronix CoBox
family. You must remember that your future programs can only use available C-functions in the
CPK. This set of functions is constantly changing and improving by the developers of Lantronix.
You should understand the sample DEMO-programs are written for training and teaching purposes
and are only a basis for your future programs.
CoBox Family
The CoBox family of products is microprocessor-based platforms, designed to exchange data
between a serial device and the network. However, this is only the tip of the iceberg. In reality, on
the CoBox base, you can do almost anything you want, because it is based on a general-purpose
microprocessor. You can write programs that transform CoBox into a mini WEB-server, or an
intelligent controller of different digital devices, or a modem bridge/router for connecting remote
networks, etc. Of course, applications need to consider the available hardware support of the
chosen delivery platform.
CoBOS Introduction
CoBOS is the name given to this Lantronix proprietary operating system. CoBOS is a cooperative
multi-tasking operating system. CoBox is designed with small memory footprint requirements in
mind. Custom programs are linked together with CoBOS and supporting libraries to create one
single program (OS included). The resultant image is loaded into flash memory.
Upon boot, the low-level boot loader is executed. The loader inspects the hardware, finds a
loadable image, loads the image, and begins execution of the image. On some hardware, the
image is executed from flash, while on platforms containing the Lantronix DSTni-LX or EX
processor; the image is loaded into RAM and then executed.
Once the firmware starts executing, the IP stack is initialized, and other low level tasks are started.
Lastly, the function newmain() is called. This is the start of all custom applications. The HTTP
server and remote configuration tasks are typically started in newmain(). Also, the serial ports are
normally initialized here as well.
CoBOS Tasks
The CoBox has a cooperative multitasking operating system. New tasks can be started with the
spawn() function. The task control block (TCB) structure (see tcbdef.h) maintains process
specific data, as well as a pointer to the next TCB. Control of the processor is released back to the
kernel by calling the nice() function. Nice() will then continue execution of the following task in a
circular list fashion. Tasks, or processes should be careful to release the CPU at least once every
second, or the watchdog timer will reboot the CoBox. Also note, that as long as this process is
running, others are not. All blocking I/O functions imply a nice(). For example, waiting for a
character to arrive via getch().
The actively running process is described in ActPro (Active Process), which is a pointer to the
currently running TCB.
8 General
2.
Make the program using Borland C tools and convert it to ROM-file by the e2i.exe utility (we usually use
a batch file t.bat or m.bat included in CPK);
3.
Download the ROM-file into CoBox by TFTP client. Use the table titled Firmware Support of various
Products and Password for the correct destination.
/* for example: tftp.exe i <CoBox_IP> PUT <program_name>.rom <destination> */
4.
5.
Start the necessary utilities for testing (Telnet, COM1/2 Terminals, UDP-client, etc.);
6.
General 9
Hardware Overview
Hardware
Chipsets
Model
Micro100
SDS-1101
SDS-2101
UDS-1100
UDS-2100
Xpress
DR+ (W)
Code Image
m100.rom
sds1101.rom
sds2101.rom
uds1100.rom
uds2100.rom
drig.rom
(dr_mrv.rom)
CPU
Lantronix
Lantronix
Lantronix
Lantronix
Lantronix
Lantronix
DSTni-LX001
DSTni-EX
DSTni-EX
DSTni-EX
DSTni-EX
DSTni-EX
48MHz
48-88MHz
48-88MHz
48-88MHz
48-88MHz
48-88MHz
Network
Controller
CPU
CPU
CPU
CPU
CPU
CPU
Serial
Controller
CPU
CPU
CPU
CPU
CPU
CPU
EEPROM
None
2 Kbytes
2 Kbytes
2 Kbytes
2 Kbytes
2 Kbytes
RAM
256 Kbytes
256 Kbytes
256 Kbytes
256 Kbytes
256 Kbytes
256 Kbytes
Flash PROM
512Kbytes
serial flash
2048 Kbytes
2048 Kbytes
2048 Kbytes
2048 Kbytes
2048Kbytes
Model
Xport-01
(LX)
Xport-03
(EX)
WiPort NR
Matchport
BG
WiPort (B/G)
(opt2)
WiBox
(B/G)
Code Image
xpt.rom
xptex.rom
fpt.rom
mpt_bg.rom
wpt_mrv.rom
wbx_mrv.rom
CPU
Lantronix
Lantronix
Lantronix
Lantronix
Lantronix
Lantronix
DSTni-LX001
DSTni-EX
DSTni-EX
DSTni-EX
DSTni-EX
DSTni-EX
48MHz
48-88MHz
48-88MHz
48-88MHz
48-88MHz
48-88MHz
Network
Controller
CPU
CPU
CPU
CPU
CPU
CPU
Serial
Controller
CPU
CPU
CPU
CPU
CPU
CPU
EEPROM
None
None
2 Kbytes
2 Kbytes
2 Kbytes
2 Kbytes
RAM
256 Kbytes
256 Kbytes
256 Kbytes
256 Kbytes
256 Kbytes
256 Kbytes
(1.25MB)
(1.25MB)
Flash PROM
512Kbytes
serial flash
512Kbytes
serial flash
2048Kbytes
2048Kbytes
2048Kbytes
(4096Kbytes)
(4096Kbytes)
10 Hardware Overview
2048Kbytes
Usage
AX
BX
CX
DX
SI
Source index
DI
Destination index
DS
Data segment
SS
Stack segment
CS
Code Segment
ES
Extra Segment
IP
Instruction pointer
Hardware Overview 11
Memory Maps
DSTni Based Products
Memory Block
(24-bit address)
WiPort opt 2
FFFFFF
FF0000
FEFFFF
WEB19
WEB51
Not Used
WEB18
WEB50
WEB17
WEB49
WEB16
WEB48
WEB15
WEB47
WEB14
WEB46
WEB13
WEB45
WEB12
WEB44
WEB11
WEB43
WEB10
WEB42
WEB9
WEB41
WEB8
WEB40
WEB7
WEB39
WEB6
WEB38
WEB5
WEB37
WEB4
WEB36
WEB3
WEB35
WEB2
WEB34
FE0000
FDFFFF
FD0000
FCFFFF
FC0000
FBFFFF
FB0000
FAFFFF
FA0000
F9FFFF
F90000
F8FFFF
F80000
F7FFFF
F70000
F6FFFF
F60000
F5FFFF
F50000
F4FFFF
F40000
F3FFFF
F30000
F2FFFF
F20000
F1FFFF
F10000
F0FFFF
F00000
EFFFFF
EF0000
EEFFFF
EE0000
EDFFFF
ED0000
12 Hardware Overview
ECFFFF
WEB1
WEB33
WEB32
EC0000
EBFFFF
EB0000
EAFFFF
WEB31
EA0000
E9FFFF
WEB30
E90000
E8FFFF
WEB29
E80000
E7FFFF
WEB28
E70000
WEB27
E6FFFF
E60000
E5FFFF
E50000
E4FFFF
WEB26
WEB25
E40000
E3FFFF
WEB24
E30000
E2FFFF
WEB23
E20000
E1FFFF
WEB22
E10000
WEB21
E0FFFF
E00000
DFFFFF
DF0000
DEFFFF
Mirrored 2MB
(E00000 FFFFFF)
WEB20
WEB19
DE0000
DDFFFF
WEB18
DD0000
DCFFFF
WEB17
DC0000
DBFFFF
WEB16
DB0000
DAFFFF
WEB15
DA0000
D9FFFF
WEB14
D90000
D8FFFF
WEB13
D80000
D7FFFF
WEB12
D70000
D6FFFF
WEB11
D60000
D5FFFF
WEB10
D50000
Hardware Overview 13
D4FFFF
WEB9
D40000
D3FFFF
WEB8
D30000
D2FFFF
WEB7
D20000
D1FFFF
WEB6
D10000
D0FFFF
WEB5
D00000
CFFFFF
WEB4
CF0000
CEFFFF
WEB3
CE0000
CDFFFF
WEB2
CD0000
CCFFFF
WEB1
CC0000
Firmware Image Bank
2 (Storage)
CBFFFF
CB0000
CAFFFF
CA0000
C9FFFF
C90000
C8FFFF
C80000
C7FFFF
C70000
C6FFFF
C60000
C5FFFF
C50000
C4FFFF
C40000
C3FFFF
C30000
C2FFFF
C20000
C1FFFF
C10000
C0FFFF
C00000
BFFFFF
B00000
Mirrored 2MB
(E00000 FFFFFF)
Mirrored 4MB
(C00000 FFFFFF)
AFFFFF
A00000
9FFFFF
900000
14 Hardware Overview
Mirrored 2MB
(E00000 FFFFFF)
8FFFFF
800000
7FFFFF
Not Used
Not Used
500000
4FFFFF
400000
3FFFFF
Not Used
040000
030000
RAM3 (Firmware
Image, Executing)
RAM3 (Firmware
Image, Executing)
RAM3 (Firmware
Image, Executing)
02FFFF
RAM2
RAM2
RAM2
010000
RAM1 (Network
Buffers)
RAM1 (Network
Buffers)
RAM1 (Network
Buffers)
00FFFF
RAM0
RAM0
RAM0
03FFFF
020000
01FFFF
000000
Hardware Overview 15
RAM3
CoBOS application programs execute from RAM3.
RAM2
Application programs can use the RAM2 (64 Kbytes of RAM) if the image is NOT executing from RAM2.
This area must be accessed by far pointers.
Description
FFFF
E800
E7FF
E000
DFFF
D000
TCP Buffer (1st TCPAlloc for tcp14.lib), free space with tcp12
and tcpip.lib
CFFF
C000
TCP Buffer (2nd TCPAlloc for tcp14.lib), free space with tcp12
and tcpip.lib
BFFF
B000
TCP Buffer (1st TCPAlloc for tcp12.lib, 3rd for tcp14), free space
with tcpip.lib
AFFF
8000
TCP Buffer (2nd, 3rd, and 4th TCPAlloc for tcp12.lib, 4th, 5th and
6th for tcp14), free space with tcpip.lib
7FFF
7000
0FFF
0000
Description
FFFF
FC00
FBFF
F000
EFFF
C800
C7FF
0100
00FF
0000
Interrupt vectors
16 Hardware Overview
557
Byte offset
range
Description
540591
WEB1-6
147048
147047
308
81312
81311
261
264
263
1320
1319
1848
1847
67848
68903
68904
68903
257
17
Programming Environment
Operating System
MS-DOS, Microsoft Windows (95, 98, NT, 2000).
Directory Structure
To avoid problems with older MS-DOS software, do not use more than eight characters for filenames. This
is an example directory tree for CoBox development. Please note, starting with V6, each product now has
its own working sub-directory. This subdirectory scheme removes the need for a specific suffix being
added to the created object files.
C:\Source
CoBox
cpk430
cpk450
cpk500
cpk520
cpk550
cpk551
cpk580
cpk6101
cpk6500
Bin
Doc
Inc
Lib
SNMP
Stdf
TCP_UDP_terminal
UDP_terminal
Demo[x]
xpt(s)
xptex(s)
wbx_mrv
wpt_mrv
Environment Variables
You should add the bin directory to your search path. Change the environment settings on Windows
NT/2000 or add this line at the end of C:\autoexec.bat:
PATH=C:\Source\CoBox\cpk6500\bin;%PATH%
18 Programming Environment
Compiling
Compiler
Borland Turbo C Version 5.2. Warning: new Borland compilers do not support 16-bit CPUs.
Libraries
Library name
Contents
crstub
crypt[2]
Drig, drw
fpt
kern100
Kernel functions
kernMAC
m100
Romlib
Parfl
Mrv[8385]
serfl[ex]
snmp[m]
std
stubs
Stub functions
supp[WPA]
uds21
vds100
web[m]
web_fs[m]
WiBox
WiPort
XPort
XPortEX
Makefile
The make process consists of two Makefiles and product subdirectories. Each demo directory
contains its own Makefiles. Please review them in detail. You MUST define BCBIN in the
Makefile.
Programming Environment 19
t.bat
m.bat
(make | more).
Make whole project and wait for key after each page
s.bat
Make Commands
Note: The optional s character will force the make process to attempt to build a 64KB module
(will not use two TEXT segments).
make all
make dr_mrv.rom
make drig[s].rom
make fpt[s].rom
make m100[s].rom
make mpt_bg.rom
make sds1101[s].rom
make sds2101[s].rom
make xpt[s].rom
make xptex[s].rom
make wpt_mrv.rom
make wbx_mrv.rom
make u2100[s].rom
make u1100[s].rom
make clean
20 Programming Environment
ROM file
Destination
Micro-100
M100.ROM
4M
SDS-1101
SDS1101.ROM
D3
SDS-2101
SDS2101.ROM
D4
UDS-1100
UDS1100.ROM
U3
UDS-2100
UDS2100.ROM
U4
DRIG.ROM
R1
Xpress DR+
Xpress DR+W
DR_MRV.ROM
R2
XPort-01 (LX)
XPT.ROM
X4
XPort-03 (EX)
XPTEX.ROM
X5
FPT.ROM
FX
WiPort(B/G)
WPT_MRV.ROM
W6
WiBox(B/G)
WBX_MRV.ROM
W7
Matchport BG
MPT_BG.ROM
W8
WiPort-NR
Restrictions
Do not use a lot of stack, stack memory is limited! Bigger buffers should be defined as global
variables.
Stack memory for the main() task is FFC0hFFFFh = 1024 bytes.
Dont place static structures onto the stack. You should define them as global variables.
Memory usage is limited to C800h bytes. Add vectors + _data + cdata + const + _bss +
extdata + stack, which is the actually used memory. The result has to be lower than C800h.
Information can be read from of the screen output or the map file (example below):
Start
Stop
Length Name
Class
CODE
DATA
DATA
DATA
CONST
BSS
STACK
Programming Environment 21
var >> 16
is OK but
var >> 17
cannot be used.
Programming
Multitasking
The CoBox round robin multitasking is controlled with four interrupts in the following priorities:
1. Serial interfaces
2. Timer
3. Network interface
4. Standard
Priority 1 is the highest priority. That means that e.g. the network event can interrupt the standard
event.
CoBox multitasking occurs only when you call the nice () function. Remember to insert this
function in any longer loop, otherwise the watchdog will reset the CoBox after approximately 1
second. nice () is also called from some internal functions (typically IO functions like getch()).
Watchdog
The watchdog is a hardware timer that resets the CoBox if it is not triggered regularly. The timeout
varies from 700 to 1300 mS depending on CPU clock speed.
22 Programming Environment
NOTE: icmp_out can only effectively send a ping, other requests will have a 0d ICMP payload.
int icmp_out (AD_T *a, WORD len, WORD code, WORD seq)
a - pointer to AD_T address structure with IP address filled in, other fields 0
len - must be 8 plus the ping data length (typically 12) == 8+12 or 20
code - ICMP type field - 0x08 for Echo Request
seq - ICMP sequence number
Programming Environment 23
TCP Connections
Example:
TCP_t *t;
BYTE InBun[128 + 8];
/* include 8 additional bytes for the FIFO control block */
BYTE OutBuf[128 + 8]; /* include 8 additional bytes for the FIFO control block */
t
= TCPAlloc(); /* Allocate TCP Structure */
t->r.StCall
= ChanS2NoTel; /* ChanS2() selects telnet automatically */
t->r.RcvCall
= ChanRcv;
t->RcvFifo
= FifoInit(InBuf, 128); /* FIFO size, w/o the control block */
t->XmitFifo
= FifoInit(OutBuf, 128);/* FIFO size, w/o the control block */
TCPOpen(0, t, 10001);
while(t.State == ESTABLISHED) {
/* Send and receive data */
}
T_Discon(t);
/* Close connection */
Connection States
The State variable in the TCP structure indicates the current connection state (see tcp.h for states).
Example:
if(t->State == ESTABLISHED) {
/* Connection established */
}
if(t->State == LISTEN) {
/* Passive connection is waiting for connect from foreign host */
}
Web Server
Telnet connection
for user application
If your application is required to open, close and re-open connections, you have to make sure that
you are not using a new connection each time. If you do, you will find that the CoBox is re-booting
once you try to open up the 9th (13th or 15th) connection.
The proper way would be to re-use the handle after T_Discon(xxx) finishes. The handle is still
valid.
Example:
24 Programming Environment
The network stack will send the TCP data in an ordinarily fashion. In some cases, the programmer
may wish to request that the packet be sent now. This may be accomplished by ORing the tcp
structures s member sflg with 2 (t->s.sflg |= 2).
*/
*/
*/
*/
*/
*/
Programming Environment 25
BYTE
Int
bbuf[300];
buflen;
main() {
...
udp_register(1234, rcvr);
...
}
/* rcvr: Demo UDP receive subroutine, called by kernel
/* Parameters:
/*
buf
UDP content received
/*
len
Length of UDP content
/*
bflg
True if block came in by broadcast
/*
xip
Source IP address (pointer)
/*
a
Source address structure (pointer)
/*
from
From port
/*
to
Destination port
void rcvr(buf, len, bflg, xip, a, from, to)
BYTE
*buf, *xip;
AD_T
*a;
Int
len, bflg;
WORD
from, to;
{
if(len && (len < 300)) {
memcpy(bbuf, buf, len);
buflen = len;
}
}
*/
*/
*/
*/
*/
*/
*/
*/
*/
Queues / FIFOs
Function
Serial and TCP queues are handled as FIFOs. The FIFO size must be a power of 2 (i. e.
256, 512, 1024,) PLUS 8 bytes. Initialization of the FIFO is done by using the
FifoInit() function and the power of 2 size (see TCP example above). The IOCall
function is available for accessing the FIFO.
FIFO Structure
FIFO Control Block
Data Block
Input pointer IP
Output pointer OP
Mask
Base
(size 1) (Pointer to 1st byte
of data block)
FIFO Data
WORD
WORD
WORD
0size-1
WORD
26 Programming Environment
Timer
The internal CoBox timer is represented in global variables time and ticks. 1000 ticks is equal to 1
second. The timer resolution for V6 and above is 1 mS for all platforms. That means the timer
value (ticks) will be updated every 1 millisecond. This could change in the future.
Example:
#define wtime
#define sticks
((WORD) time)
((WORD) ticks)
demo() {
DWORD ctime;
DWORD stime;
/* Current time in ms */
/* Current time in s */
ctime = sticks;
stime = wtime;
/* Disable interrupts to prevent timer task from changing contents between the
reading of the two variables */
disable();
ctime = ticks;
stime = time;
enable();
}
LED Control
The LED states are controlled by corresponding global variables of type WORD:
LED
Standard function
Variable
Green
Channel 1
BlinkGWord[0]
Yellow
Channel 2
BlinkGWord[1]
Red
Error
BlinkRWord
The bits of the variables are used to control the LEDs with a clock rate of 0.25 seconds. So the
pattern 0xCCCC, which is binary
15 14 13 12 11 10
1
will result in a 50% duty cycle LED blinking with a period time of one second.
After executing bit 0 the pattern starts again with bit 15 and so the whole sequence will circle
within a 4 second period.
Any changed variable contents will be activated with the start of a new period. The function
BlinkReset() will start the period immediately.
Example:
BlinkRWord
= 0x0000; /* Red LED: OFF */
BlinkGWord[0] = 0xFFFF; /* Green LED: always ON */
BlinkGWord[1] = 0x0005; /* Yellow LED: 2 flashes every 4 s */
BlinkReset();
/* Set values immediately */
Tasks
Each task has a Task Control Block (TCB). New tasks may be started with the spawn() function.
Programming Environment 27
BYTE my_tcb_stack[256];
int my_task(void);
spawn(my_task, my_tcb_stack, sizeof(my_tcb_stack), 0, my_task);
Streams
Each task has an associated stream. This stream may be the serial port, a TCP FIFO, or not
associated. IO functions (like printf, getch, etc) operate on the associated stream.
Hardware Detection
Processor Type
The variable HW.cpu contains the currently used processor type:
HW.cpu
Processor
NEC V.40
AMD 188ES
28 Programming Environment
CPU Clock
The variable HW.cpuclk contains the currently used processor clock frequency in Mhz.
HW.cpuclk
Clock Frequency
10
10 Mhz
20
20 Mhz
25
25 Mhz
48
48 Mhz (DSTni-LX)
88
EEPROM Type
The variable HW.eeprom contains the currently used EEPROM type:
HW.eeprom
EEPROM
93C46
Debugging
There are several methods to help you debug your CPK application.
Serial Port
If you need some debugging information you can use the 2nd serial port (if available). Just open a
new channel in main.c:
Programming Environment 29
#if DEBUG
int
Chan2Stack[200];
extern WORD dioptr, sioptr;
Chan2() {
extern WORD dioptr;
ActCCB->V24_speed = 0x02; /* 9600 bps */
ActCCB->V24_mode = 0x4c; /* RS232, 8N1 */
InitLocalChan();
dioptr = ActPro->IO_Ptr;
/* This stores an I/O pointer;
necessary for access and
reference by the main process */
while(1) {
putstr(\n\rCoBox demo template - DEBUG Port\n\r);
Monitor();
/* Start ProMon for debug channel */
}
}
#endif
newmain()
{
#if DEBUG
spawn(Chan2, Chan2Stack, sizeof(Chan2Stack), 1, C2);
sdelay(500); /* Wait for proper init of channel 2 */
#endif
For output something to the debug port you simply switch the standard output:
#if DEBUG
startdebug();
putstr(\n\rInit UDP receiver...);
stopdebug();
#endif
Syslog
If there is a syslog server in your network you can use the syslog() function for sending debug
information from the CoBox to the server.
Example:
memset(smtp_s.logmsg, 0, 513); /* Clear old message */
strcpy(smtp_s.logmsg, Debug information);
syslog((WORD)(LOG_NOTICE + LOG_LOCAL7), smtp_s.logmsg);
UDP
Simply call the udp_send() function to send debugging information. Use either a network sniffer
for receiving and displaying the packets or send it to another UDP receiver program. (If your only
using a sniffer, it might make sense to broadcast the packet.)
30 Programming Environment
ProMon
ProMon 3.0 can be started with the Monitor() function and allows some simple debugging. See
the Debug Functions section.
Telnet
Open a telnet session to the debug port 9998.
Example:
int telnetdebugStack[200];
static BYTE inbuf[128 + 8], outbuf[128 + 8];
WORD telnetptr;
TelnetDebug() { register TCP_t *t; extern int ChanS2(), ChanRcv();
t
= TCPAlloc();
t->r.StCall
= ChanS2;
t->r.RcvCall
= ChanRcv;
t->RcvFifo
= FifoInit(inbuf, 128);
t->XmitFifo
= FifoInit(outbuf, 128);
ActPro->IO_Ptr = &(t->RcvFifo);
TCPOpen(0, t, 9998); /* Open passive connection to port 9998 */
while(1) {
sdelay(50);
t->State = LISTEN;
while(t->State != ESTABLISHED) nice();
Monitor();
/* Start ProMon, disconnect with Quit */
T_Discon(t);
}
}
newmain() {
...
spawn(TelnetDebug, telnetdebugStack, sizeof(telnetdebugStack), -1,
TelnetDeb );
sdelay(500);
...
}
main.c
#include kernel.h
#include io.h
setpar.c
#define SETUPVAR Setup
#include io.h
int SetParStart(int d);
Programming Environment 31
main.c
Add:
/* network driver declaration */
#ifdef N0
extern int N0_DRV;
#endif
#ifdef N1
extern int N1_DRV;
#endif
#ifdef N2
extern int N2_DRV;
#endif
#ifdef N3
extern int N3_DRV;
#endif
#ifdef ND
extern int ND_DRV;
#endif
Add to newmain()
/* network driver initialization */
#pragma warn -eff
#ifdef N0
N0_DRV;
#endif
#ifdef N1
N1_DRV;
#endif
#ifdef N2
N2_DRV;
#endif
#ifdef N3
32 Programming Environment
N3_DRV;
#endif
#ifdef ND
ND_DRV;
#endif
#pragma warn +eff
Support Removed
Support for putint(), puthex(), and delay() has been removed in this release. Please use
printf() and sdelay() as substitute routines.
Include Ordering
Include io.h before ip.h.
Include ip.h before tcp.h or udp.h
main.c
Changes to VersionInit().
setpar.c
Changes in setpar.c:
new *baudratestrings[]
230400 is now valid for DSTni-LX platforms
0 disables the the serial port
Programming Environment 33
#include <digio.h>
Include the following files for DinRail builds
# include <digio.h>
New include file bldFlags.h has been added to all the demos. This contains product specific compile options
and should be included in all application source files.
Main.c change
Due to kernel reorganization, you MUST add one additional declaration. Changes were made to
the demo main.c files to reflect this change. Please add the following line in your project:
BYTE hls[75];
Setpar.c change
The XPort EX has the ability to run at serial speeds of up to 920Kbps. However, setting this baud
rate also requires changing the CPU clock speed. These changes are made in Setup record 3.
Setup record 3, also contains other kernel specific values. Avoid using record 3 in your project.
34 Programming Environment
Main.c change
Additional include files were added to main.c to support the two new wireless products. The byteorder of firmwarecheck was changed.
Setpar.c change
Additional include files were added to main.c to support the two new wireless products, along with
RS-485 support in the XPort. The setup menu now includes these new options.
WiFi.c added
WiFi.c contains the standard setup configuration dialog for the wireless interface. It is located in
the stdf directory.
Other changes
Added documentation as to How to send a ping.
Added documentation to CoBOS Ethernet frame handling.
Fixed a bug in putchar() of tools.c.
Micro-100 now uses virtual IO (pios). Added support in VersionInit via bldflags.
Added SetServicePort() to set port number for a specific service (HTTP, SMTP).
Changed Makefiles to include relative path to E2I.EXE.
Programming Environment 35
The V6 build process will attempt to relocate pieces of code into RAM2 and RAM3. In order to
make this happen, the linker will need to make multiple passes. The make process will find the far
links and create the required proxy code to access those far modules.
The product small builds (ie: xptexs.rom) will attempt to keep the single ROM image as 64KB.
The normal build (xptex.rom), will attempt to locate your application in RAM2 while the rest of
the code resides in RAM3. You can change the location of certain code pieces by manipulating
the Makefile.
Main.c change
Changes were made to support additional security settings.
GLOBAL BYTE ethmode is added to support Ethernet Mode (duplex, and speed) selection.
MTU size is now defined in VersionInit().
Setpar.c change
Changes were made to factory_defaults(), now called default_setup().
Record 1 will now be reset.
Additional setup menu options were added to support the security settings. Please review these
changes.
Demo.c change
Pointers to functions MUST be declared in global space (NOT statically defined).
Changes were made to demo.c to assit in automatic testing.
Other changes
WPA is now supported.
The radio firmware of the WiPort is no longer a separate file. The radio firmware is now
integrated into the WiPort ROM image.
WPT.ROM and WBX.ROM no longer exist. These have been replaced by WPT_AGR.ROM and
WBX_AGR.ROM. New additions WPT_MRV.ROM and WBX_MRV.ROM are added to support
the new WiPorts B/G radio.
Addition support was added for new products (UDS-1100, WiPort G, and DRIG).
36 Programming Environment
while the rest of the code resides in TEXT (RAM3). You can change the location of certain code
pieces by manipulating the Makefile.
SNMP functions referenced from the MIB should be built with G_FLAGS (located in TEXT not
TXT1).
Main.c change
Changes were made to support additional network interfaces which includes two new external
references. VersionInit() was changed to add support for arp cache timeout and multiple network
interfaces.
Setpar.c change
All instances of putcst_pde were changed to putst_pde.
A bug was fix in the baudratestrings array.
defaultWiFiSettings() now takes two parameters. Source code is available in stdf\wifi.c.
Demo.c change
All instances to ChanS2() have been changed to ChanS2NoTel() so telnet mode is no longer the
default in the demo projects. All references to GChanS2() have been removed.
SNMP change
The entry point for your SNMP mib has changed from priv_mib to data_priv_mib.
Other changes
Part of 802.11i is now supported on the wireless products.
All references to \n\r have been changed to \r\n in the demos.
Additional Notes
Library Functions
All library functions are compiled into libraries. To use them, you must include the related library
into your project.
Tools
All tools are available as source code. You can either include tools.c into your project or copy
the functions you need into your own source.
Programming Environment 37
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
int FlushIn(void)
Parameter:
None
Return value:
fprintf
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
Parameter:
Return value:
0 = OK
-1 = Stream not open (null-pointer)
Description:
Location:
kern100.lib
Prototype:
io.h
Syntax:
char getch(void)
Parameter:
None
Return value:
getch
get_int
Description:
Get integer value from a string. Get_int() will skip over leading
characters that are less than 0x20.
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
Parameter:
Return value:
get_ips
Description:
38 Programming Environment
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
Parameter:
Return value:
gethex
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
Parameter:
*v = value
*vl = last value
Return value:
char value
gethex8
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
Parameter:
*v = value
*vl = last value
Return value:
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
Parameter:
*v = value
*vl = last value
Return value:
Value
getint
getint8
Description:
Programming Environment 39
in v.
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
Parameter:
*v = value
*vl = last value
Return value:
Value
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
Parameter:
*p = pointer to IP address
Return value:
None
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
Parameter:
Return value:
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
Parameter:
default = 1 if Y, 0 if N
Return value:
1 if Y, 0 if N
getip
getstr
getyn
getynt
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
Parameter:
default = 1 if Y, 0 if N
Return value:
1 if Y, 0 if N
40 Programming Environment
kbhit
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
int kbhit(void)
Parameter:
None
Return value:
OutBuf
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
int OutBuf(void)
Parameter:
None
Return value:
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
Parameter:
Return value:
0 = OK
-1 = Error
printf
Programming Environment 41
Type
Format
string Remarks
unsigned int
%nu
signed int
%nd
hex
%nx
char
%c
single char
string
%ns
time
(dword)
%T
pointer
(long)
%P
IP address
%nA
Hardware
address
%nH
Serial
number
%S
Software
version
%nV
putch
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
void putch(BYTE c)
Parameter:
c = character to send
Return value:
None
putcstr
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
Parameter:
Return value:
None
42 Programming Environment
putcstn
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
Parameter:
Return value:
None
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
void putyn(int i)
Parameter:
i = 1 for Y or 0 for N
Return value:
None
putyn
sendblk
Description:
Location:
tools.c
Prototype:
Syntax:
Parameter:
Return value:
None
Programming Environment 43
sprintf
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
io.h
Syntax:
Parameter:
Return value:
44 Programming Environment
0 = OK
-1 = Error
Format Conversions
a2toh
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
kernel.h
Syntax:
Parameter:
Return value:
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
None
Syntax:
Parameter:
Return value:
Integer value of p
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
kernel.h
Syntax:
Parameter:
Return value:
Integer value of p
a2toi
atoi
decodeBase64
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
Syntax:
Parameter:
Return value:
None
Programming Environment 45
encodeBase64
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
Syntax:
Parameter:
Return value:
46 Programming Environment
None
Time Functions
get_trand
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
kernel.h
Syntax:
WORD get_trand(void)
Parameter:
None
Return value:
Timer value
sdelay
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
kernel.h
Syntax:
void sdelay(WORD t)
Parameter:
t = delay time in ms
Return value:
None
MsGet
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
kernel.h
Syntax:
DWORD MsGet(void)
Parameter:
None
Return value:
Programming Environment 47
Math Functions
lmod
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
kernel.h
Syntax:
Parameter:
lx
y
Return value:
lx%y
Description:
lmul
ATTENTION:
The call of the function must have the following syntax:
resultlong = lmul(longvalue, intvalue);
The function then creates two nibbles out of the word. That
means defined with three parameters but called with two!
Location:
kern100.lib, kernMAC.lib
Prototype:
kernel.h
Syntax:
Parameter:
Return value:
lllh*cons
longdiv
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
kernel.h
Syntax:
Parameter:
lx
y
Return value:
lx/y
48 Programming Environment
String Functions
sprl
Description:
Location:
tools.c
Prototype:
None
Syntax:
Parameter:
Return value:
strchr
Description:
Location:
romlib.lib
Prototype:
string.h
Syntax:
Parameter:
*s = string
c = character
Return value:
Pointer to c in string
strcpy
Description:
This copies characters from the string from (up to and including
the terminating null character) into the string to. Like
memcpy(), this function has undefinded results if the strings
overlap.
Location:
romlib.lib
Prototype:
string.h
Syntax:
Parameter:
Return value:
None
strcmp
Description:
Location:
romlib.lib
Prototype:
string.h
Syntax:
Parameter:
*s1 = string 1
*s2 = string 2
Return value:
< 0 if s1 < s2
== 0 if s1 and s2 are equal
> 0 if s1 > s2
Programming Environment 49
strncmp
Description:
Location:
romlib.lib
Prototype:
string.h
Syntax:
Parameter:
*s1 = string 1
*s2 = string 2
len = number of chars to compare
Return value:
< 0 if s1 < s2
== 0 if first len bytes of s1 and s2 are equal
> 0 if s1 > s2
Description:
Location:
romlib.lib
Prototype:
string.h
Syntax:
Parameter:
*s = string
Return value:
String length.
strlen
50 Programming Environment
Memory Functions
MBufInit()
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
mbuf.h
Syntax:
void MBufInit(void)
Parameter:
None.
Return value:
None.
MBufGet()
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
mbuf.h
Syntax:
void *MBufGet(void)
Parameter:
None.
Return value:
MBufFree()
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
mbuf.h
Syntax:
Parameter:
Return value:
None.
memset
Description:
This function copies the value of c into each of the first size
bytes of the object beginning at block.
Location:
romlib.lib
Prototype:
memory.h
Syntax:
Parameter:
*block = buffer
c = value
size = number of bytes to fill
Return value:
None.
Programming Environment 51
memcpy
Description:
Location:
romlib.lib
Prototype:
memory.h
Syntax:
Parameter:
*to = buffer 1
*from = buffer 2
size = number of bytes to copy
Return value:
memcmp
Description:
Location:
romlib.lib
Prototype:
memory.h
Syntax:
Parameter:
*to = buffer 1
*from = buffer 2
len = number of bytes to compare
Return value:
movedata
Description:
Location:
Prototype:
memory.h
Syntax:
Parameter:
Return value:
None
52 Programming Environment
UDP Functions
udp_register
Description:
Location:
tcpip.lib
Prototype:
udp.h
Syntax:
Parameter:
Return value:
Always 1
udp_reregister
Description:
Location:
tcpip.lib
Prototype:
udp.h
Syntax:
Parameter:
Return value:
Always 1
udp_send
Description:
Location:
tcpip.lib
Prototype:
udp.h
Syntax:
Parameter:
Return value:
None
Programming Environment 53
udp_sehw
Description:
Location:
tcpip.lib
Prototype:
udp.h
Syntax:
Parameter:
Return value:
Always 0
TCP Functions
TCPAlloc
Description:
Location:
Prototype:
tcp.h
Syntax:
TCP_t t = TCPAlloc(void)
Parameter:
None
Return value:
TCP structure
TCPOpen
Description:
Location:
Prototype:
tcp.h
Syntax:
Parameter:
Return value:
0 = OK
-1 = active open failed
54 Programming Environment
TcpWriteNB
Description:
Location:
Prototype:
tcp.h
Syntax:
Parameter:
*t = TCP structure
*s = data buffer
len = number of bytes to send
Return value:
T_Discon
Description:
Location:
Prototype:
tcp.h
Syntax:
void T_Discon(TCP_t t)
Parameter:
T = TCP structure
Return value:
None
ChanRcv
Description:
Location:
Prototype:
None
Syntax:
Parameter:
Return value:
Programming Environment 55
ChanS2
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
None
Syntax:
Parameter:
Return value:
Always 1
Function
Option
Meaning
Unused
Unused
N/A
Reserved
int
Unused
To disable telnet functionality, youll need to write your own TCP Channel Status function. For
example :
int GChanS2(TCP_t *t, int typ, int mode)
{
if (typ==4) {
t->TelBits=0; /* Not a telnet connection */
}
return(1);
}
Or use ChanS2NoTel().
56 Programming Environment
Location:
<prod>.lib
Prototype:
bitsXP.h
Syntax:
void defaultCP_settings(void);
Parameter:
None
Return value:
None
SaveCPsettings
Description:
Location:
<prod>.lib
Prototype:
bitsXP.h
Syntax:
void SaveCPsettings(void);
Parameter:
None
Return value:
None
dio_vbit_init
Description:
Location:
<prod>.lib
Prototype:
digio.h
Syntax:
void dio_vbit_init(void);
Parameter:
None
Return value:
None
dio_vbit_in
Description:
Location:
<prod>.lib
Prototype:
digio.h
Syntax:
Parameter:
Return value:
None
Programming Environment 57
dio_vbit_out
Description:
Location:
<prod>.lib
Prototype:
digio.h
Syntax:
Parameter:
Return value:
None
dio_vbit_read
Description:
Location:
<prod>.lib
Prototype:
digio.h
Syntax:
Parameter:
Return value:
int = 0 or 1
dio_vbit_reset
Description:
Location:
<prod>.lib
Prototype:
digio.h
Syntax:
Parameter:
Return value:
None
dio_vbit_set
Description:
Location:
<prod>.lib
Prototype:
digio.h
Syntax:
Parameter:
Return value:
None
58 Programming Environment
dio_vbit_setres
Description:
Location:
<prod>.lib
Prototype:
digio.h
Syntax:
Parameter:
Return value:
None
Programming Environment 59
Web Functions
SetServicePort
Description:
Location:
kernel.lib
Prototype:
kernel.h
Syntax:
Parameter:
srv = service
port_number = service socket port number
Return value:
WebMethRegister
Description:
Location:
web.lib
Prototype:
web.h
Syntax:
Parameter:
Return value:
Example:
WebMethRegister(GET, my_callback, call_my_callback.cgi);
int my_callback(WCT *w, char *file, char *hdr);
60 Programming Environment
DNS Functions
dns_resolve
Description:
Location:
Prototype:
ip.h
Syntax:
Parameter:
Return value:
Example:
ip.ns[0] = 194; /* set the name server IP address */
ip.ns[1] = 39;
ip.ns[2] = 78;
ip.ns[3] = 11;
*((DWORD *) ip.addr) = dns_resolve(jl232.pronet.de);
printf(IP address is: %A\n\r, ip.addr);
Programming Environment 61
Multitasking Functions
kill
Description:
Terminate a process.
Location:
kern100.lib
Prototype:
None
Syntax:
Parameter:
Return value:
None
Description:
Location:
kern100.lib
Prototype:
kernel.h
Syntax:
void nice(void)
Parameter:
None
Return value:
None
Description:
Location:
kern100.lib
Prototype:
kernel.h
Syntax:
void reset(void)
Parameter:
None
Return value:
None
nice
reset
spawn
Description:
Location:
kern100.lib
Prototype:
kernel.h
Syntax:
void spawn(void *start, BYTE *newtcb, int size, int Chan, char
*Name);
Parameter:
Return value:
None
62 Programming Environment
FIFO Control
FifoInit
Description:
Initialize a FIFO.
Location:
kern100.lib
Prototype:
io.h
Syntax:
Parameter:
Return value:
Pointer to FIFO.
IOCall
Description:
Location:
kern100.lib
Prototype:
io.h
Syntax:
Parameter:
f = Function
p = Address of a pointer to FIFO (see Example)
x = Additional parameters
Defined functions:
f
0
1
2
3
4
5
6
Function
Check and return number of bytes available for reading
Get one byte out of queue
NOT IMPLEMENTED
none
Clear buffer
none
Check and return free buffer space available for storing
byte
Store one byte into queue
buf, len Store many bytes from buf in queue. IOCall() returns
when whole buffer is sent.
7 byte
Unget, stuff byte back to top of queue
8
NOT IMPLEMENTED
9 none
Buffer size, return value is mask, which is equ. to size-1
Return value:
x
none
none
See table.
Example:
Each process and thus channel control block has two FIFOs for input and output functions
defined. The addresses of these FIFOs are stored in a structure, to which a pointer is held in the
TCB (task control block):
ActPro->IO_Ptr
ActPro->IO_Ptr[0]
ActPro->IO_Ptr[1]
Clear the output queue of the associated stream. This can be either a serial or a TCP stream.
IOCall(3, (BYTE *) &ActPro->IO_Ptr[1]);
IOCall(3, (BYTE *) &t->XmitFifo);
Programming Environment 63
LED Control
BlinkReset
Description:
Location:
kern100.lib
Prototype:
kernel.h
Syntax:
void BlinkReset(void)
Parameter:
None
Return value:
None
Description:
Red LED is on, yellow LED shows error code. After 20 seconds
the device is resetting.
Location:
kern100.lib
Prototype:
kernel.h
Syntax:
void error(WORD w)
Parameter:
w = BlinkGWord[1]
Return value:
None
error
64 Programming Environment
Location:
kern100.lib
Prototype:
io.h
Syntax:
void InitLocalChan()
Parameter:
None
Return value:
None
InitLocalIO
Description:
Location:
kern100.lib
Prototype:
io.h
Syntax:
void InitLocalIO()
Parameter:
None
Return value:
None
lio_cts
Description:
Location:
kern100.lib
Prototype:
io.h
Syntax:
Parameter:
TRUE or FALSE
Return value:
None
lio_dcd
Description:
Location:
kern100.lib
Prototype:
io.h
Syntax:
Parameter:
TRUE or FALSE
Return value:
None
Programming Environment 65
lio_tx
Description:
Location:
kern100.lib
Prototype:
io.h
Syntax:
Parameter:
Return value:
None
lio_rts
Description:
Location:
kern100.lib
Prototype:
io.h
Syntax:
int lio_rts(void)
Parameter:
None
Return value:
lio_cok
Description:
Location:
kern100.lib
Prototype:
None
Syntax:
int lio_cok(void)
Parameter:
None
Return value:
TRUE or FALSE
lio_rva
Description:
Location:
kern100.lib
Prototype:
None
Syntax:
Parameter:
TRUE or FALSE
Return value:
None
66 Programming Environment
LIOObuf
Description:
Location:
kern100.lib
Prototype:
Io.h
Syntax:
WORD LIOObuf()
Parameter:
None
Return value:
LioBrk
Description:
Location:
kern100.lib
uds.lib: for the AMD platforms(UDS10,
Mini REv2, Micro, FL, ...)
ec1.lib: for DSTNILX platfoms (UDS100
only at the moment)
cbx.lib: for V40 platforms (E2, DR1)
Prototype:
io.h
Syntax:
Parameter:
Return value:
None
Programming Environment 67
EEPROM Functions
These functions read and write data into setup or configuration memory. Typically, the
programmer will change values in Setup[], then use StoreCMOS() to save these values. If you do
not use StoreCMOS() and use EE_Write() directly, be sure you do not write over the first 6 bytes
of setup memory (kernel dependent information is stored there). All of these functions are
automatically indexed into page 1 on the XPort. However, it is possible to overwrite the firmware
image.
EE_Read
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
kernel.h
Syntax:
Parameter:
Return value:
EE_Write
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
kernel.h
Syntax:
Parameter:
Return value:
StoreCMOS
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
kernel.h
Syntax:
Parameter:
None
Return value:
None
68 Programming Environment
Flash Functions
These functions are used to write data into the WEB locations. On XPort, these functions
automatically index to the correct page.
CopyEEPR
Description:
Location:
kern100.lib, kernMAC.lib
uds.lib: for the AMD platforms(UDS10,
Mini REv2, Micro, FL, ...)
ec1.lib: for DSTNILX platfoms (UDS100
only at the moment)
cbx.lib: for V40 platforms (E2, DR1)
Prototype:
flash.h
Syntax:
void CopyEEPR(void)
Parameter:
None
Return value:
None
flsh_clr
Description:
Location:
kern100.lib, kernMAC.lib
uds.lib: for the AMD platforms(UDS10,
Mini REv2, Micro, FL, ...)
ec1.lib: for DSTNILX platfoms (UDS100
only at the moment)
cbx.lib: for V40 platforms (E2, DR1)
Prototype:
flash.h
Syntax:
Parameter:
Return value:
None
Programming Environment 69
flsh_pgm
Description:
Location:
kern100.lib, kernMAC.lib
uds.lib: for the AMD platforms(UDS10,
Mini REv2, Micro, FL, ...)
ec1.lib: for DSTNILX platfoms (UDS100
only at the moment)
cbx.lib: for V40 platforms (E2, DR1)
Prototype:
flash.h
Syntax:
Parameter:
Return value:
None
flsh_typ
Description:
Location:
kern100.lib, kernMAC.lib
uds.lib: for the AMD platforms(UDS10,
Mini REv2, Micro, FL, ...)
ec1.lib: for DSTNILX platfoms (UDS100
only at the moment)
cbx.lib: for V40 platforms (E2, DR1)
Prototype:
flash.h
Syntax:
Parameter:
Return value:
Flash type
70 Programming Environment
get_file_curr_pos
Description:
Location:
serfl.lib, parfl.lib
Prototype:
filesys.h
Syntax:
Parameter:
Return value:
get_file_len
Description:
Location:
serfl.lib, parfl.lib
Prototype:
filesys.h
Syntax:
Parameter:
Return value:
get_file_start_pos
Description:
Location:
serfl.lib, parfl.lib
Prototype:
filesys.h
Syntax:
Parameter:
Return value:
r_close
Description:
Close a file..
Location:
serfl.lib, parfl.lib
Prototype:
filesys.h
Syntax:
Parameter:
Return value:
always 0
Programming Environment 71
r_open
Description:
Opens a file.
Location:
serfl.lib, parfl.lib
Prototype:
filesys.h
Syntax:
Parameter:
fname = filename
Return value:
r_read
Description:
Location:
serfl.lib, parfl.lib
Prototype:
filesys.h
Syntax:
Parameter:
Return value:
set_file_curr_pos
Description:
Location:
serfl.lib, parfl.lib
Prototype:
filesys.h
Syntax:
Parameter:
Return value:
0 = success
-1 = error
72 Programming Environment
Location:
kern100.lib, kernMAC.lib
Prototype:
random.h
Syntax:
WORD rand(void)
Parameter:
None
Return value:
Description:
Location:
kern100.lib, kernMAC.lib
Prototype:
random.h
Syntax:
Parameter:
Return value:
None
srand
Programming Environment 73
Encryption Functions
tf_byte_stream
Description:
Location:
crypt.lib, crstub.lib
Prototype:
2fish.h
Syntax:
Parameter:
Return value:
None
tf_block_decrypt
Description:
Location:
crypt.lib, crstub.lib
Prototype:
2fish.h
Syntax:
Parameter:
Return value:
None
tf_block_encrypt
Description:
Location:
crypt.lib, crstub.lib
Prototype:
2fish.h
Syntax:
Parameter:
Return value:
None
74 Programming Environment
tf_key_prep
Description:
Location:
crypt.lib, crstub.lib
Prototype:
2fish.h
Syntax:
Parameter:
Return value:
None
Programming Environment 75
Debug Functions
Monitor
Description:
Start ProMon.
Location:
kern100.lib, kernMAC.lib
Prototype:
kernel.h
Syntax:
void Monitor(void)
Parameter:
None
Return value:
None
Command
D
E
F
C
H, ?
I
M
O
Function
Dump memory.
D segment:offset
Edit memory contents.
E segment:offset data
Fill memory
F segment:offset,length data
Clear flash page.
C segment
Help. Print command list.
Port input.
I port
Move memory.
M 0000:source_offset,length->destination_offset
Port output.
O port data
Quit ProMon.
Print timer.
Verify memory.
Compares page 1 (0000:1000) with page 8 (0000:8000)
Echo mode.
syslog
Description:
Location:
tools.c
Prototype:
./syslog.h
Syntax:
Parameter:
Return value:
None
76 Programming Environment
SNMP
Introduction
Since it was developed in 1988, the Simple Network Management Protocol has become the de facto standard for
internetwork management. Because it is a simple solution, requiring little code to implement, vendors can easily
build SNMP agents to their products. SNMP is extensible, allowing vendors to easily add network management
functions to their existing products. SNMP also separates the management architecture from the architecture of
the hardware devices, which broadens the base of multivendor support. Perhaps most important, unlike other socalled standards, SNMP is not a mere paper specification, but an implementation that is widely available today.
For more detailed information on the SNMP protocol please read the file:
Management Protocol.htm in the directory demo11.
RS-232
snmpscan()
Project
variables
Kernel SNMP
module
(Agent)
LAN
SNMP
Manager
SNMP 77
78 SNMP
SNMP environment
In the file snmp.c some static variables are defined for the SNMP environment.
Enterprise ID
A private MIB must contain a unique enterprise ID. For the example we have used a fake company called
MAGIC7 with an enterprise ID of 7777. This enterprise ID must be declared as static variable enterpriset[]:
BYTE enterpriset[ ] = { 6, 7, 0x2b, 6, 1, 4, 1, 188, 97 };
SNMP object
Use the global variable S_obj[] to point at the start of the MIB tree handled by the device server:
GLOBAL BYTE S_obj[ ] = { 9, 0x2b, 6, 1, 4, 1, 188, 97, 1, 2 };
In our examples this is the MIB tree iso.org.dod.internet.private.enterprises.magic7.products.powersrc.
Traps variables
For each generated trap we have defined an OID. This OID will be used when generating the trap message,
which can also hold optional measurement values.
Example:
BYTE onbvar[] = {
/* 1st char is always 6; 2nd length of objid excl. length */
6, 8, 0x2b, 6, 1, 2, 1, 1, 1, 0,
/* System Description
*/
6, 8, 0x2b, 6, 1, 2, 1, 1, 3, 0
/* SysUpTime
*/
}; /* object-id for standard-traps */
BYTE onbvar2[] = {
6, 12, 0x2b, 6, 1, 4, 1, 188, 97, 1, 2, 3, 1, 0 /* Error-String */
}; /* object-id for customer specific Trap 2 */
BYTE onbvar3[] = {/* 1st char is always 6; 2nd length of objid excl. length */
6, 12, 0x2b, 6, 1, 4, 1, 188, 97, 1, 2, 3, 1, 0, /* Error-String */
6, 12, 0x2b, 6, 1, 4, 1, 188, 97, 1, 2, 1, 0, 0 /* Error-Value */
/* This byte must be set to passed variable ---^
*/
}; /* object-id for customer specific Trap 3 */
The OID onbvar[] is used with the coldstart trap, onbvar2[] is used with the serial communication traps while
onbvar3[] is used when sending an alarm trap message.
The function ps_trap() is called from various places in snmpscan() and each time different
parameters are passed causing the appropriate data to be included in the trap message.
SNMP 79
)
+ 22, 162, 162, outbuf, rc );
)
+ 26, 162, 162, outbuf, rc );
)
+ 30, 162, 162, outbuf, rc );
In this example the traps will be send to up to three manager IP addresses. A specific OID will be send as trap
depending on the spec variable.
80 SNMP
if (IPflag == 0)
{
return(1);
}
*/
*/
/*
Check SNMP Community
if community is Write Community - read and write access - return (0)
if community is Read Community - read only access
- return (2)
if community not known - no access
- return (1)
we need to check the write community first, this is because if the
read and the write communities have the same name and read is checked
first, write requests are blocked as a read only access is returned
*/
if(strncmp(community, PS.wt_community, comlen) == 0)
/* write ? */
{
return(0);
/* read-write access */
}
else
{
if(strncmp(community, PS.rd_community, comlen) == 0)
/* read ? */
{
return(2);
/* read-only access */
}
else
/* then: not known */
{
return(1);
/* access denied
*/
}
}
}
SNMP 81
Private MIB
MIB tree definition
The private MIB tree inside the CoBox, as defined in snmpmib.h, must exactly match the MIB file
DEMOSNMP.MIB that is used in the MIB browser. The example shows the beginning of a MIB file with
corresponding part in CoBox source.
You dont have to use the same names inside the MIB and priv_mib but this will help understanding the
structure.
MIB file :
magic7
products
powersrc
readings
settings
traps
tables
OBJECT
OBJECT
OBJECT
OBJECT
IDENTIFIER
IDENTIFIER
IDENTIFIER
IDENTIFIER
::=
::=
::=
::=
{
{
{
{
powersrc
powersrc
powersrc
powersrc
1
2
3
4
}
}
}
}
dw 1, 7777
asm magic7:
asm dw S_SEQU
dw 1, 1
asm products:
asm dw S_LEER
asm dw S_SEQU
dw 1, 2
asm
asm
asm
asm
asm
dw 1, 4
powersrc:
dw S_SEQU
dw S_SEQU
dw S_SEQU
dw S_SEQU
, 7776
, magic7
, products
, 1
, powersrc
,
,
,
,
readings
settings
traps
tables
The enterprise name is magic7 and the enterprise identifier is 7777. The header file has to declare a structure with
7776 empty entries (S_LEER) and one for the enterprise ID. S_SEQU points to the enterprise magic7, which
contains only one entry products. products contains two entries (dw 1, 2): one is empty and the 2nd
points to powersrc. powersrc itself contains four entries (dw 1, 4).
82 SNMP
Read-only variables
Until now only the MIB structure is defined. The next part shows the definition of some read-only variables.
MIB file:
psPowerReading OBJECT-TYPE
SYNTAX
ACCESS
STATUS
DESCRIPTION Power output
::= { readings 1 }
psVoltageReading OBJECT-TYPE
SYNTAX
ACCESS
STATUS
DESCRIPTION Voltage output
::= { readings 2 }
psCurrentReading OBJECT-TYPE
SYNTAX
ACCESS
STATUS
DESCRIPTION Current output
::= { readings 3 }
psTempReading OBJECT-TYPE
SYNTAX
ACCESS
STATUS
DESCRIPTION Temperature
::= { readings 4 }
INTEGER(0..400000000)
read-only
mandatory
INTEGER(0..65535)
read-only
mandatory
INTEGER(0..65535)
read-only
mandatory
INTEGER(0..65535)
read-only
mandatory
readings: dw 1, 4
dw S_INT + S_LONG + S_RAM, PS.PowerReading
dw S_INT +
S_RAM, PS.VoltageReading
dw S_INT +
S_RAM, PS.CurrentReading
dw S_INT +
S_RAM, PS.TempReading
SNMP 83
84 SNMP
Description
S_SEQU
S_LEER
S_RAM
S_ROM
S_OCTSTR
S_INT
S_LONG
S_TIPADR
Field is an IP address
S_TCTR
Field is a counter
S_TGAUGE
Field is a gauge
S_TTICK
Field is a timer
S_AFUN
Read/write variables
By adding the S_SET to the variable type it becomes writable, meaning that the value of it can be changed
directly from the SNMP browser (manager). It is also possible to attach a separate function to handle variable
changes. In this way extra checking and validation can be added.
Private MIB tree:
asm
asm
asm
asm
asm
asm
asm
asm
Settings: dw 1, 7
dw S_INT + S_LONG + S_RAM + S_SET
dw S_INT + S_LONG + S_RAM + S_SET
dw S_INT + S_RAM + S_SET
dw S_AFUN
dw S_INT + S_RAM + S_SET
dw S_INT + S_RAM + S_SET
dw S_AFUN
,
,
,
,
,
,
,
PS.PowerUpperLimit
PS.PowerLowerLimit
PS.VoltageUpperLimit
_voltage_Lower
PS.TempUpperLimit
PS.TempLowerLimit
_send_command
SNMP 85
Tables
MIB definition for a table:
asm Tables:
dw 1, 1
asm dw S_SEQU, historyTable
asm historyTable: dw 0, 1
asm dw S_SEQU, historyEntry
asm historyEntry: dw 2, 4
asm dw S_AFUN, _history_table
86 SNMP
history_table( WORD * op )
{
WORD i;
if( ( scon.flags & FLAG_SET ) &&
( !( scon.flags & FLAG_PASS ) ) ) return S_readOnly;
if( scon.flags & FLAG_INCR )
{
/* if increment */
if( scon.objend == op )
{
i = *op = 1;
scon.objend++;
}
else
{
i = *op + 1;
}
*op = i;
}
else
{
/* non incremental */
i = *op;
}
scon.objend = op + 1;
if( i > PS_HIST )
{
op[ -1 ]++;
i = *op = 1;
}
switch( op[ -1 ] )
{
case 1: /* Volt */
snmp_leaf( S_INT + S_RAM, &PS.hist[ i ].volt );
break;
case 2: /* Amp */
snmp_leaf( S_INT + S_RAM, &PS.hist[ i ].amp );
break;
case 3: /* Temp */
snmp_leaf( S_INT + S_RAM, &PS.hist[ i ].temp );
break;
case 4: /* TimeStamp */
snmp_leaf( S_TTICK + S_RAM + S_LONG,
&PS.hist[ i ].tstamp );
break;
default:
return S_noSuchName;
}
return 0;
}
SNMP 87
Utility Programs
cbxfilt
Program Description
The goal of cbxfilt.exe is to save memory, storing strings only once.
cbxfilt.exe extracts text lines from the source file(s) and creates two new files texte.asm and
texte.h, which are included into the project.
First the program searches for lines containing putcstn() or putcstr().
putcstn(T_TXT1/*Demo project*/)
Then cbxfilt.exe creates a table with label (T_TXT1) and corresponding string (Demo project). If
the same string is used next time, you only need to write the label and the corresponding text will
be printed:
putcstn(T_TXT1)
Command Syntax
cbxfilt file1 [file2 file3]
r2h
Program Description
r2h Converts CoBox .ROM files into Intel hex format .HEX.
Command Syntax
r2h romfile
e2i
Program Description
e2i converts linker output <Project name>.EXE into .ROM file <Project name>.ROM.
Command Syntax
e2i Name Type Target Version
Name: Project name
Type: TFTP password
Target: cbx, uds, ec1, xpt
Version: version filename
Example:
e2i demo 3Q ec1 myVers
88 Utility Programs
Web2CoB
Program Description
Web2CoB is a command line utility that collects files from a given directory and puts it into one
COBOX.COB file. After uploading the COBOX.COB file to a CoBox via TFTP into memory
areas WEB0WEB6 it can be used as a CoBox web server directory.
WEB0 is located in RAM and loose its contents after a reset. WEB1WEB6 is stored in the flash
memory.
When an http request occurs the memory areas are checked for the file name starting in WEB0.
The first matching file will then be send back.
Command Syntax
Web2CoB [/o <output file>] [/d <directory>]
Output file:
Directory:
Utility Programs 89
Length [Bytes]
Magic
Remarks
0 = end of directory,
nothing follows.
max. length of file name
is 255 chars
90
File (1)
File (2)
Demo 1
In this version, the program is only a so-called hello world
program that demonstrates a very basic functionality. In this
case, it is a simple template of the necessary infinite loop with
the nice () function.
Demo 2
In this version, the program begins the exchange of UDP packets in
a classic serial tunnel (port number 1234).
Demo 3
In this version, the program adds the use of the setup menu, and
setup data array to hold remote socket information.
Demo 4
In this version, the program adds the exchange of TCP packets to
the above demo project.
Demo 5
In this version, the program joins together the two FIFO for
simple data handling.
Demo 6
In this version, the program adds the ability to use passive or
active TCP connections (listen or connect).
Demo 7
In this version, the program adds DNS resolver functionality.
Demo 8
In this version, the program changes the serial port reading for
non-buffered IO operations.
Demo 9
In this version, adds TwoFish encryption to LTX, DLX and U200.
Demo 10
This is a complete program change and only supports the Xport and
WiPort. This demo is used to control the configurable pins of the
Xport & WiPort. This demo includes a Java based applet, which can
be used to manipulate the pins.
Demo 11
This program is an example of implementing a private SNMP MIB.
Demo 12
This program is an example of implementing a cgi callback through
the HTTP server. To use this demo, you must tftp the cobox.cob
file to WEB1. Then, use a browser to connect to the CoBox
http://<ip_address>/test.html. After submitting your query,
youll have 10 seconds to input serial data as the response. (A
loopback connector would work.)
Browsing to http://<ip_address>/testjs.html is an example of using
Java Script in an application. In this example, the serial
response is placed into a Java Script variable.
Demo13
This program is an example of implementing SMTP, which is a basic
way to send mail.
Demo14
This program is an example of implementing Rijndael encryption.
This demo is for encrypted Xports, SDS and Micro-100s only, and
may not be in all kits.
Demo15
This program is an example of implementing a SNTP client. This is
a simple way of receiving network time. NOTE: this demo has not
had extensive testing performed.
Demo16
This program is an additional example of implementing a SNMP
private MIB. NOTE: this demo has not had extensive testing
performed.
ARP Handler
If this is an ARP packet, CoBOS will act on it locally. If it's not a locally handled packet it is
passed to a default arp handler (pkt_defarp() if defined).
IP Handler
IP packets have a larger processing procedure. If the packet is IP addressed to the CoBox (or a
broadcast or multicast), the packet continues processing; otherwise it is passed to the default IP
handler (pkt_defip() if defined).
Only three types of IP packets are handled: ICMP, UDP and TCP. Processing within these
sections is controlled by the global parameter tc_para.
ICMP Handler
If the packet is ICMP, and (tc_para & 2) is true, call pkt_defip(), otherwise handle the
packet locally. After local processing of ICMP, if (tc_para & 8) is true, then call
pkt_defip().
UDP Handler
If the packet is UDP, and a handler is registered (udp_register()), call the handler. Then if
(tc_para & 1) is true and it's a broadcast, multicast or no port handler is registered call
pkt_defip().
TCP Handler
If the packet is TCP and (tc_para & 4) is true, call pkt_defip(), otherwise handle the
packet locally.
After processing ICMP, UDP or TCP, if the packet is a broadcast or multicast, call pkt_defip(), if it
was not previously called.
If pkt_defip or pkt_defarp are not set, pkt_default() is called in it place - if its set.
Finally, pkt_bridge() is called for all packets if set.
{
/*
/*
/*
/*
length */
to address */
from address */
ethernet type, 0x800-IP 0x806-ARP */
}
void bridge_default(BYTE *rb)
{
/* Insert your handler code here */
}
GetSendBuf
Description:
Location:
<platform specific>.lib
Prototype:
nethw.h
Syntax:
BYTE *GetSendBuf(void);
Parameter:
None
Return value:
FreeSendBuf
Description:
Location:
<platform specific>.lib
Prototype:
nethw.h
Syntax:
Parameter:
Return value:
None
_send_block
Description:
Location:
<platform specific>.lib
Prototype:
Syntax:
Parameter:
Return value:
Always 0
For example:
{
BYTE *buf;
buf = GetSendBuf();
CoBOS Loading
Serial Flash Devices
XPort, Micro-100 (CPK580) and earlier than V6
Serial flash page 5 contains a small "intermediate loader". The main 64KB CoBOS image is stored at
page 6+. A damaged intermediate loader (checksum error of either the intermediate loader or the
CoBOS image) will cause the DSTni-EX to attempt a network boot. A DSTni-LX will spin on the
serial port for download.
Load Process:
1. The on-chip loader copies the image described in the header to the load location described in the
header (segment 0x0008 for XPort and Micro-100).
2. On-chip loader turns over control to the copied image (intermediate loader).
3. The intermediate loader copies the CoBOS image to RAM3.
4. The intermediate loader turns over control to CoBOS in RAM3.
UDP_Echo
dhcpr
tf_recv
snmp_input
dns_reply
GPIOUDPrec
fw_recv