sensor-sdk 0.0.6__tar.gz → 0.0.7__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.6 → sensor-sdk-0.0.7}/PKG-INFO +1 -1
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/sensor/gforce.py +8 -21
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/sensor/sensor_data_context.py +24 -17
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/sensor/sensor_profile.py +5 -3
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/sensor_sdk.egg-info/PKG-INFO +1 -1
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/setup.py +1 -1
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/LICENSE.txt +0 -0
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/README.md +0 -0
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/sensor/__init__.py +0 -0
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/sensor/sensor_controller.py +0 -0
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/sensor/sensor_data.py +0 -0
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/sensor/sensor_device.py +0 -0
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/sensor/utils.py +0 -0
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/sensor_sdk.egg-info/SOURCES.txt +0 -0
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/sensor_sdk.egg-info/dependency_links.txt +0 -0
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/sensor_sdk.egg-info/requires.txt +0 -0
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/sensor_sdk.egg-info/top_level.txt +0 -0
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/sensor_sdk.egg-info/zip-safe +0 -0
- {sensor-sdk-0.0.6 → sensor-sdk-0.0.7}/setup.cfg +0 -0
|
@@ -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
|
|
@@ -205,13 +205,13 @@ class SensorProfileDataCtx:
|
|
|
205
205
|
info.MTUSize = self.gForce.client.mtu_size
|
|
206
206
|
else:
|
|
207
207
|
info.MTUSize = 0
|
|
208
|
-
print("get_device_name")
|
|
208
|
+
# print("get_device_name")
|
|
209
209
|
info.DeviceName = await self.gForce.get_device_name()
|
|
210
|
-
print("get_model_number")
|
|
210
|
+
# print("get_model_number")
|
|
211
211
|
info.ModelName = await self.gForce.get_model_number()
|
|
212
|
-
print("get_hardware_revision")
|
|
212
|
+
# print("get_hardware_revision")
|
|
213
213
|
info.HardwareVersion = await self.gForce.get_hardware_revision()
|
|
214
|
-
print("get_firmware_revision")
|
|
214
|
+
# print("get_firmware_revision")
|
|
215
215
|
info.FirmwareVersion = await self.gForce.get_firmware_revision()
|
|
216
216
|
return info
|
|
217
217
|
|
|
@@ -226,19 +226,19 @@ class SensorProfileDataCtx:
|
|
|
226
226
|
self.notifyDataFlag |= DataSubscription.DNF_IMPEDANCE
|
|
227
227
|
|
|
228
228
|
if self.hasEEG():
|
|
229
|
-
print("initEEG")
|
|
229
|
+
# print("initEEG")
|
|
230
230
|
info.EegChannelCount = await self.initEEG(packageCount)
|
|
231
231
|
|
|
232
232
|
if self.hasECG():
|
|
233
|
-
print("initECG")
|
|
233
|
+
# print("initECG")
|
|
234
234
|
info.EcgChannelCount = await self.initECG(packageCount)
|
|
235
235
|
|
|
236
236
|
if self.hasBrth():
|
|
237
|
-
print("initBrth")
|
|
237
|
+
# print("initBrth")
|
|
238
238
|
info.BrthChannelCount = await self.initBrth(packageCount)
|
|
239
239
|
|
|
240
240
|
if self.hasIMU():
|
|
241
|
-
print("initIMU")
|
|
241
|
+
# print("initIMU")
|
|
242
242
|
imuChannelCount = await self.initIMU(packageCount)
|
|
243
243
|
info.AccChannelCount = imuChannelCount
|
|
244
244
|
info.GyroChannelCount = imuChannelCount
|
|
@@ -786,9 +786,15 @@ class SensorProfileDataCtx:
|
|
|
786
786
|
|
|
787
787
|
return crc8
|
|
788
788
|
|
|
789
|
-
def processUniversalData(
|
|
789
|
+
async def processUniversalData(
|
|
790
|
+
self, buf: Queue[SensorData], event_loop: asyncio.AbstractEventLoop, cmd_loop: asyncio.AbstractEventLoop, sensor, callback
|
|
791
|
+
):
|
|
790
792
|
|
|
791
793
|
while self._is_running:
|
|
794
|
+
while self._is_running and self._rawDataBuffer.empty():
|
|
795
|
+
await asyncio.sleep(0.01)
|
|
796
|
+
continue
|
|
797
|
+
|
|
792
798
|
try:
|
|
793
799
|
while self._is_running and not self._rawDataBuffer.empty():
|
|
794
800
|
data = self._rawDataBuffer.get_nowait()
|
|
@@ -821,21 +827,21 @@ class SensorProfileDataCtx:
|
|
|
821
827
|
if self._is_data_transfering:
|
|
822
828
|
data_package = bytes(self._concatDataBuffer[index + 2 : index + 2 + n])
|
|
823
829
|
self._processDataPackage(data_package, buf, sensor)
|
|
824
|
-
while self._is_running and self.isDataTransfering:
|
|
830
|
+
while self._is_running and self.isDataTransfering and not buf.empty():
|
|
825
831
|
sensorData: SensorData = None
|
|
826
832
|
try:
|
|
827
833
|
sensorData = buf.get_nowait()
|
|
828
834
|
except Exception as e:
|
|
829
835
|
break
|
|
830
|
-
if
|
|
836
|
+
if event_loop != None and sensorData != None and callback != None:
|
|
831
837
|
try:
|
|
832
|
-
|
|
838
|
+
event_loop.call_soon_threadsafe(callback, sensor, sensorData)
|
|
833
839
|
except Exception as e:
|
|
834
840
|
print(e)
|
|
835
841
|
|
|
836
842
|
buf.task_done()
|
|
837
|
-
|
|
838
843
|
last_cut = index = index + 2 + n
|
|
844
|
+
|
|
839
845
|
elif self._concatDataBuffer[index] == 0xAA:
|
|
840
846
|
if (index + 1) >= data_size:
|
|
841
847
|
index += 1
|
|
@@ -850,11 +856,12 @@ class SensorProfileDataCtx:
|
|
|
850
856
|
index += 1
|
|
851
857
|
continue
|
|
852
858
|
data_package = bytes(self._concatDataBuffer[index + 2 : index + 2 + n])
|
|
853
|
-
if
|
|
854
|
-
|
|
859
|
+
if cmd_loop != None:
|
|
860
|
+
cmd_loop.call_soon_threadsafe(self.gForce._on_cmd_response, None, data_package)
|
|
855
861
|
last_cut = index = index + 2 + n
|
|
862
|
+
|
|
856
863
|
else:
|
|
857
864
|
index += 1
|
|
858
865
|
|
|
859
|
-
|
|
860
|
-
|
|
866
|
+
if last_cut > 0:
|
|
867
|
+
self._concatDataBuffer = self._concatDataBuffer[last_cut + 1 :]
|
|
@@ -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:
|
|
@@ -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.0.
|
|
11
|
+
version="0.0.7",
|
|
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
|