Digi TX54 User Manual page 504

Hide thumbs Also See for TX54:
Table of Contents

Advertisement

Applications
State
Flashing
Fast flash
Use Python to set the state of LEDs
The following example uses an interactive Python session to set the state of all LEDs to flashing:
1. At the shell prompt, use the python command with no parameters to enter an interactive
Python session:
# python
Python 3.6.10 (default, Jan 31 2020, 08:45:19)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
2. Import the led submodule:
>>> from digidevice import led
3. Import the Led and State objects from the led submodule:
>>> from digidevice.led import Led, State
4. Use led.acquire() to gain control of the all LEDs:
>>> led.acquire(Led.ALL)
5. Use led.set() to set the state of the LEDs:
>>> led.set(Led.ALL, State.FLASH)
6. (Optional) Use led.release() to release the LEDs to system control:
>>> led.release(Led.ALL)
7. Use Ctrl-D to exit the Python session. You can also exit the session using exit() or quit().
The use(led) function
The use(led) function can be used to acquire control of LEDs and then release them back to system
control.
To create a function that acquires control of the power LED, sets it to a state of fast flashing, and then
releases control when the function has completed, use the following code in a python application:
with use(Led.POWER_B) as pwr:
pwr(State.FLASH)
Releasing the LEDs to system control
During a Python interactive session, or from within a Python script, you can release control of the LED
from Python to system control using the led.release() method.
TX54 User Guide
Atttribute name
State.FLASH
State.FLASH_FAST
Digidevice module
504

Advertisement

Table of Contents
loading

Table of Contents