home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hall of Fame
/
HallofFameCDROM.cdr
/
prog1
/
zmnp11.lzh
/
ZMNP.DOC
< prev
next >
Wrap
Text File
|
1990-02-08
|
19KB
|
661 lines
[XYZ]MODEM and MNP2 library interface description.
Giles Todd February 8, 1990
1.0 Basic async comms functions.
1.1 int connect (int rate, int data, int parity, int stop, int
port, int handshake)
where
rate is the speed of the physical connection:
1 = 110 bps
2 = 300 bps
3 = 600 bps (no MNP)
4 = 1200 bps
5 = 2400 bps
6 = 4800 bps (no MNP)
7 = 9600 bps (no MNP)
8 = 19200 bps (no MNP)
9 = 38400 bps (no MNP, may not work on some PCs)
10 = 56000 bps (no MNP, may not work on some PCs)
11 = 115200 bps (no MNP, may not work on some PCs)
data is the number of data bits (5..8)
parity is the selected parity
0 = NONE
1 = ODD
3 = EVEN
5 = MARK
7 = SPACE
8 bit data, no parity is recommended for use with
the file transfer protocols.
If MNP is to be used, the only valid settings are:
8 bit data, no parity
7 bit data, even, odd, mark or space parity.
stop the number of stop bits (1 or 2)
NB: if 5 data bits are used, 1 1/2 stop bits are
automatically selected.
port is the COM port number (1 and 2 only)
handshake is the hardware handshaking flag
0 = no RTS/CTS handshaking
1 = use RTS/CTS handshaking
1
This function returns an integer with the following meaning:
0 = success, 8250 initialised
-64 = invalid rate
-65 = invalid data
-66 = invalid parity
-67 = invalid stop
-68 = invalid port
-69 = invalid handshake
This function initialises the 8250 and the PC interrupt
vectors.
1.2 void hangup (void)
Hangs up the physical link by dropping DTR. If using an MNP
link, call mnpdisconnect () before calling this function.
1.3 void disconnect (void)
Hangs up the physical link and restores the original interrupt
environment and 8250 settings. If using an MNP link, call
mnpdisconnect () before calling this function. Use before
exiting from your program.
1.4 int send (unsigned char *sndbuf, unsigned int buflen)
where
sndbuf points to the buffer where the data to be sent is
stored.
buflen is the maximum number of data bytes to be sent.
The function's return value is a count of the bytes actually
sent. This may differ from the count requested to be sent.
send (NULL, 0) may be used to flush the output buffer.
This function may only be used _outside_ an MNP connection.
Use the mnpsend () equivalent during an MNP connection.
2
1.5 int receive (unsigned char *rcvbuf, unsigned int buflen)
where
rcvbuf points the the user receive buffer. This buffer must
be at least as long as buflen.
buflen is the number of bytes to copy into the user receive
buffer.
The function's return value is is a count of the bytes actually
copied into the receive buffer. This may differ from the count
requested to be copied.
This function may only be used _outside_ an MNP connection.
Use the mnpreceive () equivalent during an MNP connection.
1.6 void bufstat (unsigned short *s_free, unsigned short *r_ready)
where
s_free points to a variable which is filled in with the
number of bytes free in the transmit buffer
r_ready points to a variable which is filled in with the
number of bytes ready to be read from the receive
buffer
This function returns information about the state of the
transmit and receive buffers.
This function may only be used _outside_ an MNP connection.
Use the mnpstatus () equivalent during an MNP connection.
1.7 unsigned char linestat (void)
returns a copy of the 8250 line status register.
bit set meaning
0 Rx ready
1 overrun error
2 parity error
3 framing error
4 BREAK detect
5 Tx buffer empty
6 Tx empty
7 Always 0
3
1.8 unsigned char modemstat (void)
returns a copy of the 8250 modem status register.
bit meaning
0 if set, CTS changed since last read
1 if set, DSR changed since last read
2 if set, RI changed since last read
3 if set, DCD changed since last read
4 absolute state of CTS input
5 absolute state of DSR input
6 absolute state of RI input
7 absolute state of DCD input
4
2.0 MNP level 2 functions.
Please note that after an MNP link has been established (but
not after it has been terminated), it must be maintained by
calling one of mnpsend (), mnpreceive (), mnpstatus () or
mnpbreak () every 250ms or so (recommended although not
critical). If no data is being transferred and your program is
waiting for user input, this may be achieved by calling
mnpstatus () on each pass through a keyboard polling loop.
[XYZ]MODEM file transfers on an MNP link will perform this
polling automatically. Future versions of this library may
perform this polling automatically as part of a timer interrupt
service routine.
Note also that the mnpxxx () data transfer and status functions
are only valid if the call to mnpconnect () succeeds.
2.1 int mnpconnect (unsigned int mode)
where
mode is the 'role' to play:
0 = link initiator (caller)
1 = link acceptor (answerer)
This function returns an integer with the following meaning:
0 = success (link established)
-64 = failure, unknown error
-65 = failure, timeout
-66 = failure, no carrier
-67 = failure, bad data format
-70 = failure, incompatible MNP
-72 = failure, remote protocol error
This function is used to establish an error corrected link. It
is called after the physical link has been established (i.e.
carrier present) by a call to connect (), the sending of the
appropriate dialling sequence via send () and the detection of
carrier (either by receiving a CONNECT message from the modem
or by reading the modem status). It can take up to five
seconds for the MNP negotiation to complete. Note that this
function _must_ be called within four seconds of the physical
connection being made.
2.2 void mnpdisconnect (void)
This function is used to terminate the error corrected link.
It must be called just prior to hanging up with a disconnect ()
or hangup () call.
5
2.3 int mnpsend (unsigned char *sndbuf, unsigned int buflen)
where
sndbuf points to the buffer where the data to be sent is
stored.
buflen is the maximum number of data bytes to be sent.
If the function's return value is positive, it is a count of
the bytes actually sent. This may differ from the count
requested to be sent. A negative return code indicates an
error as follows:
-64 = link terminated, retransmission limit exceeded
-65 = link terminated, unable to send
-66 = link terminated, no carrier
-67 = link terminated, remote disconnect
mnpsend (NULL, 0) may be used to flush the output buffer.
2.4 int mnpreceive (unsigned char *rcvbuf, unsigned int buflen)
where
rcvbuf points the the user receive buffer. This buffer must
be at least as long as buflen.
buflen is the number of bytes to copy into the user receive
buffer.
If the function's return value is positive, it is a count of
the bytes actually copied into the receive buffer. This may
differ from the count requested to be copied. A negative
return code indicates an error as follows:
-64 = link terminated, retransmission limit exceeded
-65 = link terminated, unable to send
-66 = link terminated, no carrier
-67 = link terminated, remote disconnect
6
2.5 void mnpstatus (struct link_stat_blk *stat)
where
struct link_stat_blk /* defined in ZMNP.H */
{
unsigned short p_status;
unsigned short l_status;
unsigned short s_count;
unsigned short r_count;
unsigned short all_sent;
} *stat;
This function fills in the fields of the user's status
structure as follows:
p_status physical connection status
0 = not connected (no carrier)
1 = connected (carrier present)
l_status MNP link status
0 = MNP link not established
1 = MNP link established
s_count the number of bytes free in the MNP transmit buffer.
This indicates the maximum number of bytes which can
be sent by a mnpsend () call.
r_count the maximum number of bytes which can be read by a
mnpreceive () call.
all_sent data sent and successfully acknowledged flag.
0 = all data not sent
1 = all data sent
2.6 int mnpbreak (void)
Sends a break signal to the remote DTE. The return code is
interpreted as follows:
0 = break initiated
-64 = link terminated, retransmission limit exceeded
-65 = link terminated, unable to send
-66 = link terminated, no carrier
-67 = link terminated, remote disconnect
-75 = break not supported (remote did not negotiate
break support for this link)
-76 = previous break still in progress
Note that mnpbreak () is only valid when sent to a MNP modem.
The current version of this library does not yet support
application notification of a received break condition.
7
3.0 [XYZ]MODEM functions.
3.1 int sendfile (char protocol, char *options, char *filenames[],
void (*reporter) (int type, void *data))
Sends files. Returns 0 if files transmitted successfully
otherwise returns a negative error code:
-1 invalid option
-2 user abort
-3 no carrier
Parameters:
protocol the file transfer protocol:
'z' = ZMODEM
'y' = YMODEM batch
'x' = XMODEM
options a null terminated string of characters denoting
various protocol options:
'+' = append file to existing destination file
(ZMODEM)
'a' = convert <NL> to <CR/NL> in ASCII file
'b' = binary file transfer
'c' = send command, wait for completion
(ZMODEM). The command string should be
delimited by '#' characters.
'd' = change '.' to '/' in pathnames
(YMODEM/ZMODEM)
'e' = escape all control characters (ZMODEM)
'f' = send full pathname (YMODEM/ZMODEM)
'i' = send command, no wait for completion
(ZMODEM). The command string should be
delimited by '#' characters.
'k' = 1024 byte packets (YMODEM)
'L' followed by a number = limit subpacket
length to number bytes. The number must
be followed by a whitespace character
(ZMODEM)
'l' followed by a number = limit frame length
to number bytes (l >= L). The number must
be followed by a whitespace character
(ZMODEM)
'n' = send only if source newer (ZMODEM)
'N' = send only if source newer or longer
(ZMODEM)
'o' = use 16 bit CRC instead of 32 bit (ZMODEM)
'p' = don't overwrite existing target (ZMODEM)
'r' = resume interrupted file transfer (ZMODEM)
'q' = quiet (no progress report)
'u' = erase source file after transmission
8
'v' = provide debugging information. More 'v's,
more debug info (9 max). Information
is appended to the file ZMODEM.LOG in
the current directory.
'w' followed by a number = set window to number
bytes. The number must be followed by a
whitespace character (ZMODEM)
'Y' = overwrite existing destination file but
don't send if no existing destination file
(ZMODEM)
'y' = overwrite existing destination file
unconditionally (ZMODEM)
filenames an array of filenames to be sent. The last string in
this array should be the null string ("") which acts
as an end marker. NB: only one file name is
permitted if the XMODEM protocol is chosen.
reporter a pointer to a user function which makes progress
reports. The type parameter of this function
indicates whether the data parameter points to
character or numeric data. If type = 0, data points
to the filename string. If type = 1, data points to
an unsigned long which gives the number of bytes
transferred so far. If type = 2, data points to a
text string (usually an error message). If you just
want to use the default progress reporting (or no
progress reporting with the 'q' option), set this
parameter to NULL.
NB: the user report function should return as quickly
as possible to avoid losing any MNP link.
3.2 int getfile (char protocol, char *options, char *filename, void
(*reporter) (int type, void *data))
Receives files. Returns 0 if files received successfully
otherwise returns a negative error code:
-1 invalid option
-2 user abort
-3 no carrier
Parameters:
protocol the file transfer protocol:
'z' = ZMODEM
'y' = YMODEM batch
'x' = XMODEM
If the ZMODEM or YMODEM protocols are chosen, the
filename parameter will be ignored and should be
set to NULL. The filename parameter _must_ be
supplied for an XMODEM transfer.
9
options a null terminated string of characters denoting
various protocol options:
'a' = ASCII transfer
'b' = binary transfer
'c' = XMODEM/CRC (XMODEM)
'e' = escape control characters (ZMODEM)
'i' = disallow remote commands (ZMODEM)
'q' = quiet (no progress report)
'v' = provide debugging information. More 'v's,
more debug info (9 max). Information
is appended to the file ZMODEM.LOG in
the current directory.
filename the filename for an XMODEM receive. For YMODEM batch
and ZMODEM, this parameter should be set to NULL.
reporter a pointer to a user function which makes progress
reports. The type parameter of this function
indicates whether the data parameter points to
character or numeric data. If type = 0, data points
to the filename string. If type = 1, data points to
an unsigned long which gives the number of bytes
transferred so far. If type = 2, data points to a
text string (usually an error message). If you just
want to use the default progress reporting (or no
progress reporting with the 'q' option), set this
parameter to NULL.
NB: the user report function should return as quickly
as possible to avoid losing any MNP link.
10