- Main
- Tutorials
- Library
- Samples

- Namespace List
- Namespace Members

Functions | Variables
misc Namespace Reference

## Functions
def | main ()

## Variables
int | LED_CHANNEL_U1 = 1
int | LED_CHANNEL_U2 = 2
int | LED_STATE_DARK = 0
int | LED_STATE_GREEN = 1
int | LED_STATE_RED = 2

## Detailed Description

    Copyright (C) 2019 Moxa Inc. All rights reserved.
    SPDX-License-Identifier: Apache-2.0

    Miscellaneous Python Sample Application

    Date          Author            Comment
    2019-02-11    William Chang     Created it.

## Function Documentation

def misc.main | ( |  | ) |

Definition at line 30 of file misc.py.

30 def main():
31 parser = argparse.ArgumentParser(description="Miscellaneous sample program.")
32 parser.add_argument("-s", "--slot", dest="module_slot", type=int, default=1)
33 args = parser.parse_args()
34
35 # initialize ioThinx I/O
36 misc_slot = 0
37 module_slot = args.module_slot
38 device = ioThinx_4530_API.ioThinx_4530_API()
39
40 # module infomation
41 module_count = device.ioThinx_Misc_GetModuleCount()
42 print("Module count = {}".format(module_count))
43 print("Module slot = {}".format(module_slot))
44
45 module_info = device.ioThinx_Misc_GetModuleInfo(module_slot)
46 print("Slot {} Module Information:".format(module_slot))
47 print("Model Name: {}".format(module_info["model_name"]))
48 print("Serial Number: {}".format(module_info["serial_number"]))
49
50 # locating
51 device.ioThinx_Misc_SetLocateState(module_slot, 1)
52 print("Slot {}: Locating...".format(module_slot))
53 input("Press enter to stop locate.")
54 device.ioThinx_Misc_SetLocateState(module_slot, 0)
55 rs_state = device.ioThinx_Misc_GetRotarySwitchState(misc_slot)
56 print("Rotary switch state = {}".format(rs_state))
57
58 # push button
59 pbtn_state = device.ioThinx_Misc_GetPushButtonState(misc_slot)
60 print("Push button state = {}".format(pbtn_state))
61
62 # user led
63 device.ioThinx_Misc_SetUserLedState(misc_slot, LED_CHANNEL_U1, LED_STATE_GREEN)
64 print("Set LED U1 to GREEN")
65 device.ioThinx_Misc_SetUserLedState(misc_slot, LED_CHANNEL_U2, LED_STATE_RED)
66 print("Set LED U2 to RED")
67 input("Press enter to clear.")
68 device.ioThinx_Misc_SetUserLedState(misc_slot, LED_CHANNEL_U1, LED_STATE_DARK)
69 device.ioThinx_Misc_SetUserLedState(misc_slot, LED_CHANNEL_U2, LED_STATE_DARK)
70 input("Press enter to continue.")
71
72
misc.main
def main()
Definition: misc.py:30
format
char const int const cJSON_bool format
Definition: cJSON.h:161

## Variable Documentation

int LED_CHANNEL_U1 = 1

Definition at line 23 of file misc.py.

int LED_CHANNEL_U2 = 2

Definition at line 24 of file misc.py.

int LED_STATE_DARK = 0

Definition at line 25 of file misc.py.

int LED_STATE_GREEN = 1

Definition at line 26 of file misc.py.

int LED_STATE_RED = 2

Definition at line 27 of file misc.py.