CK-InoDrive-API 0.2.9__py3-none-any.whl → 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: CK-InoDrive-API
3
- Version: 0.2.9
3
+ Version: 1.0.0
4
4
  Summary: InoDrive API Library
5
5
  Home-page: https://cardinalkinetic.com
6
6
  Author: Cardinal Kinetic
@@ -18,9 +18,9 @@ Classifier: Programming Language :: Python :: 3.12
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE.txt
20
20
  License-File: README.txt
21
- Requires-Dist: websocket-client ==1.6.4
21
+ Requires-Dist: websocket-client ==1.8.0
22
22
  Requires-Dist: ifaddr ==0.2.0
23
- Requires-Dist: msgpack ==1.0.7
23
+ Requires-Dist: msgpack ==1.0.8
24
24
 
25
25
  #### **Installation**
26
26
 
@@ -19,14 +19,14 @@ of the license associated with each component.
19
19
  SECTION 1: Apache License, V2.0
20
20
 
21
21
  >>> bleach-5.0.1
22
- >>> importlib-metadata-6.8.0
23
- >>> msgpack-1.0.7
24
- >>> readme-renderer-42.0
22
+ >>> importlib-metadata-8.4.0
23
+ >>> msgpack-1.0.8
24
+ >>> readme-renderer-44.0
25
25
  >>> requests-2.31.0
26
26
  >>> requests-toolbelt-1.0.0
27
27
  >>> rfc3986-2.0.0
28
- >>> twine-4.0.2
29
- >>> websocket-client-1.6.4
28
+ >>> twine-5.1.1
29
+ >>> websocket-client-1.8.0
30
30
 
31
31
  SECTION 2: BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES
32
32
 
@@ -35,32 +35,34 @@ SECTION 2: BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES
35
35
  >>> click-8.1.7
36
36
  >>> colorama-0.4.6
37
37
  >>> commonmark-0.9.1
38
- >>> docutils-0.20.1
38
+ >>> docutils-0.21.2
39
39
  >>> flask-3.0.0
40
40
  >>> greenlet-3.0.1
41
- >>> idna-3.6
41
+ >>> idna-3.8
42
42
  >>> ifaddr-0.2.0
43
43
  >>> itsdangerous-2.1.2
44
- >>> jaraco.classes-3.3.0
44
+ >>> jaraco.classes-3.4.0
45
+ >>> jaraco.context-6.0.1
46
+ >>> jaraco.functools-4.0.2
45
47
  >>> jinja2-3.1.2
46
- >>> keyring-24.3.0
48
+ >>> keyring-25.3.0
47
49
  >>> markdown-it-py-3.0.0
48
50
  >>> markupsafe-2.1.3
49
51
  >>> mdurl-0.1.2
50
- >>> more-itertools-10.1.0
51
- >>> nh3-0.2.14
52
+ >>> more-itertools-10.5.0
53
+ >>> nh3-0.2.18
52
54
  >>> pkginfo-1.9.6
53
- >>> pygments-2.17.2
55
+ >>> pygments-2.18.0
54
56
  >>> pycryptodome-3.19.0
55
- >>> pywin32-ctypes-0.2.2
57
+ >>> pywin32-ctypes-0.2.3
56
58
  >>> rich-13.7.0
57
- >>> setuptools-68.2.2
59
+ >>> setuptools-74.1.2
58
60
  >>> six-1.16.0
59
61
  >>> sqlalchemy-2.0.23
60
62
  >>> urllib3-2.1.0
61
63
  >>> webencodings-0.5.1
62
64
  >>> werkzeug-3.0.1
63
- >>> zipp-3.17.0
65
+ >>> zipp-3.20.1
64
66
 
65
67
  SECTION 3: GNU General Public License, V2.0
66
68
 
@@ -68,16 +70,17 @@ SECTION 3: GNU General Public License, V2.0
68
70
 
69
71
  SECTION 4: Mozilla Public License, V2.0
70
72
 
71
- >>> certifi-2023.11.17
73
+ >>> certifi-2024.8.30
72
74
 
73
75
  SECTION 5: Python License, V2.0
74
76
 
75
- >>> datetime
76
77
  >>> ipaddress-1.0
77
78
  >>> json-2.0.9
