serGetStatus (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.10.00


Query the status of a serial port.

 

Input:

port : SINT (0..127) (default 0)

Selects which serial port to query.

 

Returns: INT

1

- The serial port is open and ready for use.

0

- This function is not supported.

-1

- The serial port is not present.

-2

- The serial port is not open.

-3

- The serial port is open, but the device is not present.

 

Declaration:

FUNCTION serGetStatus : INT;
VAR_INPUT
  port : SINT := 0;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc

 

PROGRAM example;

VAR

  status   : INT;

  old      : INT := 999;

END_VAR;

 

  // Enable USB serial port

  usbHostEnable(port := 1, enable := ON);

 

BEGIN

  // Get the status of the USB serial port

  status := serGetStatus(port := 10);

  IF status <> old THEN

    CASE status OF

        1: DebugMsg(message := "Serial port:   Open and ready for use!");

        0: DebugMsg(message := "serGetStatus is not supported.");

        -1: DebugMsg(message := "Serial port:   Not present.");

        -2: DebugMsg(message := "Serial port:   Not open.");

        -3: DebugMsg(message := "Serial port:   Device is removed!");

    END_CASE;

  END_IF;

  old := status;

END;

END_PROGRAM;