📄 pcl4c.ref
字号:
if(delta=SioModem(Port,DeltaDCD|DeltaCTS))
{status = SioModem(Port,DCD|CTS);
/* display DCD status if changed */
if(delta&DeltaDCD)
{if(status&DCD) c='T';
else c='F';
printf("DCD=%c\n",c);
}
/* display CTS status if changed */
if(delta&DeltaCTS)
{if(status&CTS) c = 'T';
else c='F';
printf("CTS=%c\n",c);
}
}
See Also SioCTS, SioDCD, SioDSR and SioRI.
PCL4C Reference Manual Page 24
SioParms
Function Sets parity, stop bits, and word length.
Syntax int SioParms(Port,ParityCode,StopBitsCode,
WordLengthCode)
int Port; /* Port selected (COM1 - COM4) */
int ParityCode; /* parity code [0,1,2] */
int StopBitsCode; /* stop bits code [0,1] */
int WordLengthCode; /* word length code [0,1,2,3] */
Remarks The SioParms function sets the parity, stop bits, and
word length. If the default parity (none), stop bits
(1), or word length (8) is not acceptable, then they
can be changed by calling SioParms. SioParms can be
called either before or after calling SioReset. See
file PCL4C.H.
Value Description PCL4C.H Name
ParityCode: *0 no parity NoParity
1 odd parity OddParity
3 even parity EvenParity
StopBitsCode: *0 1 stop bit OneStopBit
1 2 stop bits TwoStopBits
WordLengthCode: 0 5 data bits WordLength5
1 6 data bits WordLength6
2 7 data bits WordLength7
*3 8 data bits WordLength8
* = Default
Returns -4 : No such port. Expect 0 to MaxPort.
-7 : Bad parity code selected. Expecting 0 to 2.
-8 : Bad stop bits code. Expecting 0 or 1.
-9 : Bad word length code. Expecting 0 to 3.
Example /* set no parity, 1 stop bit, and 8 bit data for COM1 */
SioParms(COM1,NoParity,OneStopBit,WordLength8);
See Also SioReset.
PCL4C Reference Manual Page 25
SioPorts
Function To set the number of ports, the 1st DigiBoard port
and the DigiBoard status register address.
Syntax int SioPorts(NumberPorts,FirstPort,StatusReg)
int NumberPorts; /* total number of ports */
int FirstPort; /* First DigiBoard port */
int StatusReg; /* DigiBoard Status Register */
Remarks The SioPorts function must be called before ANY other
serial functions. The purpose of the SioPorts function
is to set the total number of ports, the first
DigiBoard port and the DigiBoard status register
address.
Once SioPorts is called, all COM ports starting with
"FirstPort" will be treated as DigiBoard ports. The
default setup is 4 standard PC ports and no DigiBoard
ports [ SioPorts(4,4,0) ].
The standard DigiBoard status register is 0x140 if you
are using an odd IRQ for the DigiBoard, and 0x141 if
you are using an even IRQ for the DigiBoard. If you
change this address on your DigiBoard, be sure to
specify the correct value for "StatusReg".
Returns -4 : No such port. Expect 0 to 9.
0 : No error (sets MaxPort to NumberPorts-1).
Example /* Want 2 PC ports & 8 DigiBoard ports (on PC/8) */
SioPorts(10,COM3,0x140);
/* Want 1 PC port & 4 DigiBoard ports (on PC/4) */
SioPorts(5,COM2,0x140);
See Also SioUART, SioIRQ.
PCL4C Reference Manual Page 26
SioPutc
Function Transmit a character over a serial line.
Syntax int SioPutc(Port,c)
int Port; /* Port selected (COM1 thru COM4) */
char c; /* character to send */
Remarks The SioPutc function transmits one character over the
selected serial line.
If flow control has been enabled, then SioPutc may
return a -1 (time out) if the number of tics specified
in the SioFlow function was exceeded waiting for the
modem to raise CTS.
Refer to the User's Manual for a discussion of flow
control.
If transmitter interrupts are enabled (there are
separate versions of the library for transmitter
interrupts enabled), then the byte is placed in the
transmit buffer, awaiting transmission by the PCL4C
interrupt service routine.
Returns -2 : Port not enabled. Call SioReset first.
-4 : No such port. Expect 0 to MaxPort.
-1 : Timed out waiting for CTS (flow control enabled)
Example char crc;
char buffer[128];
...
/* transmit 128 byte buffer + CRC */
crc = 0;
for(i=0;i<128;i++)
{crc = crcupdate( buffer[i], crc);
SioPutc(Port, buffer[i]);
}
SioPutc(crc);
See Also SioGetc and SioFlow.
PCL4C Reference Manual Page 27
SioRead
Function Reads any UART register.
Syntax int SioRead(Port,Reg)
int Port; /* Port selected (COM1 thru COM4) */
int Reg; /* UART register (0 to 7) */
Remarks The SioReset function directly reads the contents of
any of the 7 UART registers. This function is useful
when debugging application programs, and as a method
for verifying UART contents. Refer to the PCL Users
Manual for a discussion of the 7 UART registers.
The line status register (register 5) can also be read
with SioLine while the modem status register (register
6) can also be read with SioModem.
Refer to the PCL4C User's Manual for a discussion of
the UART registers.
Returns -3 : No buffer available. Call SioRxBuf first.
-4 : No such port. Expect 0 to MaxPort.
Example int Reg; /* UART register */
int Contents; /* contents of UART */
/* print contents of 7 UART registers */
for(Reg=0;Reg<7;Reg++)
{Contents = SioRead(Port,Reg);
printf("COM%d: UART Register %d = %d\n",
1+Port,Reg,Contents);
}
See Also SioLine and SioModem.
PCL4C Reference Manual Page 28
SioReset
Function Initialize a serial port for processing.
Syntax int SioReset(Port,BaudCode)
int Port; /* Port selected (COM1 thru COM4) */
int BaudCode; /* baud code or -1 */
Remarks The SioReset function initializes the selected serial
port. SioReset should be called after calling SioParm
and SioRxBuf but before making any other calls to
PCL4C. SioReset uses the parity, stop bits, and word
length value previously set if SioParm was called,
otherwise the default values (see SioParm) are used.
Recall that COM1 and COM3 share the same interrupt
vector and therefore cannot operate simultaneously.
Similiarly, COM2 and COM4 cannot operate
simultaneously. Any other combination of two ports can
be used.
By specifing NORESET (-1) for the baud rate code, the
port will NOT be reset. This is used to "take over" a
port from a host communications program that allows a
"DOS gateway". External protocols can be implemented
this way. See SioBaud for a list of the baud rate
codes, or see "PCL4C.H".
Returns -3 : No buffer available. Call SioRxBuf first.
-4 : No such port. Expect 0 to MaxPort.
-11 : Bad baud rate code selected. Expecting 0 to 9.
-13 : UART undefined. SioUART(Port,0) was called
previously.
-14 : Bad or missing UART. You may not have hardware
present.
-15 : Port already enabled. SioReset has already been
called.
-16 : Interrupt already in use.
Example char Buffer[128];
int rc;
...
SioRxBuf(COM1,Buffer,Size128);
rc = SioReset(Com1,Baud38400);
if(rc==0) puts("RESET ok");
else if(rc<0) SioError(rc);
else
{if(rc&OverrunError) puts("Overrun Error");
if(rc&ParityError) puts("Parity Error");
if(rc&FramingError) puts("Framing Error");
if(rc&BreakDetected) puts("Break Detected");
}
See Also SioBaud, SioParms, SioRxBuf, SioDone, and SioUART.
PCL4C Reference Manual Page 29
SioRI
Function Reads the Ring Indicator (RI) modem status bit.
Syntax int SioRI(Port)
int Port; /* Port selected (COM1 thru COM4) */
Remarks The SioRI function is used to read the Ring Indicator
(RI) modem status bit. Also see SioModem.
Returns -2 : Port not enabled. Call SioReset first.
-4 : No such port. Expect 0 to MaxPort.
0 : RI is clear.
>0 : RI is set (RING has occurred).
Example /* check for Ring */
if(SioRI(Port))
{puts("RING ");
/* process RING */
...
}
See Also SioDSR, SioCTS, SioDCD, and SioModem.
PCL4C Reference Manual Page 30
SioRTS
Function Sets, clears, or reads the Request to Send (RTS) line.
Syntax int SioRTS(Port,Cmd)
int Port; /* COM1 to COM4 */
char Cmd; /* RTS command (SET, CLEAR, or READ) */
Remarks The SioRTS function controls the Request to Send (RTS
bit in the modem control register.
The RTS line is used by some error correcting modems
to implement hardware flow control. RTS is dropped by
the computer to signal the modem not to send data, and
is raised to signal the modem to continue.
Refer to the User's Manual for a discussion of flow
control.
Commands (defined in PCL4C.H) are:
SET_LINE ('S') -- set RTS (ON)
CLEAR_LINE ('C') -- clear RTS (OFF)
READ_LINE ('R') -- read RTS
Returns -2 : Port not enabled. Call SioReset first.
-4 : No such port. Expect 0 to MaxPort.
-5 : Command is not one of 'S', 'C', or 'R'.
0 : RTS is OFF (READ_LINE Command).
>0 : RTS is ON (READ_LINE Command).
Example /* turn off RTS for modem */
SioRTS(Port,CLEAR);
See Also SioFlow and SioDTR.
PCL4C Reference Manual Page 31
SioRxBuf
Function Sets up receive buffers.
Syntax int SioRxBuf(Port,Buffer,SizeCode)
int Port; /* Port selected (COM1 thru COM4) */
char *Buffer /* Receive buffer */
int SizeCode; /* Buffer size code */
Remarks The SioRxBuf function passes the address and size of
the receive buffer to PCL4C. Recall that PCL4C
requires a receive buffer for each port in
simultaneous operation since the receive function is
interrupt driven. It must be called before any
incoming characters can be received. SioRxBuf must be
called before SioReset. Buffer size codes are listed
in "PCL4C.H".
Size Code Buffer Size PCL4C.H Name
0 8 bytes Size8
1 16 bytes Size16
2 32 bytes Size32
3 64 bytes Size64
4 128 bytes Size128
5 256 bytes Size256
6 512 bytes Size512
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -