Functions
misc Namespace Reference

Functions

def main ()
 

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

◆ main()

def misc.main ( )

Definition at line 32 of file misc.py.

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