piezense 0.0.2__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.
- piezense-0.0.2/PKG-INFO +20 -0
- piezense-0.0.2/README.md +6 -0
- piezense-0.0.2/piezense/__init__.py +5 -0
- piezense-0.0.2/piezense/piezense.py +57 -0
- piezense-0.0.2/piezense.egg-info/PKG-INFO +20 -0
- piezense-0.0.2/piezense.egg-info/SOURCES.txt +10 -0
- piezense-0.0.2/piezense.egg-info/dependency_links.txt +1 -0
- piezense-0.0.2/piezense.egg-info/requires.txt +1 -0
- piezense-0.0.2/piezense.egg-info/top_level.txt +1 -0
- piezense-0.0.2/pyproject.toml +3 -0
- piezense-0.0.2/setup.cfg +4 -0
- piezense-0.0.2/setup.py +22 -0
piezense-0.0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: piezense
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: A Python package for interfacing with PieZense pneumatic systems
|
|
5
|
+
Home-page: https://github.com/haptica-robotics/piezense
|
|
6
|
+
Author: Haptica Robotics
|
|
7
|
+
Author-email: info@hapticarobotics.com
|
|
8
|
+
License: LicenseRef-Proprietary
|
|
9
|
+
Platform: UNKNOWN
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# PieZense
|
|
14
|
+
a python library for Haptica Robotics' pneumatic system
|
|
15
|
+
|
|
16
|
+
## Example programs
|
|
17
|
+
https://github.com/haptica-robotics/piezense-examples
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
piezense-0.0.2/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import bleak
|
|
5
|
+
FOLLOWER_COUNT=2
|
|
6
|
+
class PieZense:
|
|
7
|
+
def __init__(self, system_name_list_input):
|
|
8
|
+
self.system_name_list = system_name_list_input
|
|
9
|
+
self.system_client_list=[] # list of BleakClient objects
|
|
10
|
+
self.num_systems = len(self.system_name_list)
|
|
11
|
+
for i, _ in enumerate(self.system_name_list):
|
|
12
|
+
self.system_client_list.append(None)
|
|
13
|
+
|
|
14
|
+
asyncio.run(self.reconnect_to_systems())
|
|
15
|
+
|
|
16
|
+
async def reconnect_to_systems(self):
|
|
17
|
+
while(True):
|
|
18
|
+
for i, system_name in enumerate(self.system_name_list):
|
|
19
|
+
if self.system_client_list[i] is None: # connect
|
|
20
|
+
print(f"Need device: {system_name}")
|
|
21
|
+
device = await bleak.BleakScanner.find_device_by_name(system_name)
|
|
22
|
+
print(f"Scanned for device: {system_name}")
|
|
23
|
+
if device:
|
|
24
|
+
print(f"Found device: {device}")
|
|
25
|
+
self.system_client_list[i] = bleak.BleakClient(device)
|
|
26
|
+
# self.system_client_list[i].set_disconnected_callback(self.generate_disconnect_callback(i, system_name))
|
|
27
|
+
await self.system_client_list[i].connect()
|
|
28
|
+
if self.system_client_list[i].is_connected:
|
|
29
|
+
print(f"Connected to device: {system_name}")
|
|
30
|
+
services=await self.system_client_list[i].services
|
|
31
|
+
print(f"Services: {services}")
|
|
32
|
+
|
|
33
|
+
for service in services:
|
|
34
|
+
for char in service.characteristics:
|
|
35
|
+
if "notify" in char.properties:
|
|
36
|
+
print(f"[{system_name}] Subscribing to {char.uuid}")
|
|
37
|
+
await self.system_client_list[i].start_notify(
|
|
38
|
+
char.uuid,
|
|
39
|
+
lambda sender, data, idx=i: self.notification_handler(idx, sender, data)
|
|
40
|
+
)
|
|
41
|
+
else:
|
|
42
|
+
print(f"Failed to connect to device: {system_name}")
|
|
43
|
+
self.system_client_list[i] = None
|
|
44
|
+
|
|
45
|
+
else:
|
|
46
|
+
print(f"Device not found, will retry: {system_name}")
|
|
47
|
+
await asyncio.sleep(11)
|
|
48
|
+
|
|
49
|
+
def notification_handler(self, device_index, sender, data):
|
|
50
|
+
expected_without_ts = FOLLOWER_COUNT * 2
|
|
51
|
+
pressure_data = data[:expected_without_ts]
|
|
52
|
+
num_followers = len(pressure_data) // 2 # // does integer division
|
|
53
|
+
for follower_id in range(num_followers):
|
|
54
|
+
low_byte = pressure_data[follower_id * 2]
|
|
55
|
+
high_byte = pressure_data[follower_id * 2 + 1]
|
|
56
|
+
pressure_value = (high_byte << 8) | low_byte
|
|
57
|
+
print(f"Device {device_index}, Follower {follower_id}, Pressure: {pressure_value} Pa")
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: piezense
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: A Python package for interfacing with PieZense pneumatic systems
|
|
5
|
+
Home-page: https://github.com/haptica-robotics/piezense
|
|
6
|
+
Author: Haptica Robotics
|
|
7
|
+
Author-email: info@hapticarobotics.com
|
|
8
|
+
License: LicenseRef-Proprietary
|
|
9
|
+
Platform: UNKNOWN
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# PieZense
|
|
14
|
+
a python library for Haptica Robotics' pneumatic system
|
|
15
|
+
|
|
16
|
+
## Example programs
|
|
17
|
+
https://github.com/haptica-robotics/piezense-examples
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bleak==1.1.1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
piezense
|
piezense-0.0.2/setup.cfg
ADDED
piezense-0.0.2/setup.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# !/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import setuptools
|
|
4
|
+
|
|
5
|
+
with open("README.md", "r") as fh:
|
|
6
|
+
description = fh.read()
|
|
7
|
+
|
|
8
|
+
setuptools.setup(
|
|
9
|
+
name="piezense",
|
|
10
|
+
version="0.0.2",
|
|
11
|
+
author="Haptica Robotics",
|
|
12
|
+
author_email="info@hapticarobotics.com",
|
|
13
|
+
packages=["piezense"],
|
|
14
|
+
description="A Python package for interfacing with PieZense pneumatic systems",
|
|
15
|
+
long_description=description,
|
|
16
|
+
long_description_content_type="text/markdown",
|
|
17
|
+
url="https://github.com/haptica-robotics/piezense",
|
|
18
|
+
license='LicenseRef-Proprietary',
|
|
19
|
+
python_requires='>=3.8',
|
|
20
|
+
install_requires=["bleak==1.1.1"]
|
|
21
|
+
)
|
|
22
|
+
|