sensor-sdk 0.1.4__tar.gz → 0.1.5__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.
- {sensor_sdk-0.1.4/sensor_sdk.egg-info → sensor_sdk-0.1.5}/PKG-INFO +1 -1
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/sensor_data_context.py +8 -2
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/sensor_utils.py +24 -23
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5/sensor_sdk.egg-info}/PKG-INFO +1 -1
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/setup.py +1 -1
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/LICENSE.txt +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/README.md +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/__init__.py +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/bleak_host.py +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/bleak_process.py +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/fb/DataType.py +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/fb/Sample.py +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/fb/SensorData.py +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/fb/__init__.py +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/gforce.py +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/sdk_log.py +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/sensor_controller.py +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/sensor_data.py +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/sensor_data_pool.py +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/sensor_device.py +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/sensor_profile.py +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor/winrt_high_throughput.py +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor_sdk.egg-info/SOURCES.txt +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor_sdk.egg-info/dependency_links.txt +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor_sdk.egg-info/requires.txt +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor_sdk.egg-info/top_level.txt +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/sensor_sdk.egg-info/zip-safe +0 -0
- {sensor_sdk-0.1.4 → sensor_sdk-0.1.5}/setup.cfg +0 -0
|
@@ -1476,9 +1476,15 @@ class SensorProfileDataCtx:
|
|
|
1476
1476
|
lostSampleCount: int,
|
|
1477
1477
|
):
|
|
1478
1478
|
sampleCount = sensorData.packageSampleCount
|
|
1479
|
+
def _type_name():
|
|
1480
|
+
try:
|
|
1481
|
+
return DataType(sensorData.dataType).name
|
|
1482
|
+
except Exception:
|
|
1483
|
+
return str(sensorData.dataType)
|
|
1484
|
+
|
|
1479
1485
|
if lostSampleCount <= 0:
|
|
1480
1486
|
if data is None or offset < 0 or offset > len(data):
|
|
1481
|
-
raise ValueError("Invalid data or offset")
|
|
1487
|
+
raise ValueError(f"Invalid data or offset for data type {_type_name()}")
|
|
1482
1488
|
|
|
1483
1489
|
if sensorData.resolutionBits in (7, 8):
|
|
1484
1490
|
bytesPerChannel = 1
|
|
@@ -1499,7 +1505,7 @@ class SensorProfileDataCtx:
|
|
|
1499
1505
|
realChannelCount += 1
|
|
1500
1506
|
|
|
1501
1507
|
if offset + ((bytesPerChannel * realChannelCount * sampleCount) + (dataGap * (sampleCount - 1))) > dataLength:
|
|
1502
|
-
raise ValueError(f"Invalid dataLength:{dataLength}")
|
|
1508
|
+
raise ValueError(f"Invalid dataLength:{dataLength} for data type {_type_name()}")
|
|
1503
1509
|
|
|
1504
1510
|
|
|
1505
1511
|
sampleInterval = (
|
|
@@ -38,33 +38,34 @@ def Terminate():
|
|
|
38
38
|
global _runloop, _needCloseRunloop, _event_thread, _terminated
|
|
39
39
|
_terminated = True
|
|
40
40
|
|
|
41
|
+
# 如果不是我们创建的 loop(例如用户自己的 qasync/Qt loop),不要动它
|
|
42
|
+
if not _needCloseRunloop or _runloop is None:
|
|
43
|
+
return
|
|
44
|
+
|
|
41
45
|
def _cancel_tasks():
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
try:
|
|
47
|
+
# 在 loop 线程内部调用,有运行中的事件循环
|
|
48
|
+
for task in asyncio.all_tasks():
|
|
49
|
+
if not task.done():
|
|
50
|
+
task.cancel()
|
|
51
|
+
except Exception:
|
|
52
|
+
# 取消任务失败时不阻塞终止流程
|
|
53
|
+
pass
|
|
44
54
|
|
|
45
55
|
try:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
_runloop.call_soon_threadsafe(_cancel_tasks)
|
|
52
|
-
time.sleep(0.1)
|
|
53
|
-
except Exception as e:
|
|
54
|
-
SdkLog.exception(_TAG, "Error cancelling tasks during terminate")
|
|
55
|
-
except Exception as e:
|
|
56
|
-
SdkLog.exception(_TAG, "Error cancelling tasks during terminate")
|
|
56
|
+
# 取消 / stop 都必须在 loop 所在线程执行,避免跨线程调用 asyncio API 抛异常
|
|
57
|
+
if _runloop.is_running():
|
|
58
|
+
_runloop.call_soon_threadsafe(_cancel_tasks)
|
|
59
|
+
time.sleep(0.2)
|
|
60
|
+
_runloop.call_soon_threadsafe(_runloop.stop)
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
_runloop.close()
|
|
66
|
-
except Exception as e:
|
|
67
|
-
SdkLog.exception(_TAG, "Error closing runloop during terminate")
|
|
62
|
+
if _event_thread is not None and _event_thread.is_alive():
|
|
63
|
+
_event_thread.join(timeout=3.0)
|
|
64
|
+
|
|
65
|
+
# 不再主动 close loop:Windows 的 ProactorEventLoop 在 still-running 时 close()
|
|
66
|
+
# 会抛 RuntimeError。守护线程会在 loop stop 后自然退出,进程退出时回收资源。
|
|
67
|
+
except Exception as e:
|
|
68
|
+
SdkLog.exception(_TAG, "Error during terminate")
|
|
68
69
|
|
|
69
70
|
|
|
70
71
|
def async_exec(function, runloop=None):
|
|
@@ -8,7 +8,7 @@ with open(os.path.join(this_directory, "README.md"), "r", encoding="utf-8") as f
|
|
|
8
8
|
|
|
9
9
|
setup(
|
|
10
10
|
name="sensor-sdk",
|
|
11
|
-
version="0.1.
|
|
11
|
+
version="0.1.5",
|
|
12
12
|
description="Python sdk for Synchroni",
|
|
13
13
|
long_description=long_description,
|
|
14
14
|
long_description_content_type="text/markdown",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|