Format
number1 = COMSTAT (number2)
Description
This statement returns the status of a com port. Number2 should contain
"0" for COM1, or "1" for COM2. The status of that COM port is returned in
number1. Each bit in number1 represents a different piece of information.
These are described in the table below. Note that you may test if a bit is
on/off using the ZBIT command.
Example
PORTSTAT = COMSTAT (0)
DATAREADY = ZBIT(8,PORTSTAT)
IF DATAREADY = 1 THEN GORECEIVE:
These statements do the following. The first retrieves the status of COM1
to the variable PORTSTAT. The second checks to see if bit 8 is on,
DATAREADY will contain 1 if so, otherwise it will contain 0. Since Bit 8
is used to determine if data is waiting to be received from the port, if
DATAREADY = 1 then the program will transfer to the label GORECEIVE: which
would contain code to RECEIVE data from the port.
Comments
Status Codes Returned by COMSTAT (Meaning when set to 1)
0 |
Delta clear-to-send |
1 |
Delta data-set-ready |
2 |
Trailing-edge ring detector |
3 |
Delta receive line signal detect |
4 |
Clear-to-send |
5 |
Data-set-ready |
6 |
Ring Indicator |
7 |
Received line signal detect |
8 |
Data Ready |
9 |
Overrun error |
10 |
Parity error |
11 |
Framing error |
12 |
Break-detect error |
13 |
Transfer holding register empty |
14 |
Transfer shift-register empty |
15 |
Time-out error |
See Also
|