serGetStatus (Function) |
Top Previous Next |
Query the status of a serial port.
Input: port : SINT (0..127) (default 0) Selects which serial port to query.
Returns: INT
Declaration: FUNCTION serGetStatus : INT;
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;
|