sensor-sdk 0.0.6__py3-none-any.whl → 0.0.8__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.
Potentially problematic release.
This version of sensor-sdk might be problematic. Click here for more details.
- sensor/gforce.py +8 -21
- sensor/sensor_data_context.py +31 -18
- sensor/sensor_device.py +6 -0
- sensor/sensor_profile.py +5 -3
- {sensor_sdk-0.0.6.dist-info → sensor_sdk-0.0.8.dist-info}/METADATA +1 -1
- sensor_sdk-0.0.8.dist-info/RECORD +14 -0
- sensor_sdk-0.0.6.dist-info/RECORD +0 -14
- {sensor_sdk-0.0.6.dist-info → sensor_sdk-0.0.8.dist-info}/LICENSE.txt +0 -0
- {sensor_sdk-0.0.6.dist-info → sensor_sdk-0.0.8.dist-info}/WHEEL +0 -0
- {sensor_sdk-0.0.6.dist-info → sensor_sdk-0.0.8.dist-info}/top_level.txt +0 -0
- {sensor_sdk-0.0.6.dist-info → sensor_sdk-0.0.8.dist-info}/zip-safe +0 -0
sensor/gforce.py
CHANGED
|
@@ -370,9 +370,7 @@ class Response:
|
|
|
370
370
|
|
|
371
371
|
|
|
372
372
|
class GForce:
|
|
373
|
-
def __init__(
|
|
374
|
-
self, device: BLEDevice, cmd_char: str, data_char: str, isUniversalStream: bool
|
|
375
|
-
):
|
|
373
|
+
def __init__(self, device: BLEDevice, cmd_char: str, data_char: str, isUniversalStream: bool):
|
|
376
374
|
self.device_name = ""
|
|
377
375
|
self.client = None
|
|
378
376
|
self.cmd_char = cmd_char
|
|
@@ -412,6 +410,7 @@ class GForce:
|
|
|
412
410
|
|
|
413
411
|
def _on_data_response(self, q: Queue[bytes], bs: bytearray):
|
|
414
412
|
bs = bytes(bs)
|
|
413
|
+
|
|
415
414
|
full_packet = []
|
|
416
415
|
|
|
417
416
|
is_partial_data = bs[0] == ResponseCode.PARTIAL_PACKET
|
|
@@ -500,9 +499,7 @@ class GForce:
|
|
|
500
499
|
def _convert_acceleration_to_g(data: bytes) -> np.ndarray[np.float32]:
|
|
501
500
|
normalizing_factor = 65536.0
|
|
502
501
|
|
|
503
|
-
acceleration_data = (
|
|
504
|
-
np.frombuffer(data, dtype=np.int32).astype(np.float32) / normalizing_factor
|
|
505
|
-
)
|
|
502
|
+
acceleration_data = np.frombuffer(data, dtype=np.int32).astype(np.float32) / normalizing_factor
|
|
506
503
|
num_channels = 3
|
|
507
504
|
|
|
508
505
|
return acceleration_data.reshape(-1, num_channels)
|
|
@@ -511,9 +508,7 @@ class GForce:
|
|
|
511
508
|
def _convert_gyro_to_dps(data: bytes) -> np.ndarray[np.float32]:
|
|
512
509
|
normalizing_factor = 65536.0
|
|
513
510
|
|
|
514
|
-
gyro_data = (
|
|
515
|
-
np.frombuffer(data, dtype=np.int32).astype(np.float32) / normalizing_factor
|
|
516
|
-
)
|
|
511
|
+
gyro_data = np.frombuffer(data, dtype=np.int32).astype(np.float32) / normalizing_factor
|
|
517
512
|
num_channels = 3
|
|
518
513
|
|
|
519
514
|
return gyro_data.reshape(-1, num_channels)
|
|
@@ -522,9 +517,7 @@ class GForce:
|
|
|
522
517
|
def _convert_magnetometer_to_ut(data: bytes) -> np.ndarray[np.float32]:
|
|
523
518
|
normalizing_factor = 65536.0
|
|
524
519
|
|
|
525
|
-
magnetometer_data = (
|
|
526
|
-
np.frombuffer(data, dtype=np.int32).astype(np.float32) / normalizing_factor
|
|
527
|
-
)
|
|
520
|
+
magnetometer_data = np.frombuffer(data, dtype=np.int32).astype(np.float32) / normalizing_factor
|
|
528
521
|
num_channels = 3
|
|
529
522
|
|
|
530
523
|
return magnetometer_data.reshape(-1, num_channels)
|
|
@@ -846,15 +839,11 @@ class GForce:
|
|
|
846
839
|
async def stop_streaming(self):
|
|
847
840
|
exceptions = []
|
|
848
841
|
try:
|
|
849
|
-
await asyncio.wait_for(
|
|
850
|
-
self.set_subscription(DataSubscription.OFF), utils._TIMEOUT
|
|
851
|
-
)
|
|
842
|
+
await asyncio.wait_for(self.set_subscription(DataSubscription.OFF), utils._TIMEOUT)
|
|
852
843
|
except Exception as e:
|
|
853
844
|
exceptions.append(e)
|
|
854
845
|
try:
|
|
855
|
-
await asyncio.wait_for(
|
|
856
|
-
self.client.stop_notify(self.data_char), utils._TIMEOUT
|
|
857
|
-
)
|
|
846
|
+
await asyncio.wait_for(self.client.stop_notify(self.data_char), utils._TIMEOUT)
|
|
858
847
|
except Exception as e:
|
|
859
848
|
exceptions.append(e)
|
|
860
849
|
|
|
@@ -881,9 +870,7 @@ class GForce:
|
|
|
881
870
|
bs = bytes([req.cmd])
|
|
882
871
|
if req.body is not None:
|
|
883
872
|
bs += req.body
|
|
884
|
-
await asyncio.wait_for(
|
|
885
|
-
self.client.write_gatt_char(self.cmd_char, bs), utils._TIMEOUT
|
|
886
|
-
)
|
|
873
|
+
await asyncio.wait_for(self.client.write_gatt_char(self.cmd_char, bs), utils._TIMEOUT)
|
|
887
874
|
|
|
888
875
|
if not req.has_res:
|
|
889
876
|
return None
|
sensor/sensor_data_context.py
CHANGED
|
@@ -11,7 +11,6 @@ from sensor.sensor_data import DataType, Sample, SensorData
|
|
|
11
11
|
from enum import Enum, IntEnum
|
|
12
12
|
|
|
13
13
|
from sensor.sensor_device import DeviceInfo
|
|
14
|
-
from sensor.utils import timer
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
class SensorDataType(IntEnum):
|
|
@@ -205,13 +204,13 @@ class SensorProfileDataCtx:
|
|
|
205
204
|
info.MTUSize = self.gForce.client.mtu_size
|
|
206
205
|
else:
|
|
207
206
|
info.MTUSize = 0
|
|
208
|
-
print("get_device_name")
|
|
207
|
+
# print("get_device_name")
|
|
209
208
|
info.DeviceName = await self.gForce.get_device_name()
|
|
210
|
-
print("get_model_number")
|
|
209
|
+
# print("get_model_number")
|
|
211
210
|
info.ModelName = await self.gForce.get_model_number()
|
|
212
|
-
print("get_hardware_revision")
|
|
211
|
+
# print("get_hardware_revision")
|
|
213
212
|
info.HardwareVersion = await self.gForce.get_hardware_revision()
|
|
214
|
-
print("get_firmware_revision")
|
|
213
|
+
# print("get_firmware_revision")
|
|
215
214
|
info.FirmwareVersion = await self.gForce.get_firmware_revision()
|
|
216
215
|
return info
|
|
217
216
|
|
|
@@ -226,22 +225,27 @@ class SensorProfileDataCtx:
|
|
|
226
225
|
self.notifyDataFlag |= DataSubscription.DNF_IMPEDANCE
|
|
227
226
|
|
|
228
227
|
if self.hasEEG():
|
|
229
|
-
print("initEEG")
|
|
228
|
+
# print("initEEG")
|
|
230
229
|
info.EegChannelCount = await self.initEEG(packageCount)
|
|
230
|
+
info.EegSampleRate = self.sensorDatas[SensorDataType.DATA_TYPE_EEG].sampleRate
|
|
231
231
|
|
|
232
232
|
if self.hasECG():
|
|
233
|
-
print("initECG")
|
|
233
|
+
# print("initECG")
|
|
234
234
|
info.EcgChannelCount = await self.initECG(packageCount)
|
|
235
|
+
info.EcgSampleRate = self.sensorDatas[SensorDataType.DATA_TYPE_ECG].sampleRate
|
|
235
236
|
|
|
236
237
|
if self.hasBrth():
|
|
237
|
-
print("initBrth")
|
|
238
|
+
# print("initBrth")
|
|
238
239
|
info.BrthChannelCount = await self.initBrth(packageCount)
|
|
240
|
+
info.BrthSampleRate = self.sensorDatas[SensorDataType.DATA_TYPE_BRTH].sampleRate
|
|
239
241
|
|
|
240
242
|
if self.hasIMU():
|
|
241
|
-
print("initIMU")
|
|
243
|
+
# print("initIMU")
|
|
242
244
|
imuChannelCount = await self.initIMU(packageCount)
|
|
243
245
|
info.AccChannelCount = imuChannelCount
|
|
244
246
|
info.GyroChannelCount = imuChannelCount
|
|
247
|
+
info.AccSampleRate = self.sensorDatas[SensorDataType.DATA_TYPE_ACC].sampleRate
|
|
248
|
+
info.GyroSampleRate = self.sensorDatas[SensorDataType.DATA_TYPE_GYRO].sampleRate
|
|
245
249
|
|
|
246
250
|
self._device_info = info
|
|
247
251
|
|
|
@@ -786,9 +790,15 @@ class SensorProfileDataCtx:
|
|
|
786
790
|
|
|
787
791
|
return crc8
|
|
788
792
|
|
|
789
|
-
def processUniversalData(
|
|
793
|
+
async def processUniversalData(
|
|
794
|
+
self, buf: Queue[SensorData], event_loop: asyncio.AbstractEventLoop, cmd_loop: asyncio.AbstractEventLoop, sensor, callback
|
|
795
|
+
):
|
|
790
796
|
|
|
791
797
|
while self._is_running:
|
|
798
|
+
while self._is_running and self._rawDataBuffer.empty():
|
|
799
|
+
await asyncio.sleep(0.01)
|
|
800
|
+
continue
|
|
801
|
+
|
|
792
802
|
try:
|
|
793
803
|
while self._is_running and not self._rawDataBuffer.empty():
|
|
794
804
|
data = self._rawDataBuffer.get_nowait()
|
|
@@ -821,21 +831,21 @@ class SensorProfileDataCtx:
|
|
|
821
831
|
if self._is_data_transfering:
|
|
822
832
|
data_package = bytes(self._concatDataBuffer[index + 2 : index + 2 + n])
|
|
823
833
|
self._processDataPackage(data_package, buf, sensor)
|
|
824
|
-
while self._is_running and self.isDataTransfering:
|
|
834
|
+
while self._is_running and self.isDataTransfering and not buf.empty():
|
|
825
835
|
sensorData: SensorData = None
|
|
826
836
|
try:
|
|
827
837
|
sensorData = buf.get_nowait()
|
|
828
838
|
except Exception as e:
|
|
829
839
|
break
|
|
830
|
-
if
|
|
840
|
+
if event_loop != None and sensorData != None and callback != None:
|
|
831
841
|
try:
|
|
832
|
-
|
|
842
|
+
event_loop.call_soon_threadsafe(callback, sensor, sensorData)
|
|
833
843
|
except Exception as e:
|
|
834
844
|
print(e)
|
|
835
845
|
|
|
836
846
|
buf.task_done()
|
|
837
|
-
|
|
838
847
|
last_cut = index = index + 2 + n
|
|
848
|
+
|
|
839
849
|
elif self._concatDataBuffer[index] == 0xAA:
|
|
840
850
|
if (index + 1) >= data_size:
|
|
841
851
|
index += 1
|
|
@@ -850,11 +860,14 @@ class SensorProfileDataCtx:
|
|
|
850
860
|
index += 1
|
|
851
861
|
continue
|
|
852
862
|
data_package = bytes(self._concatDataBuffer[index + 2 : index + 2 + n])
|
|
853
|
-
if
|
|
854
|
-
|
|
863
|
+
if cmd_loop != None:
|
|
864
|
+
cmd_loop.call_soon_threadsafe(self.gForce._on_cmd_response, None, data_package)
|
|
855
865
|
last_cut = index = index + 2 + n
|
|
866
|
+
|
|
856
867
|
else:
|
|
857
868
|
index += 1
|
|
858
869
|
|
|
859
|
-
|
|
860
|
-
|
|
870
|
+
if last_cut > 0:
|
|
871
|
+
self._concatDataBuffer = self._concatDataBuffer[last_cut + 1 :]
|
|
872
|
+
last_cut = -1
|
|
873
|
+
index = 0
|
sensor/sensor_device.py
CHANGED
|
@@ -40,11 +40,17 @@ class DeviceInfo:
|
|
|
40
40
|
self.HardwareVersion = ""
|
|
41
41
|
self.FirmwareVersion = ""
|
|
42
42
|
self.EmgChannelCount = 0
|
|
43
|
+
self.EmgSampleRate = 0
|
|
43
44
|
self.EegChannelCount = 0
|
|
45
|
+
self.EegSampleRate = 0
|
|
44
46
|
self.EcgChannelCount = 0
|
|
47
|
+
self.EcgSampleRate = 0
|
|
45
48
|
self.AccChannelCount = 0
|
|
49
|
+
self.AccSampleRate = 0
|
|
46
50
|
self.GyroChannelCount = 0
|
|
51
|
+
self.GyroSampleRate = 0
|
|
47
52
|
self.BrthChannelCount = 0
|
|
53
|
+
self.BrthSampleRate = 0
|
|
48
54
|
self.MTUSize = 0
|
|
49
55
|
|
|
50
56
|
|
sensor/sensor_profile.py
CHANGED
|
@@ -351,7 +351,9 @@ class SensorProfile:
|
|
|
351
351
|
self._data_buffer.task_done()
|
|
352
352
|
|
|
353
353
|
async def _process_universal_data(self):
|
|
354
|
-
self._data_ctx.processUniversalData(
|
|
354
|
+
await self._data_ctx.processUniversalData(
|
|
355
|
+
self._data_buffer, self._event_loop, self._gforce_event_loop, self, self._on_data_callback
|
|
356
|
+
)
|
|
355
357
|
|
|
356
358
|
async def _startDataNotification(self) -> bool:
|
|
357
359
|
if self.deviceState != DeviceStateEx.Ready:
|
|
@@ -474,7 +476,7 @@ class SensorProfile:
|
|
|
474
476
|
return sync_call(
|
|
475
477
|
self._gforce_event_loop,
|
|
476
478
|
self._init(packageSampleCount, powerRefreshInterval),
|
|
477
|
-
|
|
479
|
+
20,
|
|
478
480
|
)
|
|
479
481
|
|
|
480
482
|
async def asyncInit(self, packageSampleCount: int, powerRefreshInterval: int) -> bool:
|
|
@@ -490,7 +492,7 @@ class SensorProfile:
|
|
|
490
492
|
return await async_call(
|
|
491
493
|
self._gforce_event_loop,
|
|
492
494
|
self._init(packageSampleCount, powerRefreshInterval),
|
|
493
|
-
|
|
495
|
+
20,
|
|
494
496
|
)
|
|
495
497
|
|
|
496
498
|
def getBatteryLevel(self) -> int:
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
sensor/__init__.py,sha256=L1VyAP0EDEnJIMeMTzp4iXHSRUUHyHScF_GIl3iYKRI,123
|
|
2
|
+
sensor/gforce.py,sha256=wHnZ9fJiqzD9TpHekWsEqp3VIyIBhbXwJSj5k6FjVNw,25049
|
|
3
|
+
sensor/sensor_controller.py,sha256=lNi7i3T_aAHEJvv963OvVv_PNAYy_5-BwXD82XNvnGg,10028
|
|
4
|
+
sensor/sensor_data.py,sha256=Hu7Ql0LgQ7V24xYZhaLrKPwU4KWZeWE655v8Gy8xphY,3934
|
|
5
|
+
sensor/sensor_data_context.py,sha256=KuwdB_l-IC4hxcN_9MMfiRQCLZQBpCn3TgWZioQrSpc,29364
|
|
6
|
+
sensor/sensor_device.py,sha256=eO1vaqjxCc2UCPBoKXqlk6o498uRyWt6IYs7r7wXSD0,3042
|
|
7
|
+
sensor/sensor_profile.py,sha256=mjqOEZLGJQYY8zhH8TA0HRVxrFC4AjjKAj_zGOQMgHg,19678
|
|
8
|
+
sensor/utils.py,sha256=ybmByBldCQ_x-sVtjA2mdXWo0QOafPAupfnWAxLrkV0,1773
|
|
9
|
+
sensor_sdk-0.0.8.dist-info/LICENSE.txt,sha256=8CSivOpub3IuXODTyqBRI91AxouJZk02YrcKuOAkWu8,1111
|
|
10
|
+
sensor_sdk-0.0.8.dist-info/METADATA,sha256=BfvYDfGxMX44lgFKSXsx6QvxjMaE94xKaG327ww3iYI,8374
|
|
11
|
+
sensor_sdk-0.0.8.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
12
|
+
sensor_sdk-0.0.8.dist-info/top_level.txt,sha256=Ftq49B6bH0Ffdc7c8LkcyakHo6lsg_snlBbpEUoILSk,7
|
|
13
|
+
sensor_sdk-0.0.8.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
14
|
+
sensor_sdk-0.0.8.dist-info/RECORD,,
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
sensor/__init__.py,sha256=L1VyAP0EDEnJIMeMTzp4iXHSRUUHyHScF_GIl3iYKRI,123
|
|
2
|
-
sensor/gforce.py,sha256=z-w9POiw5rtj6AgTvwFAI6tZt_5jv_3eSiKt_0jA1Ps,25229
|
|
3
|
-
sensor/sensor_controller.py,sha256=lNi7i3T_aAHEJvv963OvVv_PNAYy_5-BwXD82XNvnGg,10028
|
|
4
|
-
sensor/sensor_data.py,sha256=Hu7Ql0LgQ7V24xYZhaLrKPwU4KWZeWE655v8Gy8xphY,3934
|
|
5
|
-
sensor/sensor_data_context.py,sha256=7GQwthoAH-qJsimWwCf8JcQAP8TivG3X0lwxfyHabo4,28575
|
|
6
|
-
sensor/sensor_device.py,sha256=LCjBzm2TuOh2KpHsFTjm1sF8hzwvS22LhF_ueAct0Jo,2848
|
|
7
|
-
sensor/sensor_profile.py,sha256=SFecXPCauvadRJdssu9iWMgCdxRinTqGlzLAQsZ8-k8,19625
|
|
8
|
-
sensor/utils.py,sha256=ybmByBldCQ_x-sVtjA2mdXWo0QOafPAupfnWAxLrkV0,1773
|
|
9
|
-
sensor_sdk-0.0.6.dist-info/LICENSE.txt,sha256=8CSivOpub3IuXODTyqBRI91AxouJZk02YrcKuOAkWu8,1111
|
|
10
|
-
sensor_sdk-0.0.6.dist-info/METADATA,sha256=JP3HgNyVlwNe2AkT7LMm1PCVAxGtLr4XrdkfHZKBmL0,8374
|
|
11
|
-
sensor_sdk-0.0.6.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
12
|
-
sensor_sdk-0.0.6.dist-info/top_level.txt,sha256=Ftq49B6bH0Ffdc7c8LkcyakHo6lsg_snlBbpEUoILSk,7
|
|
13
|
-
sensor_sdk-0.0.6.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
14
|
-
sensor_sdk-0.0.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|