1 How to use python sample codes {#python}
3 @brief Introdution to python package installation and tutorial to execute python sample code.
7 # Install python package and sample code
9 1.Copy sample.tar.gz and library.tar.gz contained in the programing guide from your PC to ioThinx:
10 For example, if the IP address of the ioThinx is "192.168.127.254", use the following command:
13 user@Linux:~$ scp sample.tar.gz moxa@192.168.127.254:~
14 user@Linux:~$ scp library.tar.gz moxa@192.168.127.254:~
18 2.Extract the sample code and library
21 moxa@Moxa:~$ tar zxvf sample.tar.gz
22 moxa@Moxa:~$ tar zxvf library.tar.gz
28 moxa@Moxa:~$ cd library/python_package
29 moxa@Moxa:~$ ./install.sh
31 [ OK ] Install finished
35 4.The module will be installed to the standard location. For example
38 /usr/local/lib/python3.5/dist-packages
42 ## Python Interactive Mode
44 1.open python interactive windwos
47 moxa@Moxa:~$ sudo python3
48 [sudo] password for moxa:
50 Python 3.5.3 (default, Sep 27 2018, 17:25:39)
51 [GCC 6.3.0 20170516] on linux
52 Type "help", "copyright", "credits" or "license" for more information.
57 2.Then in the Python Interactive Mode.
60 >>> from ioThinx_4530 import ioThinx_4530_API
61 >>> device = ioThinx_4530_API.ioThinx_4530_API()
62 >>> slot_num = device.ioThinx_Misc_GetModuleCount()
63 >>> print("slot_num = {}".format(slot_num))
66 >>> for slot in range(1,slot_num):
67 ... print(device.ioThinx_Misc_GetModuleInfo(slot))
70 {'fwr_version': '0x1100', 'product_id': '0x8000a024', 'model_name': '45MR-1600', 'serial_number': 'TAHGB1014465', 'fwr_build_date': datetime.datetime(2018, 12, 19, 15, 0)}
71 {'fwr_version': '0x1100', 'product_id': '0x8000a032', 'model_name': '45MR-1601-T', 'serial_number': 'TAHGB1021495', 'fwr_build_date': datetime.datetime(2018, 12, 19, 15, 0)}
72 {'fwr_version': '0x1100', 'product_id': '0x8000a026', 'model_name': '45MR-2600', 'serial_number': 'TAHGB1019637', 'fwr_build_date': datetime.datetime(2018, 12, 19, 15, 0)}
73 {'fwr_version': '0x1100', 'product_id': '0x8000a027', 'model_name': '45MR-2601', 'serial_number': 'TAHGB1017574', 'fwr_build_date': datetime.datetime(2018, 12, 19, 15, 0)}
74 {'fwr_version': '0x1100', 'product_id': '0x8000a028', 'model_name': '45MR-2606', 'serial_number': 'TAHGB1016527', 'fwr_build_date': datetime.datetime(2018, 12, 19, 15, 0)}
75 {'fwr_version': '0x1100', 'product_id': '0x8000a036', 'model_name': '45MR-2404-T', 'serial_number': 'TAHGB1014483', 'fwr_build_date': datetime.datetime(2018, 12, 19, 15, 0)}
76 {'fwr_version': '0x1100', 'product_id': '0x8000a02e', 'model_name': '45MR-6810', 'serial_number': 'TAHIB1035236', 'fwr_build_date': datetime.datetime(2018, 12, 21, 17, 0)}
77 {'fwr_version': '0x1100', 'product_id': '0x8000a023', 'model_name': '45MR-6600', 'serial_number': 'TAHIB1035385', 'fwr_build_date': datetime.datetime(2018, 12, 21, 17, 0)}
78 {'fwr_version': '0x1008', 'product_id': '0x8000a02a', 'model_name': '45MR-3800', 'serial_number': 'TAHIB1035470', 'fwr_build_date': datetime.datetime(2018, 10, 31, 3, 0)}
79 {'fwr_version': '0x1008', 'product_id': '0x8000a02b', 'model_name': '45MR-3810', 'serial_number': 'TAHIB1034735', 'fwr_build_date': datetime.datetime(2018, 10, 31, 3, 0)}
80 {'fwr_version': '0x1002', 'product_id': '0x8000a02c', 'model_name': '45MR-7210', 'serial_number': 'MOXA89191230', 'fwr_build_date': datetime.datetime(2018, 12, 19, 15, 0)}
90 moxa@Moxa:~$ cd sample/python-sample
91 moxa@Moxa:~/sample/python-sample$ sudo python3 misc/misc.py
92 [sudo] password for moxa:
100 Slot 1 Module Information:
101 Model Name: 45MR-1600
102 Serial Number: TAHGB1014465
104 Press enter to stop locate.
105 Rotary switch state = 2
106 Push button state = 0
109 Press enter to clear.
110 Set process priority to 2
111 Press enter to continue.