📄 pcl4w.usr
字号:
If you are using a modem, you also need to be concerned about initializing
your modem correctly and handling any required flow control. Refer to the
"Talking to Your Modem" chapter for detailed information.
PCL4W Users Manual Page 5
1.3 Installation
(1) Before installation of PCL4W , your Windows C compiler should already be
installed on your system and tested. If you are not familiar with makefiles,
refer to your compiler manual. Examine the file "FILES.LST" for a list of
the distribution files.
(2) Make a backup copy of your distribution disk. Put your original
distribution disk in a safe place.
(3) Create a work directory on your work disk (normally your harddisk). For
example, to create a work directory named PCL4W, we first log onto the work
disk and then type:
MKDIR PCL4W
(4) Copy all the files from your backup copy of the distribution disk to
your work directory. For example, to copy from the A: drive to your work
directory, we type:
CD PCL4W
COPY A:*.*
(5) Compile SIMPLE.C and link with the PCL4W library (PCL4W.LIB).
Makefiles are provided for each of the supported compilers. If you are
unfamiliar with makefiles, please consult your compiler manual. After
compiling with the provided makefiles, you can convert to a Microsoft
Workbench or Borland Integrated Development Environment project file if you
wish. Compile as follows (use NMAKE not MAKE in (a) below):
(a) Microsoft C: Type NMAKE SIMPLE._M_
(b) Borland C: Type MAKE -fSIMPLE._B_
SIMPLE.C should compile and link without any problems.
(6) The recommended way to test SIMPLE is to run it on two computers
connected by a null modem cable. Whatever is typed on one computer should
be displayed on the other. If you don't have two computers, you can use
SIMPLE to talk to your modem. Sending an "AT" to the modem should result in
an "OK" being sent back.
(7) If you have downloaded the TERM test program (WTERM10.ZIP), be sure to
create a separate directory and copy all TERM files into it. The TERM
program uses some functions of enhanced capability with the same name as
used by the SIMPLE program.
Once you have become familiar with the PCL4W files and have compiled and
tested SIMPLE, you may want to re-organize your files into sub-directories.
PCL4W Users Manual Page 6
2.0 Library Organization
The PCL4W library is organized into six categories of functions. Refer to
the PCL Reference Manual (PCL4W.REF) for details on individual functions.
2.1 Configuration
There are three functions in the configuration category. SioPorts sets the
number of PC and DigiBoard ports. SioUART is used to change the UART base
address for a communications port to a non-standard address, while SioIRQ is
used to assign a nonstandard IRQ line to a port. (See the chapter IBM
Communications Ports for more details on standard UART addresses and IRQ
lines).
The configuration functions SioPorts, SioUART and SioIRQ must be called
before calling any other library functions. Be very careful when using
these functions. Remember that your serial hardware must support the UART
and IRQ that you specify. Always test any new configuration immediately.
SioPorts -- Sets number of PC and DigiBoard ports.
SioUART -- Sets the UART base address.
SioIRQ -- Assigns an IRQ line to a port.
THE IRQ GOLDEN RULE: You may open (via SioReset) only one port per IRQ
(except for the DigiBoard).
2.2 Initialization & Termination
There are eight functions in the initialization and termination category.
Together, SioParms, SioFIFO, SioRxBuf, SioTxBuf, and SioReset initialize
your serial communications system. Your application must call SioParms and
SioRxBuf before calling SioReset, and SioReset must be called before any
serial I/O processing can be done.
After initialization, SioParms and SioBaud can be called again to change the
communications parameters without resetting the serial port. SioFlow can be
called to enable hardware flow control.
Before exiting from your application, SioDone must be called. Failure to
call SioDone can crash your system later.
SioRxBuf -- Sets up receive buffer.
SioTxBuf -- Sets up transmitter buffer.
SioFIFO -- Sets the interrupt level for the INS16550.
SioParms -- Sets parity, stop bits, and word length.
SioReset -- Initialize a serial port for processing.
SioDone -- Terminates further serial processing.
SioBaud -- Sets the baud rate of the selected port.
SioFlow -- Enables / disables flow control.
PCL4W Users Manual Page 7
2.3 Modem Control & Status
There are eight functions in the modem control and status category which
provide your application with complete control over the status and control
bits of your modem.
There are two modem control bits, "Data Terminal Ready" (DTR) and "Request
To Send" (RTS). These bits can be read, set, or cleared by SioDTR and
SioRTS.
There are four modem status bits, "Data Set Ready" (DSR), "Clear To Send"
(CTS), "Ring Indicator" (RI), and "Data Carrier Detect" (DCD). SioModem can
read any of the modem status bits. SioDSR, SioCTS, SioRI, and SioDCD can
only read their respective modem status bit.
Refer to the chapter entitled "RS232 Signals" for a discussion of each of
the control and status bits.
SioDTR -- Set, clear, or read the Data Terminal Ready (DTR) bit.
SioRTS -- Sets, clears, or reads the Request to Send (RTS) line.
SioModem -- Reads the modem status register.
SioDSR -- Reads the Data Set Ready (DSR) modem status bit.
SioCTS -- Reads the Clear to Send (CTS) modem status bit.
SioDCD -- Reads the Data Carrier Detect (DCD) modem status bit.
SioRI -- Reads the Ring Indicator (RI) modem status bit.
SioRead -- Reads the contents of the 7 UART registers.
2.4 Serial I/O
There are eight library functions in the serial I/O category. Together,
these functions give the programmer complete control over serial I/O. Higher
level functions such as protocols and smart modem communications can be
completely implemented in terms of these functions. Refer to the example
code.
SioGetc and SioPutc perform all the actual serial I/O. SioUnGetc "ungets"
the last serial byte read. SioRxFlush clears the receive queue while
SioTxFlush clears the transmit queue. SioLine can be used to test for UART
errors. SioRxQue returns the number of bytes in the receive queue while
SioTxQue returns the number of bytes in the transmit queue.
SioGetc -- Reads the next character from the serial line.
SioPutc -- Transmit a character over a serial line.
SioUnGetc -- "Un-gets" (puts back) a specified character.
SioRxFlush -- Flush (clears) the receive buffer.
SioRxQue -- Returns the number of characters in the RX queue.
SioTxFlush -- Flush (clears) the transmit buffer.
SioTxQue -- Returns the number of characters in the TX queue.
SioLine -- Reads the line status register.
PCL4W Users Manual Page 8
2.5 Error Detection
There are two functions in the error detection category. They are concerned
with detecting or reporting communications errors. Use of these functions
can make your application significantly more robust.
SioBrkSig can read or modify the UART break bit. This is useful for
signalling the remote system that a fatal condition has occurred.
SioLoopBack can be used to test the integrity of your UART.
There is also a file SIOERROR.C which contains the function SioError which
displays a error message corresponding to an error code returned from a
PCL4W function (every PCL4W function returns a code).
SioBrkSig -- Asserts, cancels, or detects the RS232 BREAK signal.
SioError -- Displays error in text.
SioLoopBack -- Performs a UART loopback test.
2.6 General Support
There is one function in the general support category. SioInfo returns the
version number of the library and whether transmitter interrupts are
enabled.
SioInfo -- Returns the library version & memory model.
PCL4W Users Manual Page 9
3.0 Library Overview
3.1 Dynamic Link Libraries
PCL4W is provided as a dynamic link library (DLL). A DLL is characterized by
the fact that it need not be loaded until required by an application program
and that only one copy of the DLL is necessary regardless of the number of
application programs that use it. Contrast this to the traditional static
library which is bound to each and every application that uses it at link
time.
Since PCL4W is a DLL, only one copy of the PCL4W code & data is loaded into
memory regardless of the number of applications programs that use it.
For example, more than one instance of the test program simple can be
started. All copies of SIMPLE can run concurrently as long as each uses a
different COM port.
3.2 DOS Protected Mode Interface
Windows itself uses what is known as the "DOS Protected Mode Interface"
(DPMI) to control changing states (protected vs real), controlling the
interrupt system, etc. This is necessary because Windows itself typically
runs in a protected state and must change to real state in order to use
MSDOS services.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -