COMSTAT


 

The COMSTAT instruction retrieves the status of the communications device. The instruction uses the following format:

 

 

[label]

COMSTAT

{comfile},{status}

 

Where:

label

Optional. A Program Execution Label.

comfile

Required. A previously defined and opened COMFILE definition.

status

Required. A Character String Variable that receives the status information.

 

Flags Affected: EOS

Note the following:

  1. The {comfile} variable specifies the device that is interrogated. The {comfile} must have been previously opened via the COMOPEN instruction.

  2. The EOS flag is set if status information is lost due to the {status} being too small.

  3. The following information is returned for local ports. Not all information is returned under Windows. Some values may be correct but are documented as having a problem (Maybe ?).

  4.  

    Byte

    Value

    Description

    1-8

     

    Port Status

    1

    Always 0

    Time-out occurred if ‘1’

    2

    Always 1

    Transmission shift register empty if ‘1’

    3

    Always 1

    Transmission hold register empty if ‘1’

    4

     

    Break detected if ‘1’

    5

     

    Framing error if ‘1’

    6

     

    Parity error if ‘1’

    7

     

    Overrun error if ‘1’

    8

     

    Data ready if ‘1’

    9-16

     

    Modem status

    9

     

    Receive line signal detected if ‘1’

    10

    Maybe ?

    Ring indicate if ‘1’

    11

     

    Data set ready if ‘1’

    12

     

    Clear to send if ‘1’

    13

     

    Change in receive line signal detected if ‘1’

    14

    Maybe ?

    Trailing edge ring indicator if ‘1’

    15

     

    Change in data set ready if ‘1’

    16

     

    Change in clear to send status if ‘1’

    17-21

     

    Character count of last COMWRITE/COMREAD

    22

     

    Status of data terminal ready signal

     

  5. The following information is returned for Windows sockets:

  6.  

    Byte

    Description

    1

    Zero (0) if not connected or one (1) if connected

    2

    Zero if writing is disabled or one if writing is enabled

    3

    Zero if reading is disabled or one if reading is enabled

    4

    Zero if no error or one if error occurred

    5-12

    Last generic error code

    13-20

    Last native error code

    21

    Zero if no socket attach request is pending or one if a request is pending

     

  7. The following information is returned for RMS pipes:

  8.  

    Byte

    Description

    1

    Zero (0) if not connected or one (1) if connected

    2

    Zero if writing is not available or one if writing is available

    3

    Zero if no data to read or one if data is available

    4

    Zero if no error or one if error occurred

    5-12

    Last generic error code

    13-20

    Last native error code

     

  9. Generic error codes that can occur for sockets, pipes, or opened file/devices are:

  10.  

    Code

    Description

    0

    No error.

    1

    No more write buffer space.

    2

    A write is already in progress.

    3

    Not connected to another process.

    4

    Send failed.

    5

    Receive failed.

    6

    Unexpected API error.

    7

    Unread data exists.

    8

    Timeout during send

     

  11. When using a Linux runtime where the {comfile} is opened for a file/device, the following information is returned:

  12.  

    Byte

    Description

    1

    Zero (0) if not opened or one (1) if opened.

    2

    Zero if writing is not available or one if writing is available.

    3

    Zero if no data to read or one if data is available.

    4

    Zero if no error or one if error occurred.

    5-12

    Last generic error code.

    13-20

    Last native error code

 

 

See Also: Communication I/O Instructions

 



PL/B Language Reference COMREAD COMWRITE