- Main
- Tutorials
- Library
- Samples

- File List
- Globals

Namespaces | Functions | Variables
misc.py File Reference

Miscellaneous Sample More...

Go to the source code of this file.

## Namespaces
| misc

## 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

Miscellaneous Sample

Copyright
  2019 Moxa Inc. All rights reserved.

Date
  2019-02-11

Author
  William Chang

Version
  V1.0
  1 '''
  2 Copyright (C) 2019 Moxa Inc. All rights reserved.
  3 SPDX-License-Identifier: Apache-2.0
  4
  5 Miscellaneous Python Sample Application
  6
  7 Date Author Comment
  8 2019-02-11 William Chang Created it.
  9 '''
  10
  11
  19
  20 from ioThinx_4530 import ioThinx_4530_API
  21 import argparse
  22
  23 LED_CHANNEL_U1 = 1
  24 LED_CHANNEL_U2 = 2
  25 LED_STATE_DARK = 0
  26 LED_STATE_GREEN = 1
  27 LED_STATE_RED = 2
  28
  29
  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
  73 if __name__ == '__main__':
  74 main()

Definition in file misc.py.