📄 pcl4c.ref
字号:
Code = SioFlow(COM2,-1);
if(Code==0) printf("Flow Control disabled\n");
else SioError(Code);
See Also SioPutc
PCL4C Reference Manual Page 16
SioGetc
Function Reads the next character from the serial line.
Syntax int SioGetc(Port,Tics)
int Port; /* COM1 to COM4 */
int Tics; /* # timer tics */
Remarks The SioGetc function reads a byte from the selected
serial port. The function will wait for the number of
system tics given by the 'Tics' argument before
returning 'timed out'. There are 18 tics to the
second.
To specify no waiting, call SioGetc with Tics = 0.
Returns -2 : Port not enabled. Call SioReset first.
-4 : No such port. Expect 0 to MaxPort.
-1 : If timed out.
>0 : Character read.
Example int c; /* MUST be 'int', not 'char' !!! */
...
/* wait 9 tics for incoming character & display it */
if( (c=SioGetc(COM1,9)) != -1)
printf("Character is '%c'\n", c);
else puts("Timed out");
See Also SioUnGetc and SioPutc.
PCL4C Reference Manual Page 17
SioKeyPress
Function Detects if keyboard has been pressed.
Syntax int SioKeyPress()
Remarks The SioKeyPress function uses the BIOS to test the
keyboard for a key press (including control
characters).
SioKeyPress calls the BIOS directly without any
intermediate buffering or processing. It is usually
faster than using the C library.
Returns zero
Example if( SioKeyPress() )
{c = SioKeyRead();
/* echo character c */
SioCrtWrite(c)
}
See Also SioCrtWrite and SioKeyRead.
PCL4C Reference Manual Page 18
SioKeyRead
Function Reads the keyboard.
Syntax int SioKeyRead()
Remarks The SioKeyRead function uses the BIOS to read the
keyboard. It will wait until a character is typed.
SioKeyRead calls the BIOS directly without any
intermediate buffering or processing. It is usually
faster than using the C library.
Returns Character typed (including control codes).
Example if(SioKeyPress())
{/* fetch the character */
c = SioKeyRead();
/* echo to screen */
SioCrtWrite(c);
}
See Also SioCrtWrite and SioKeyRead.
PCL4C Reference Manual Page 19
SioInfo
Function Returns PCL4C library information.
Syntax int SioInfo(Cmd)
char Cmd; /* Command (VERSION or MODEL) */
Remarks The SioInfo function returns an integer code
corresponding to either the (1) library version
number, (2) the memory model (small, medium, compact,
or large), and (3) whether or not transmitter
interrupts are enabled.
Returns Version ('V')
hex byte XY where version is denoted as X.Y
Memory Model ('M')
0 Small
1 Compact
2 Medium
3 Large
TX Interrupts ('I')
TRUE if transmitter interrupts are enabled in the
library, otherwise FALSE.
Example char *String[]={"Small","Compact","Medium","Large"};
int Version;
int Model;
...
/* display library version */
Version = SioInfo('V');
printf("Library version is %d.%d\n",
Version/16, Version%16);
/* display memory model */
Model = SioInfo('M');
printf("Memory Model is %s\n", String[Model]);
/* display TX interrupt status */
printf("TX interrupts are ");
if( SioInfo('I') ) puts("enabled.");
else puts("not enabled.");
PCL4C Reference Manual Page 20
SioIRQ
Function Assigns an IRQ line to a port.
Syntax int SioIRQ(Port,IRQcode)
int Port; /* Port selected (COM1 thru COM4) */
int IRQcode; /* IRQ number [IRQ2..IRQ7] */
Remarks The SioIRQ function assigns an IRQ line to a port.
That is, SioIRQ maps an IRQ to a port. SioIRQ (like
SioUART) must be called before calling SioReset.
Unless you have a non-standard (COM1 & COM3 use IRQ4
while COM2 & COM4 use IRQ3) serial port configuration
(or don't want to run more than 2 ports concurrently),
you will not need to call SioIRQ. Be EXTREMELY
carefull with SioIRQ as it can lock your machine up if
given incorrect information.
In particular, remember that your port hardware must
generate the interrupt that you have specified. You
should refer to your serial board hardware manual for
specfics instructions in configuring your hardware.
Be sure to call SioPorts first to setup DigiBoard
ports if you have them. Refer to the PCL4C Users
Manual for additional information.
Returns -4 : No such port. Expect 0 to MaxPort.
-15 : Port already enabled. SioReset has already been
called.
-17 : No such IRQ.
-18 : ISR limit (maximum of 4 PC IRQs) exceeded.
0 : Otherwise
Example /* use IRQ5 for COM3 (not DigiBoard) */
SioUART(COM3,0x3220);
SioIRQ(COM3,IRQ5);
/* we can now run 3 ports simultaneously */
See Also SioUART and SioPorts.
PCL4C Reference Manual Page 21
SioLine
Function Reads the line status register.
Syntax int SioLine(Port)
int Port; /* Port selected (COM1 thru COM4) */
Remarks The SioLine function reads the line status register.
The individual bit masks are as follows:
0x40 = Transmitter empty.
0x20 = Transmitter buffer empty.
0x10 = Break detected.
0x08 = Framming error.
0x04 = Parity error.
0x02 = Overrun error.
0x01 = Data ready.
The above are documented in the file PCL4C.H.
Returns -2 : Port not enabled. Call SioReset first.
-4 : No such port. Expect 0 to MaxPort.
>0 : Line status (rightmost byte of word).
Example int rc;
...
rc = LineStatus(Port);
if(rc & (FramingError|ParityError|OverrunError))
{if(rc & FramingError) puts("Framing Error");
if(rc & ParityError) puts("Parity Error");
if(rc & OverrunError) puts("Overrun Error");
}
else puts("No error");
See Also SioModem.
PCL4C Reference Manual Page 22
SioLoopBack
Function Does a UART loopback test.
Syntax int SioLoopBack(Port)
int Port; /* Port selected (COM1 thru COM4) */
Remarks SioLoopBack makes use of the built in loopback test
capability of the INS8250 family UART. Normally
SioLoopBack will never need to be called except if you
suspect that your UART is bad.
Many UARTs must be reset after running a loopback
test.
Returns 0 : Loopback test is successfull.
-2 : Port not enabled. Call SioReset first.
-4 : No such port. Expect 0 to MaxPort.
-12 : Loopback test fails.
Example /* test port */
if(SioLoopBack(Port))
{puts("Loopback test has failed");
SioDone(Port);
exit(1);
}
/* loopback was successful */
puts("Loopback test has succeeded");
SioDone(Port);
/* reset port again if want to do more processing */
...
PCL4C Reference Manual Page 23
SioModem
Function Reads the modem status register.
Syntax int SioModem(Port, Mask)
int Port; /* Port selected (COM1 thru COM4) */
char Mask; /* Modem function mask */
Remarks The SioModem function reads the modem register. The
bit definitions for the function mask are as follows:
Bit PCL4C.H Name Function
7 DCD Data Carrier Detect
6 RI Ring Indicator
5 DSR Data Set Ready
4 CTS Clear To Send
3 DeltaDCD Delta DCD (DCD has changed)
2 DeltaRI Delta RI (RI has changed)
1 DeltaDSR Delta DSR (DSR has changed)
0 DeltaCTS Delta CTS (CTS has changed)
Bits 4 through 7 represent the absolute state of their
respective RS-232 inputs. Bits 0 through 3 repesent a
change in the state of their respective RS-232 inputs
since last read.
The above definitions are also in the PCL4C.H file for
use by your application program.
Returns -2 : Port not enabled. Call SioReset first.
-4 : No such port. Expect 0 to MaxPort.
>0 : Modem status (rightmost byte of word).
Example /* any change in DCD or CTS ? */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -