17. API - Software Reset Button

17.1. Regular Classes

The following classes are intended for general use with the devices they represent. All classes in this section are concrete (not abstract).

17.1.1. SWR

class lannerpsp.SWR(check_platform: bool = False)[source]

Software Reset Button.

Parameters:

check_platform (bool) – Set to True to check if the platform supports this feature. Defaults to False for better compatibility.

Raises:
get_status() int[source]

Get software reset button status.

Example:

>>> swr = SWR()
>>> swr.get_status()
1
Returns:

software reset button status

Return type:

int

Raises:
exec_callback() None[source]

Use callback function to detect software reset button status (default 10 seconds).

Example:

>>> swr = SWR()
>>> swr.exec_callback()
----> hook Software-Reset button Callback OK <----
===> wait about 10 second time <===
SWR Item = 0001, Status = 0001, time is 2022/08/01 17:45:12
SWR Item = 0001, Status = 0000, time is 2022/08/01 17:45:13
SWR Item = 0001, Status = 0001, time is 2022/08/01 17:45:14
SWR Item = 0001, Status = 0000, time is 2022/08/01 17:45:14
SWR Item = 0001, Status = 0001, time is 2022/08/01 17:45:15
SWR Item = 0001, Status = 0000, time is 2022/08/01 17:45:16
----> disabled Software-Reset button Callback hook <----
property is_pressed: bool

Returns True if the device is currently active and False otherwise.

Example:

>>> swr = SWR()
>>> swr.is_pressed
True
Returns:

if is pressed or not

Return type:

bool

Raises:
wait_for_press(timeout: float | int | None = None) None[source]

Pause the script until the device is activated, or the timeout is reached.

Example:

>>> swr = SWR()
>>> swr.wait_for_press()
Parameters:

timeout (float or int or None) – Number of seconds to wait before proceeding. If this is None (the default), then wait indefinitely until the device is active.

Raises:
wait_for_release(timeout: float | int | None = None) None[source]

Pause the script until the device is deactivated, or the timeout is reached.

Example:

>>> swr = SWR()
>>> swr.wait_for_release()
Parameters:

timeout (float or int or None) – Number of seconds to wait before proceeding. If this is None (the default), then wait indefinitely until the device is active.

Raises:

17.2. Supported Platforms