Miscellaneous Sample
More...
Go to the source code of this file.
Miscellaneous Sample
- Copyright
- 2019 Moxa Inc. All rights reserved.
- Date
- 2019-02-11
- Author
- William Chang
- Version
- V1.0
2 Copyright (C) 2019 Moxa Inc. All rights reserved. 3 SPDX-License-Identifier: Apache-2.0 5 Miscellaneous Python Sample Application 8 2019-02-11 William Chang Created it. 20 from ioThinx_4530
import ioThinx_4530_API
28 SCHED_PRIORITY_HIGH = 2
32 parser = argparse.ArgumentParser(description=
"Miscellaneous sample program.")
33 parser.add_argument(
"-s",
"--slot", dest=
"module_slot", type=int, default=1)
34 args = parser.parse_args()
38 module_slot = args.module_slot
39 device = ioThinx_4530_API.ioThinx_4530_API()
42 module_count = device.ioThinx_Misc_GetModuleCount()
43 print(
"Module count = {}".format(module_count))
44 print(
"Module slot = {}".format(module_slot))
46 module_info = device.ioThinx_Misc_GetModuleInfo(module_slot)
47 print(
"Slot {} Module Information:".format(module_slot))
48 print(
"Model Name: {}".format(module_info[
"model_name"]))
49 print(
"Serial Number: {}".format(module_info[
"serial_number"]))
52 device.ioThinx_Misc_SetLocateState(module_slot, 1)
53 print(
"Slot {}: Locating...".format(module_slot))
54 input(
"Press enter to stop locate.")
55 device.ioThinx_Misc_SetLocateState(module_slot, 0)
56 rs_state = device.ioThinx_Misc_GetRotarySwitchState(misc_slot)
57 print(
"Rotary switch state = {}".format(rs_state))
60 pbtn_state = device.ioThinx_Misc_GetPushButtonState(misc_slot)
61 print(
"Push button state = {}".format(pbtn_state))
64 device.ioThinx_Misc_SetUserLedState(misc_slot, LED_CHANNEL_U1, LED_STATE_GREEN)
65 print(
"Set LED U1 to GREEN")
66 device.ioThinx_Misc_SetUserLedState(misc_slot, LED_CHANNEL_U2, LED_STATE_RED)
67 print(
"Set LED U2 to RED")
68 input(
"Press enter to clear.")
69 device.ioThinx_Misc_SetUserLedState(misc_slot, LED_CHANNEL_U1, LED_STATE_DARK)
70 device.ioThinx_Misc_SetUserLedState(misc_slot, LED_CHANNEL_U2, LED_STATE_DARK)
73 device.ioThinx_Misc_SetScheduler(SCHED_PRIORITY_HIGH)
74 print(
"Set process priority to {}".format(SCHED_PRIORITY_HIGH))
75 input(
"Press enter to continue.")
78 if __name__ ==
'__main__':
Definition in file misc.py.