sensor-sdk 0.0.31__tar.gz → 0.0.32__tar.gz
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.
Potentially problematic release.
This version of sensor-sdk might be problematic. Click here for more details.
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/PKG-INFO +4 -13
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/README.md +2 -2
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/sensor/sensor_data.py +5 -3
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/sensor/sensor_data_context.py +40 -17
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/sensor/sensor_profile.py +2 -2
- sensor_sdk-0.0.32/sensor/sensor_utils.py +906 -0
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/sensor_sdk.egg-info/PKG-INFO +4 -13
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/setup.py +1 -1
- sensor_sdk-0.0.31/sensor/sensor_utils.py +0 -373
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/LICENSE.txt +0 -0
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/sensor/__init__.py +0 -0
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/sensor/gforce.py +0 -0
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/sensor/sensor_controller.py +0 -0
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/sensor/sensor_device.py +0 -0
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/sensor_sdk.egg-info/SOURCES.txt +0 -0
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/sensor_sdk.egg-info/dependency_links.txt +0 -0
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/sensor_sdk.egg-info/requires.txt +0 -0
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/sensor_sdk.egg-info/top_level.txt +0 -0
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/sensor_sdk.egg-info/zip-safe +0 -0
- {sensor_sdk-0.0.31 → sensor_sdk-0.0.32}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: sensor-sdk
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.32
|
|
4
4
|
Summary: Python sdk for Synchroni
|
|
5
5
|
Home-page: https://github.com/oymotion/SynchroniSDKPython
|
|
6
6
|
Author: Martin Ye
|
|
@@ -11,15 +11,6 @@ License-File: LICENSE.txt
|
|
|
11
11
|
Requires-Dist: numpy
|
|
12
12
|
Requires-Dist: setuptools
|
|
13
13
|
Requires-Dist: bleak
|
|
14
|
-
Dynamic: author
|
|
15
|
-
Dynamic: author-email
|
|
16
|
-
Dynamic: description
|
|
17
|
-
Dynamic: description-content-type
|
|
18
|
-
Dynamic: home-page
|
|
19
|
-
Dynamic: license-file
|
|
20
|
-
Dynamic: requires-dist
|
|
21
|
-
Dynamic: requires-python
|
|
22
|
-
Dynamic: summary
|
|
23
14
|
|
|
24
15
|
# sensor-sdk
|
|
25
16
|
|
|
@@ -387,10 +378,10 @@ result = sensorProfile.setParam("NTF_IMU", "ON")
|
|
|
387
378
|
result = sensorProfile.setParam("NTF_BRTH", "ON")
|
|
388
379
|
# set BRTH data to ON or OFF, result is "OK" if succeed
|
|
389
380
|
|
|
390
|
-
result = sensorProfile.setParam("
|
|
381
|
+
result = sensorProfile.setParam("FILTER_50HZ", "ON")
|
|
391
382
|
# set 50Hz notch filter to ON or OFF, result is "OK" if succeed
|
|
392
383
|
|
|
393
|
-
result = sensorProfile.setParam("
|
|
384
|
+
result = sensorProfile.setParam("FILTER_60HZ", "ON")
|
|
394
385
|
# set 60Hz notch filter to ON or OFF, result is "OK" if succeed
|
|
395
386
|
|
|
396
387
|
result = sensorProfile.setParam("FILTER_HPF", "ON")
|
|
@@ -364,10 +364,10 @@ result = sensorProfile.setParam("NTF_IMU", "ON")
|
|
|
364
364
|
result = sensorProfile.setParam("NTF_BRTH", "ON")
|
|
365
365
|
# set BRTH data to ON or OFF, result is "OK" if succeed
|
|
366
366
|
|
|
367
|
-
result = sensorProfile.setParam("
|
|
367
|
+
result = sensorProfile.setParam("FILTER_50HZ", "ON")
|
|
368
368
|
# set 50Hz notch filter to ON or OFF, result is "OK" if succeed
|
|
369
369
|
|
|
370
|
-
result = sensorProfile.setParam("
|
|
370
|
+
result = sensorProfile.setParam("FILTER_60HZ", "ON")
|
|
371
371
|
# set 60Hz notch filter to ON or OFF, result is "OK" if succeed
|
|
372
372
|
|
|
373
373
|
result = sensorProfile.setParam("FILTER_HPF", "ON")
|
|
@@ -41,10 +41,12 @@ class DataType(IntEnum):
|
|
|
41
41
|
NTF_EMG = 0x8 # EMG,用于标识肌电传感器采集的数据
|
|
42
42
|
NTF_EEG = 0x10 # EEG,用于标识脑电传感器采集的数据
|
|
43
43
|
NTF_ECG = 0x11 # ECG,用于标识心电传感器采集的数据
|
|
44
|
-
NTF_IMPEDANCE =
|
|
45
|
-
NTF_IMU =
|
|
46
|
-
NTF_ADS =
|
|
44
|
+
NTF_IMPEDANCE = 0x12 # 阻抗数据
|
|
45
|
+
NTF_IMU = 0x13 # 包含ACC和GYRO数据
|
|
46
|
+
NTF_ADS = 0x14 # 无单位ads数据
|
|
47
47
|
NTF_BRTH = 0x15 # 呼吸,用于标识呼吸传感器采集的数据
|
|
48
|
+
NTF_IMPEDANCE_EXT = 0x16 # 阻抗数据扩展
|
|
49
|
+
NTF_DATA_TYPE_MAX = 0x17
|
|
48
50
|
|
|
49
51
|
|
|
50
52
|
# 一次采样的数据,包含多个通道的数据,channal_samples 为一个二维数组, 第一个维度为通道索引,第二个维度为采样索引
|
|
@@ -61,7 +61,7 @@ class SensorProfileDataCtx:
|
|
|
61
61
|
self.saturationData: List[float] = list()
|
|
62
62
|
self.dataPool = ThreadPoolExecutor(1, "data")
|
|
63
63
|
self.init_map = {"NTF_EMG": "ON", "NTF_EEG": "ON", "NTF_ECG": "ON", "NTF_IMU": "ON", "NTF_BRTH": "ON"}
|
|
64
|
-
self.filter_map = {"
|
|
64
|
+
self.filter_map = {"FILTER_50HZ": "ON", "FILTER_60HZ": "ON", "FILTER_HPF": "ON", "FILTER_LPF": "ON"}
|
|
65
65
|
self.debugCSVWriter = None
|
|
66
66
|
self.debugCSVPath = None
|
|
67
67
|
|
|
@@ -340,10 +340,10 @@ class SensorProfileDataCtx:
|
|
|
340
340
|
switch = 0
|
|
341
341
|
for filter in self.filter_map.keys():
|
|
342
342
|
value = self.filter_map[filter]
|
|
343
|
-
if filter == "
|
|
343
|
+
if filter == "FILTER_50HZ":
|
|
344
344
|
if value == "ON":
|
|
345
345
|
switch |= 1
|
|
346
|
-
elif filter == "
|
|
346
|
+
elif filter == "FILTER_60HZ":
|
|
347
347
|
if value == "ON":
|
|
348
348
|
switch |= 2
|
|
349
349
|
elif filter == "FILTER_HPF":
|
|
@@ -427,6 +427,29 @@ class SensorProfileDataCtx:
|
|
|
427
427
|
|
|
428
428
|
self.impedanceData = impedanceData
|
|
429
429
|
self.saturationData = saturationData
|
|
430
|
+
elif v == DataType.NTF_IMPEDANCE_EXT:
|
|
431
|
+
offset = 1
|
|
432
|
+
# packageIndex = ((data[offset + 1] & 0xff) << 8) | (data[offset] & 0xff)
|
|
433
|
+
offset += 2
|
|
434
|
+
|
|
435
|
+
impedanceData = []
|
|
436
|
+
saturationData = []
|
|
437
|
+
|
|
438
|
+
dataCount = self._device_info.EegChannelCount + self._device_info.EcgChannelCount
|
|
439
|
+
|
|
440
|
+
for index in range(dataCount):
|
|
441
|
+
impedance = struct.unpack_from("<f", data, offset)[0]
|
|
442
|
+
offset += 4
|
|
443
|
+
impedanceData.append(impedance)
|
|
444
|
+
|
|
445
|
+
for index in range(dataCount):
|
|
446
|
+
saturation = struct.unpack_from("<H", data, offset)[0]
|
|
447
|
+
offset += 2
|
|
448
|
+
saturationData.append(saturation / 10) # firmware value range 0 - 1000
|
|
449
|
+
|
|
450
|
+
self.impedanceData = impedanceData
|
|
451
|
+
self.saturationData = saturationData
|
|
452
|
+
|
|
430
453
|
elif v == DataType.NTF_EMG:
|
|
431
454
|
sensor_data = self.sensorDatas[SensorDataType.DATA_TYPE_EMG]
|
|
432
455
|
if self.checkReadSamples(sensor, data, sensor_data, 3, 0):
|
|
@@ -712,39 +735,39 @@ class SensorProfileDataCtx:
|
|
|
712
735
|
|
|
713
736
|
if self._concatDataBuffer[index] == 0x55:
|
|
714
737
|
if (index + 1) >= data_size:
|
|
715
|
-
index
|
|
738
|
+
index = data_size
|
|
716
739
|
continue
|
|
717
740
|
n = self._concatDataBuffer[index + 1]
|
|
718
|
-
if (index + 1 + n +
|
|
719
|
-
index
|
|
741
|
+
if (index + 1 + n + 2) >= data_size:
|
|
742
|
+
index = data_size
|
|
720
743
|
continue
|
|
721
|
-
|
|
722
|
-
calc_crc = sensor_utils.
|
|
723
|
-
if
|
|
744
|
+
crc16 = (self._concatDataBuffer[index + 1 + n + 2] << 8) | self._concatDataBuffer[index + 1 + n + 1]
|
|
745
|
+
calc_crc = sensor_utils.crc16_cal(self._concatDataBuffer[index + 2 : index + 2 + n], n)
|
|
746
|
+
if crc16 != calc_crc:
|
|
724
747
|
index += 1
|
|
725
748
|
continue
|
|
726
749
|
if self._is_data_transfering:
|
|
727
750
|
data_package = bytes(self._concatDataBuffer[index + 2 : index + 2 + n])
|
|
728
751
|
self._processDataPackage(data_package, buf, sensor)
|
|
729
|
-
last_cut = index = index + 2 + n
|
|
752
|
+
last_cut = index = index + 2 + n + 1
|
|
730
753
|
elif self._concatDataBuffer[index] == 0xAA:
|
|
731
754
|
if (index + 1) >= data_size:
|
|
732
|
-
index
|
|
755
|
+
index = data_size
|
|
733
756
|
continue
|
|
734
757
|
n = self._concatDataBuffer[index + 1]
|
|
735
|
-
if (index + 1 + n +
|
|
736
|
-
index
|
|
758
|
+
if (index + 1 + n + 2) >= data_size:
|
|
759
|
+
index = data_size
|
|
737
760
|
continue
|
|
738
|
-
|
|
739
|
-
calc_crc = sensor_utils.
|
|
740
|
-
if
|
|
761
|
+
crc16 = (self._concatDataBuffer[index + 1 + n + 2] << 8) | self._concatDataBuffer[index + 1 + n + 1]
|
|
762
|
+
calc_crc = sensor_utils.crc16_cal(self._concatDataBuffer[index + 2 : index + 2 + n], n)
|
|
763
|
+
if crc16 != calc_crc:
|
|
741
764
|
index += 1
|
|
742
765
|
continue
|
|
743
766
|
data_package = bytes(self._concatDataBuffer[index + 2 : index + 2 + n])
|
|
744
767
|
|
|
745
768
|
if not sensor_utils._terminated:
|
|
746
769
|
await sensor_utils.async_call(self.gForce.async_on_cmd_response(data_package), runloop=sensor._event_loop)
|
|
747
|
-
last_cut = index = index + 2 + n
|
|
770
|
+
last_cut = index = index + 2 + n + 1
|
|
748
771
|
else:
|
|
749
772
|
index += 1
|
|
750
773
|
|
|
@@ -582,12 +582,12 @@ class SensorProfile:
|
|
|
582
582
|
if self.deviceState != DeviceStateEx.Ready:
|
|
583
583
|
result = "Error: Please connect first"
|
|
584
584
|
|
|
585
|
-
if key in ["NTF_EMG", "NTF_EEG", "NTF_ECG", "NTF_IMU", "NTF_BRTH"]:
|
|
585
|
+
if key in ["NTF_EMG", "NTF_EEG", "NTF_ECG", "NTF_IMU", "NTF_BRTH", "NTF_IMPEDANCE"]:
|
|
586
586
|
if value in ["ON", "OFF"]:
|
|
587
587
|
self._data_ctx.init_map[key] = value
|
|
588
588
|
result = "OK"
|
|
589
589
|
|
|
590
|
-
if key in ["
|
|
590
|
+
if key in ["FILTER_50HZ", "FILTER_60HZ", "FILTER_HPF", "FILTER_LPF"]:
|
|
591
591
|
if value in ["ON", "OFF"]:
|
|
592
592
|
result = await self._data_ctx.setFilter(key, value)
|
|
593
593
|
|