pmGetWakeSource (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.36.00


 
This function is used to parse the return code from pmSuspend.

For details about the values, please see the descriptions for the individual wake-up sources.

 

 

Input:

Source : DINT

The return code from pmSuspend.

 

 

Output:

Error : BOOL

If TRUE the return code represents an error. If FALSE, the return code represents a successful wake-up source.

 

Type : INT

The module that caused the return code. Some modules supports wake-up while others are only used when they prevent suspend.

Type

Module

Details

0

System

Errors not related to a module

1

Board

ID 1 = RTC

ID 2 = Timeout (time parameter on pmSuspend)

ID 3 = Supply change

2

Digital input

ID = input number

3

Serial port

ID = port number

4

Motion sensor

ID 1 = Vibration

5

Cellular

 

8

Key press

 

9

CAN

ID = Bus number

Additionally, some modules may prevent the system from being suspended and must be powered off first:

Type

Module

Details

1

Board

ID 4 = Battery

6

Network

 

7

Bluetooth

 

 

 

 

ID : INT

The ID of the wake source. For some modules, this may represent a port or a pin while it in other cases may represent entirely different wake-up sources.

 

Value : INT

Detailed return code for the module.

Some values are common for all modules and can be found below, the rest can be found in the documentation for the individual wake-up functions.

-1

Unknown

-2

The wake-up source does not support the requested low power mode. There may be other wake sources that require incompatible low power modes.

-3

The module must be powered off before the low power mode can be entered.

 

 

Returns: INT

1

The return code was parsed

0

the function is not supported.

 

Declaration:

FUNCTION pmGetWakeSource : INT;
VAR_INPUT
  source         : DINT;
  error           : ACCESS BOOL;
  type           : ACCESS INT;
  id             : ACCESS INT;
  value           : ACCESS INT;
END_VAR;

 

 

Example:

 
  ...
    wk := pmSuspend(time:=600, mode := 0);
    // Parse return code
    rc := pmGetWakeSource(source:=wk, error:=err, type:=type,id:=id,value:=val);
    IF err THEN
        DebugFmt(message:="pmSuspend failed");
    ELSE
        DebugFmt(message:="pmSuspend succeeded");
    END_IF;
    DebugFmt(message:="$ttype: \1", v1:=type);
    DebugFmt(message:="$tid: \1", v1:=id);
    DebugFmt(message:="$tval: \1", v1:=val);
  ...