78
79
  >>> logging-0.5.1.2
80
+ >>> os
79
81
  >>> select
80
82
  >>> socket
83
+ >>> ssl
81
84
  >>> struct
82
85
  >>> random-3
83
86
  >>> re-2.2.1
@@ -107,7 +110,7 @@ Copyright (c) 2014-2017, Mozilla Foundation
107
110
  See the License for the specific language governing permissions and
108
111
  limitations under the License.
109
112
 
110
- >>> msgpack-1.0.7
113
+ >>> msgpack-1.0.8
111
114
 
112
115
  Found in: msgpack-python/COPYING
113
116
 
@@ -157,11 +160,11 @@ Copyright 2014 Ian Cordasco, Rackspace
157
160
  See the License for the specific language governing permissions and
158
161
  limitations under the License.
159
162
 
160
- >>> importlib-metadata-6.8.0
161
- >>> readme-renderer-42.0
162
- >>> requests-2.31.0
163
- >>> twine-4.0.2
164
- >>> websocket-client-1.6.4
163
+ >>> importlib-metadata-8.4.0
164
+ >>> readme-renderer-44.0
165
+ >>> requests-2.32.3
166
+ >>> twine-5.1.1
167
+ >>> websocket-client-1.8.0
165
168
 
166
169
  Apache License
167
170
  Version 2.0, January 2004
@@ -485,7 +488,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
485
488
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
486
489
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
487
490
 
488
- >>> docutils-0.20.1
491
+ >>> docutils-0.21.2
489
492
 
490
493
  .. include:: docs/header0.txt
491
494
 
@@ -711,7 +714,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
711
714
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
712
715
  THE SOFTWARE.
713
716
 
714
- >>> idna-3.6
717
+ >>> idna-3.8
715
718
 
716
719
  BSD 3-Clause License
717
720
 
@@ -935,7 +938,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
935
938
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
936
939
  IN THE SOFTWARE.
937
940
 
938
- >>> more-itertools-10.1.0
941
+ >>> more-itertools-10.5.0
939
942
 
940
943
  Copyright (c) 2012 Erik Rose
941
944
 
@@ -957,7 +960,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
957
960
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
958
961
  SOFTWARE.
959
962
 
960
- >>> nh3-0.2.14
963
+ >>> nh3-0.2.18
961
964
 
962
965
  The MIT License (MIT)
963
966
 
@@ -1069,7 +1072,7 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1069
1072
  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1070
1073
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1071
1074
 
1072
- >>> pygments-2.17.2
1075
+ >>> pygments-2.18.0
1073
1076
 
1074
1077
  Copyright (c) 2006-2022 by the respective authors (see AUTHORS file).
1075
1078
  All rights reserved.
@@ -1097,7 +1100,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1097
1100
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1098
1101
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1099
1102
 
1100
- >>> pywin32-ctypes-0.2.2
1103
+ >>> pywin32-ctypes-0.2.3
1101
1104
 
1102
1105
  This software is OSI Certified Open Source Software.
1103
1106
  OSI Certified is a certification mark of the Open Source Initiative.
@@ -1282,10 +1285,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
1282
1285
  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1283
1286
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1284
1287
 
1285
- >>> jaraco.classes-3.3.0
1286
- >>> keyring-24.3.0
1287
- >>> setuptools-68.2.2
1288
- >>> zipp-3.17.0
1288
+ >>> jaraco.classes-3.4.0
1289
+ >>> jaraco.context-6.0.1
1290
+ >>> jaraco.functools-4.0.2
1291
+ >>> keyring-25.3.0
1292
+ >>> setuptools-74.1.2
1293
+ >>> zipp-3.20.1
1289
1294
 
1290
1295
  Permission is hereby granted, free of charge, to any person obtaining a copy
1291
1296
  of this software and associated documentation files (the "Software"), to
@@ -1655,7 +1660,7 @@ Public License instead of this License.
1655
1660
  =============== SECTION 4. Mozilla Public License, V2.0 ===============
1656
1661
 
1657
1662
 
1658
- >>> certifi-2023.11.17
1663
+ >>> certifi-2024.8.30
1659
1664
 
1660
1665
  This package contains a modified version of ca-bundle.crt:
1661
1666
 
@@ -1682,12 +1687,13 @@ one at http://mozilla.org/MPL/2.0/.
1682
1687
  =============== SECTION 5. Python License, V2.0 ===============
1683
1688
 
1684
1689
 
1685
- >>> datetime
1686
1690
  >>> ipaddress-1.0
1687
1691
  >>> json-2.0.9
1688
1692
  >>> logging-0.5.1.2
1693
+ >>> os
1689
1694
  >>> select
1690
1695
  >>> socket
1696
+ >>> ssl
1691
1697
  >>> struct
1692
1698
  >>> random-3
1693
1699
  >>> re-2.2.1
@@ -1975,4 +1981,4 @@ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1975
1981
  INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1976
1982
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1977
1983
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1978
- PERFORMANCE OF THIS SOFTWARE.
1984
+ PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,18 @@
1
+ CkInoDriveAPI/IO.py,sha256=vaCoHNPF5-qYzA2vjtykYKHjtJicqAexL_tyGj9Vspk,10533
2
+ CkInoDriveAPI/__init__.py,sha256=ejsWVPPET1Yvp3iHCYVdxGNw0rKtk814M8xEL4Lo2zM,104
3
+ CkInoDriveAPI/ck_ca.crt,sha256=uopTpSLmrazZpYhrJ-79bMTFYIjiAMxhHhMo07hYsy4,878
4
+ CkInoDriveAPI/defines.py,sha256=ZbgVXIF9Ax-cKU3bXl7tsT6rVPUpr6p2rlVqmGvh1wc,12903
5
+ CkInoDriveAPI/discoverLan.py,sha256=cMUfD5MDxPxPOu2K-1oOoUIMdDJtplh3-ff3hxeTFc8,11029
6
+ CkInoDriveAPI/discoverWs.py,sha256=hdqKz0IAS9NBO90r3TFzsyKKl152XpfVZX5eUemk4fg,1154
7
+ CkInoDriveAPI/file.py,sha256=amUdZOKKr9EXDEjYNmkNrRtYqGro93BjdtvhsiwhjLQ,6584
8
+ CkInoDriveAPI/inoDrive.py,sha256=g3IWnKt-PZD9j43nCj7cgSAX8uTI9BYSUeRHPIEjhGY,5667
9
+ CkInoDriveAPI/sysControl.py,sha256=SLsi6JKG1jRkLDtSS0YW8Jqmcrl3UV4xC5Li9N-rvvw,3482
10
+ CkInoDriveAPI/userApp.py,sha256=3i9zrml8JAheOzId-6KSks_1grWwXQc6UHMitwJV5jc,21465
11
+ CkInoDriveAPI/utils.py,sha256=CwAVqkWMfbGcY2xq8jply8qgXs3Ff6EnD0UUkJs8Fi8,16003
12
+ CkInoDriveAPI/wsHandle.py,sha256=WVn_yDVHyuSQOxnvY1GC0AUaXyOC-lXSFJ5eA2qnYeI,19150
13
+ CK_InoDrive_API-1.0.0.dist-info/LICENSE.txt,sha256=Htz8K82ehzm2lkK44nZ_hU0M5I4W8YHipiiRYyRdH5o,1077
14
+ CK_InoDrive_API-1.0.0.dist-info/METADATA,sha256=KHx5mUSHBM73xd5tcf5N1fn7eYuHTvMa4hDuEoo0eWE,3127
15
+ CK_InoDrive_API-1.0.0.dist-info/README.txt,sha256=AmRZf0ukNgLBwr5t_xfghCUOF4UIsmrNtSJtUeWL6ms,94524
16
+ CK_InoDrive_API-1.0.0.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
17
+ CK_InoDrive_API-1.0.0.dist-info/top_level.txt,sha256=HQb3X73ZpaiGH2dSziFYqzUFtsf1oG6A5_qUtF03xyQ,14
18
+ CK_InoDrive_API-1.0.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.3)
2
+ Generator: setuptools (74.1.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
CkInoDriveAPI/IO.py CHANGED
@@ -1,13 +1,16 @@
1
1
  import logging
2
2
 
3
- from .wsHandle import InoDriveWS
4
3
  from .defines import CK
5
4
  from .defines import OP_STATE
6
5
 
7
6
 
8
7
  class IO(object):
9
8
  def __init__(self, **kwargs):
10
- self._connection_handle: InoDriveWS = kwargs.get('connection_handle')
9
+ self._get_connection_handle = kwargs.get('get_connection_handle')
10
+
11
+ @property
12
+ def _connection_handle(self):
13
+ return self._get_connection_handle()
11
14
 
12
15
  def dispose(self):
13
16
  return
@@ -130,7 +133,7 @@ class IO(object):
130
133
  logging.error(data['error'])
131
134
  return None
132
135
 
133
- if type(input) == int and input >= 0 and input <= 3:
136
+ if type(input) is int and 0 <= input <= 3:
134
137
  return 1 if (data['digital'] >> input) & 0x1 else 0
135
138
  else:
136
139
  return data['digital']
@@ -146,7 +149,7 @@ class IO(object):
146
149
  logging.error(data['error'])
147
150
  return None
148
151
 
149
- if type(input) == int and input >= 0 and input <= 1:
152
+ if type(input) is int and 0 <= input <= 1:
150
153
  return 1 if (data['safety'] >> input) & 0x1 else 0
151
154
  else:
152
155
  return data['safety']
@@ -173,14 +176,14 @@ class IO(object):
173
176
 
174
177
  if target == 'all' and state is not None:
175
178
  target = -1
176
- if type(state) == str:
179
+ if type(state) is str:
177
180
  state = 0xf if state.upper() == 'NPN' else 0x0
178
181
  else:
179
182
  state = 0xf if state else 0x0
180
- elif target == 'val' and type(state) == int:
183
+ elif target == 'val' and type(state) is int:
181
184
  target = -1
182
- elif type(target) == int and target >= 0 and target <= 3 and state is not None:
183
- if type(state) == str:
185
+ elif type(target) is int and 0 <= target <= 3 and state is not None:
186
+ if type(state) is str:
184
187
  state = 0x1 if state.upper() == 'NPN' else 0x0
185
188
  else:
186
189
  state = 0x1 if state else 0x0
@@ -207,7 +210,7 @@ class IO(object):
207
210
  logging.error(data['error'])
208
211
  return None
209
212
 
210
- if type(input) == int and input >= 0 and input <= 3:
213
+ if type(input) is int and 0 <= input <= 3:
211
214
  return 'NPN' if (data['polarity'] >> input) & 0x1 else 'PNP'
212
215
  else:
213
216
  return data['polarity']
@@ -235,9 +238,9 @@ class IO(object):
235
238
  if target == 'all' and state is not None:
236
239
  target = -1
237
240
  state = 0x7 if state else 0x0
238
- elif target == 'val' and type(state) == int:
241
+ elif target == 'val' and type(state) is int:
239
242
  target = -1
240
- elif type(target) == int and target >= 0 and target <= 2 and state is not None:
243
+ elif type(target) is int and 0 <= target <= 2 and state is not None:
241
244
  state = 0x1 if state else 0x0
242
245
  else:
243
246
  logging.error(f'InoDrive SetOutput Error: target os state not supported...')
@@ -263,7 +266,7 @@ class IO(object):
263
266
  logging.error(data['error'])
264
267
  return None
265
268
 
266
- if type(output) == int and output >= 0 and output <= 2:
269
+ if type(output) is int and 0 <= output <= 2:
267
270
  return 1 if (data['digital'] >> output) & 0x1 else 0
268
271
  else:
269
272
  return data['digital']
@@ -281,7 +284,7 @@ class IO(object):
281
284
  logging.error(data['error'])
282
285
  return None
283
286
 
284
- if type(output) == int and output >= 0 and output <= 2:
287
+ if type(output) is int and 0 <= output <= 2:
285
288
  return 1 if (data['digital_faults'] >> output) & 0x1 else 0
286
289
  else:
287
290
  return data['digital_faults']
@@ -0,0 +1,15 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIICUTCCAdigAwIBAgIUKSVqbARTYaxckTUEA7Gby+uWD8IwCgYIKoZIzj0EAwIw
3
+ VzELMAkGA1UEBhMCVVMxETAPBgNVBAgMCEtlbnR1Y2t5MRgwFgYDVQQKDA9DYXJk
4
+ aW5hbEtpbmV0aWMxGzAZBgNVBAMMEkNhcmRpbmFsS2luZXRpYy1DQTAgFw0yNDA3
5
+ MTUxODM1NTVaGA8yMDk5MDQxMzE4MzU1NVowVzELMAkGA1UEBhMCVVMxETAPBgNV
6
+ BAgMCEtlbnR1Y2t5MRgwFgYDVQQKDA9DYXJkaW5hbEtpbmV0aWMxGzAZBgNVBAMM
7
+ EkNhcmRpbmFsS2luZXRpYy1DQTB2MBAGByqGSM49AgEGBSuBBAAiA2IABGvtdcSO
8
+ PH4qPKdA/wSbraw88KgoiBmJMaD3ko4Gaix6iZSBTEK1TU+Oxp0XwVuaQxa0J7hp
9
+ xcjuy3BLYDhfF5e5Fp/Tjc4qaQNDZs9Z0MbVytZeNtrm7u4lwKWsjIjhUqNjMGEw
10
+ HQYDVR0OBBYEFOQ3kaz6Bd2kAHicNWlIoWdSYclMMB8GA1UdIwQYMBaAFOQ3kaz6
11
+ Bd2kAHicNWlIoWdSYclMMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGG
12
+ MAoGCCqGSM49BAMCA2cAMGQCMFhAt55Z+O88sJ60Z2FcGmYztu6QF18tdj04YlQX
13
+ SBWZ8tdpWofMsJi6yHwKlhqqQgIwVEpeh5RSuVSGmZAfYNFLLSnAYV0LnkKEAmuZ
14
+ 2YwmOc7BTjgjgnZrhb9538baKIaG
15
+ -----END CERTIFICATE-----
@@ -174,105 +174,12 @@ def _discover_modules_on_netif(netif_ip_tuple, num_attempts=1, per_attempt_timeo
174
174
  # Remove 9 bytes header
175
175
  data = resp[9:]
176
176
 
177
- # Discover version
178
- # =======================================================================
179
- item_size = 1
180
- discover_version = Utils.get_typed_value(data[0:item_size], 'uint8')
181
- data = data[item_size:]
182
- # =======================================================================
177
+ module_object = Utils.decode_discover_data(data)
178
+ sn = None
183
179
 
184
- # SN
185
- # =======================================================================
186
- item_size = 25
187
- sn = Utils.get_typed_value(data[0:item_size], 'string')
188
- data = data[item_size:]
189
- # =======================================================================
190
-
191
- # PN
192
- # =======================================================================
193
- item_size = 25
194
- pn = Utils.get_typed_value(data[0:item_size], 'string')
195
- data = data[item_size:]
196
- # =======================================================================
197
-
198
- # Name
199
- # =======================================================================
200
- item_size = 33
201
- name = Utils.get_typed_value(data[0:item_size], 'string')
202
- data = data[item_size:]
203
- # =======================================================================
204
-
205
- # Firmware version
206
- # =======================================================================
207
- item_size = 1
208
- fw_major = Utils.get_typed_value(data[0:item_size], 'uint8')
209
- data = data[item_size:]
210
-
211
- item_size = 1
212
- fw_minor = Utils.get_typed_value(data[0:item_size], 'uint8')
213
- data = data[item_size:]
214
-
215
- item_size = 1
216
- fw_build = Utils.get_typed_value(data[0:item_size], 'uint8')
217
- data = data[item_size:]
218
-
219
- item_size = 1
220
- fw_type = Utils.get_typed_value(data[0:item_size], 'uint8')
221
- data = data[item_size:]
222
-
223
- firmware_flags = Utils.get_firmware_flags(fw_type)
224
- # =======================================================================
225
-
226
- # Networking
227
- # =======================================================================
228
- item_size = 6
229
- mac_address = Utils.get_typed_value(data[0:item_size], 'macAddress')
230
- data = data[item_size:]
231
-
232
- item_size = 4
233
- ip_address = Utils.get_typed_value(data[0:item_size], 'ipV4')
234
- data = data[item_size:]
235
-
236
- item_size = 4
237
- net_mask = Utils.get_typed_value(data[0:item_size], 'ipV4')
238
- data = data[item_size:]
239
-
240
- item_size = 4
241
- gateway = Utils.get_typed_value(data[0:item_size], 'ipV4')
242
- data = data[item_size:]
243
-
244
- item_size = 4
245
- dns = Utils.get_typed_value(data[0:item_size], 'ipV4')
246
- data = data[item_size:]
247
- # =======================================================================
248
-
249
- # PCB Version
250
- # =======================================================================
251
- pcb_major = 1
252
- pcb_minor = 1
253
- pcb_build = 1
254
- pcb_type = 0
255
-
256
- if discover_version >= 2:
257
- item_size = 1
258
- pcb_major = Utils.get_typed_value(data[0:item_size], 'uint8')
259
- data = data[item_size:]
260
-
261
- item_size = 1
262
- pcb_minor = Utils.get_typed_value(data[0:item_size], 'uint8')
263
- data = data[item_size:]
264
-
265
- item_size = 1
266
- pcb_build = Utils.get_typed_value(data[0:item_size], 'uint8')
267
- data = data[item_size:]
268
-
269
- if discover_version >= 3:
270
- item_size = 1
271
- pcb_type = Utils.get_typed_value(data[0:item_size], 'uint8')
272
- data = data[item_size:]
273
-
274
- pcb_flags = Utils.get_pcb_flags(pcb_type)
275
- # =======================================================================
180
+ if module_object is not None:
181
+ module_object['netif'] = netif_ip_tuple[0]
182
+ sn = module_object['sn']
276
183
 
277
184
  except struct.error:
278
185
  continue
@@ -281,25 +188,7 @@ def _discover_modules_on_netif(netif_ip_tuple, num_attempts=1, per_attempt_timeo
281
188
  continue
282
189
 
283
190
  if sn not in modules_found:
284
- new_module_d = {
285
- 'discoverVersion': discover_version,
286
- 'sn': sn,
287
- 'pn': pn,
288
- 'name': name,
289
- 'firmware': '.'.join([str(fw_major), str(fw_minor), str(fw_build)]),
290
- 'firmwareFlags': firmware_flags,
291
- 'network': {
292
- 'ip': ip_address,
293
- 'mask': net_mask,
294
- 'gw': gateway,
295
- 'dns': dns,
296
- 'mac': mac_address,
297
- },
298
- 'pcb': '.'.join([str(pcb_major), str(pcb_minor), str(pcb_build)]),
299
- 'pcbFlags': pcb_flags,
300
- "netif": netif_ip_tuple[0]
301
- }
302
- modules_found[sn] = new_module_d
191
+ modules_found[sn] = module_object
303
192
  # for resp in response_list:
304
193
  # for iteration in range(num_attempts):
305
194
 
@@ -338,6 +227,6 @@ def id_discover_lan(net_adapter_ip=None, num_attempts=2):
338
227
  pass
339
228
 
340
229
  # Return a stripped down version of the dictionary because the serial number key is no longer needed.
341
- results_list = list(all_modules_on_all_ifs.values())
342
- logging.info(f'Total modules found: {len(results_list)}')
343
- return results_list
230
+ results = list(all_modules_on_all_ifs.values())
231
+ logging.info(f'Total modules found: {len(results)}')
232
+ return results
@@ -2,12 +2,15 @@ import logging
2
2
 
3
3
  from .defines import CK
4
4
  from .utils import Utils
5
- from .wsHandle import InoDriveWS
6
5
 
7
6
 
8
7
  class DiscoverWs(object):
9
8
  def __init__(self, **kwargs):
10
- self._connection_handle: InoDriveWS = kwargs.get('connection_handle')
9
+ self._get_connection_handle = kwargs.get('get_connection_handle')
10
+
11
+ @property
12
+ def _connection_handle(self):
13
+ return self._get_connection_handle()
11
14
 
12
15
  def dispose(self):
13
16
  return
@@ -26,124 +29,11 @@ class DiscoverWs(object):
26
29
  resp_items = resp.get('items')
27
30
  if resp_items and len(resp_items) > 0:
28
31
  data = resp_items[0].get('data')
32
+ result = Utils.decode_discover_data(data)
29
33
 
30
- # Discover version
31
- # =======================================================================
32
- item_size = 1
33
- discover_version = Utils.get_typed_value(data[0:item_size], 'uint8')
34
- data = data[item_size:]
35
- # =======================================================================
36
-
37
- # SN
38
- # =======================================================================
39
- item_size = 25
40
- sn = Utils.get_typed_value(data[0:item_size], 'string')
41
- data = data[item_size:]
42
- # =======================================================================
43
-
44
- # PN
45
- # =======================================================================
46
- item_size = 25
47
- pn = Utils.get_typed_value(data[0:item_size], 'string')
48
- data = data[item_size:]
49
- # =======================================================================
50
-
51
- # Name
52
- # =======================================================================
53
- item_size = 33
54
- name = Utils.get_typed_value(data[0:item_size], 'string')
55
- data = data[item_size:]
56
- # =======================================================================
57
-
58
- # Firmware version
59
- # =======================================================================
60
- item_size = 1
61
- fw_major = Utils.get_typed_value(data[0:item_size], 'uint8')
62
- data = data[item_size:]
63
-
64
- item_size = 1
65
- fw_minor = Utils.get_typed_value(data[0:item_size], 'uint8')
66
- data = data[item_size:]
67
-
68
- item_size = 1
69
- fw_build = Utils.get_typed_value(data[0:item_size], 'uint8')
70
- data = data[item_size:]
71
-
72
- item_size = 1
73
- fw_type = Utils.get_typed_value(data[0:item_size], 'uint8')
74
- data = data[item_size:]
75
-
76
- firmware_flags = Utils.get_firmware_flags(fw_type)
77
- # =======================================================================
78
-
79
- # Networking
80
- # =======================================================================
81
- item_size = 6
82
- mac_address = Utils.get_typed_value(data[0:item_size], 'macAddress')
83
- data = data[item_size:]
84
-
85
- item_size = 4
86
- ip_address = Utils.get_typed_value(data[0:item_size], 'ipV4')
87
- data = data[item_size:]
88
-
89
- item_size = 4
90
- net_mask = Utils.get_typed_value(data[0:item_size], 'ipV4')
91
- data = data[item_size:]
92
-
93
- item_size = 4
94
- gateway = Utils.get_typed_value(data[0:item_size], 'ipV4')
95
- data = data[item_size:]
96
-
97
- item_size = 4
98
- dns = Utils.get_typed_value(data[0:item_size], 'ipV4')
99
- data = data[item_size:]
100
- # =======================================================================
101
-
102
- # PCB Version
103
- # =======================================================================
104
- pcb_major = 1
105
- pcb_minor = 1
106
- pcb_build = 1
107
- pcb_type = 0
108
-
109
- if discover_version >= 2:
110
- item_size = 1
111
- pcb_major = Utils.get_typed_value(data[0:item_size], 'uint8')
112
- data = data[item_size:]
113
-
114
- item_size = 1
115
- pcb_minor = Utils.get_typed_value(data[0:item_size], 'uint8')
116
- data = data[item_size:]
117
-
118
- item_size = 1
119
- pcb_build = Utils.get_typed_value(data[0:item_size], 'uint8')
120
- data = data[item_size:]
121
-
122
- if discover_version >= 3:
123
- item_size = 1
124
- pcb_type = Utils.get_typed_value(data[0:item_size], 'uint8')
125
- data = data[item_size:]
126
-
127
- pcb_flags = Utils.get_pcb_flags(pcb_type)
128
- # =======================================================================
129
-
130
- result = {
131
- 'discoverVersion': discover_version,
132
- 'sn': sn,
133
- 'pn': pn,
134
- 'name': name,
135
- 'firmware': '.'.join([str(fw_major), str(fw_minor), str(fw_build)]),
136
- 'firmwareFlags': firmware_flags,
137
- 'network': {
138
- 'ip': ip_address,
139
- 'mask': net_mask,
140
- 'gw': gateway,
141
- 'dns': dns,
142
- 'mac': mac_address,
143
- },
144
- 'pcb': '.'.join([str(pcb_major), str(pcb_minor), str(pcb_build)]),
145
- 'pcbFlags': pcb_flags
146
- }
34
+ if result is None:
35
+ logging.exception("Message decoding error")
36
+ return None
147
37
 
148
38
  return result
149
39
  except Exception as ex: