tinkerforge-async 1.4.2__py3-none-any.whl → 1.5.0__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.
- tinkerforge_async/_version.py +1 -1
- tinkerforge_async/brick_master.py +1 -6
- tinkerforge_async/bricklet_industrial_dual_analog_in_v2.py +10 -8
- tinkerforge_async/bricklet_io4_v2.py +11 -10
- tinkerforge_async/bricklet_isolator.py +307 -0
- tinkerforge_async/device_factory.py +4 -2
- tinkerforge_async/devices.py +11 -0
- tinkerforge_async/ip_connection.py +2 -2
- {tinkerforge_async-1.4.2.dist-info → tinkerforge_async-1.5.0.dist-info}/METADATA +31 -27
- {tinkerforge_async-1.4.2.dist-info → tinkerforge_async-1.5.0.dist-info}/RECORD +13 -12
- {tinkerforge_async-1.4.2.dist-info → tinkerforge_async-1.5.0.dist-info}/WHEEL +1 -1
- {tinkerforge_async-1.4.2.dist-info → tinkerforge_async-1.5.0.dist-info}/LICENSE +0 -0
- {tinkerforge_async-1.4.2.dist-info → tinkerforge_async-1.5.0.dist-info}/top_level.txt +0 -0
tinkerforge_async/_version.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# pylint: disable=missing-module-docstring
|
2
|
-
__version__ = "1.
|
2
|
+
__version__ = "1.5.0"
|
@@ -15,7 +15,7 @@ from typing import TYPE_CHECKING, AsyncGenerator, Iterable, NamedTuple
|
|
15
15
|
|
16
16
|
from .devices import BasicCallbackConfiguration
|
17
17
|
from .devices import BrickletPort as Port
|
18
|
-
from .devices import DeviceIdentifier, DeviceWithMCU, Event, GetSPITFPErrorCount
|
18
|
+
from .devices import DeviceIdentifier, DeviceWithMCU, Event, GetSPITFPBaudrateConfig, GetSPITFPErrorCount
|
19
19
|
from .devices import ThresholdOption as Threshold
|
20
20
|
from .devices import _FunctionID
|
21
21
|
from .ip_connection_helper import pack_payload, unpack_payload
|
@@ -265,11 +265,6 @@ class GetWifi2MeshAPStatus(NamedTuple):
|
|
265
265
|
mac_address: tuple[int, int, int, int, int, int]
|
266
266
|
|
267
267
|
|
268
|
-
class GetSPITFPBaudrateConfig(NamedTuple):
|
269
|
-
enable_dynamic_baudrate: bool
|
270
|
-
minimum_dynamic_baudrate: int
|
271
|
-
|
272
|
-
|
273
268
|
class GetProtocol1BrickletName(NamedTuple):
|
274
269
|
protocol_version: int
|
275
270
|
firmware_version: tuple[int, int, int]
|
@@ -11,7 +11,14 @@ from decimal import Decimal
|
|
11
11
|
from enum import Enum, unique
|
12
12
|
from typing import TYPE_CHECKING, AsyncGenerator, NamedTuple
|
13
13
|
|
14
|
-
from .devices import
|
14
|
+
from .devices import (
|
15
|
+
AdvancedCallbackConfiguration,
|
16
|
+
BrickletWithMCU,
|
17
|
+
DeviceIdentifier,
|
18
|
+
Event,
|
19
|
+
LedConfig,
|
20
|
+
SimpleCallbackConfiguration,
|
21
|
+
)
|
15
22
|
from .devices import ThresholdOption as Threshold
|
16
23
|
from .devices import _FunctionID
|
17
24
|
from .ip_connection_helper import pack_payload, unpack_payload
|
@@ -99,11 +106,6 @@ class GetChannelLEDStatusConfig(NamedTuple):
|
|
99
106
|
config: ChannelLedStatusConfig
|
100
107
|
|
101
108
|
|
102
|
-
class GetAllVoltagesCallbackConfiguration(NamedTuple):
|
103
|
-
period: int
|
104
|
-
value_has_to_change: bool
|
105
|
-
|
106
|
-
|
107
109
|
class BrickletIndustrialDualAnalogInV2(BrickletWithMCU):
|
108
110
|
"""
|
109
111
|
Measures two DC voltages between -35V and +35V with 24bit resolution each
|
@@ -313,7 +315,7 @@ class BrickletIndustrialDualAnalogInV2(BrickletWithMCU):
|
|
313
315
|
response_expected=response_expected,
|
314
316
|
)
|
315
317
|
|
316
|
-
async def get_all_voltages_callback_configuration(self) ->
|
318
|
+
async def get_all_voltages_callback_configuration(self) -> SimpleCallbackConfiguration:
|
317
319
|
"""
|
318
320
|
Returns the callback configuration as set by :func:`Set All Voltages Callback Configuration`.
|
319
321
|
|
@@ -322,7 +324,7 @@ class BrickletIndustrialDualAnalogInV2(BrickletWithMCU):
|
|
322
324
|
_, payload = await self.ipcon.send_request(
|
323
325
|
device=self, function_id=FunctionID.GET_VOLTAGE_CALLBACK_CONFIGURATION, response_expected=True
|
324
326
|
)
|
325
|
-
return
|
327
|
+
return SimpleCallbackConfiguration(*unpack_payload(payload, "I !"))
|
326
328
|
|
327
329
|
async def set_sample_rate(self, rate: _SamplingRate | int, response_expected: bool = True) -> None:
|
328
330
|
"""
|
@@ -10,7 +10,13 @@ from decimal import Decimal
|
|
10
10
|
from enum import Enum, unique
|
11
11
|
from typing import TYPE_CHECKING, AsyncGenerator, NamedTuple
|
12
12
|
|
13
|
-
from .devices import
|
13
|
+
from .devices import (
|
14
|
+
AdvancedCallbackConfiguration,
|
15
|
+
BrickletWithMCU,
|
16
|
+
DeviceIdentifier,
|
17
|
+
Event,
|
18
|
+
SimpleCallbackConfiguration,
|
19
|
+
)
|
14
20
|
from .devices import ThresholdOption as Threshold
|
15
21
|
from .devices import _FunctionID
|
16
22
|
from .ip_connection_helper import pack_payload, unpack_payload
|
@@ -94,11 +100,6 @@ class GetInputValueCallbackConfiguration(NamedTuple):
|
|
94
100
|
value_has_to_change: bool
|
95
101
|
|
96
102
|
|
97
|
-
class GetAllInputValueCallbackConfiguration(NamedTuple):
|
98
|
-
period: int
|
99
|
-
value_has_to_change: bool
|
100
|
-
|
101
|
-
|
102
103
|
class GetMonoflop(NamedTuple):
|
103
104
|
value: bool
|
104
105
|
time: int
|
@@ -329,7 +330,7 @@ class BrickletIO4V2(BrickletWithMCU):
|
|
329
330
|
response_expected=response_expected,
|
330
331
|
)
|
331
332
|
|
332
|
-
async def get_input_value_callback_configuration(self, channel: int) ->
|
333
|
+
async def get_input_value_callback_configuration(self, channel: int) -> SimpleCallbackConfiguration:
|
333
334
|
"""
|
334
335
|
Returns the callback configuration for the given channel as set by
|
335
336
|
:func:`Set Input Value Callback Configuration`.
|
@@ -342,7 +343,7 @@ class BrickletIO4V2(BrickletWithMCU):
|
|
342
343
|
data=pack_payload((int(channel),), "B"),
|
343
344
|
response_expected=True,
|
344
345
|
)
|
345
|
-
return
|
346
|
+
return SimpleCallbackConfiguration(*unpack_payload(payload, "I !"))
|
346
347
|
|
347
348
|
async def set_all_input_value_callback_configuration(
|
348
349
|
self, period: int = 0, value_has_to_change: bool = False, response_expected: bool = True
|
@@ -371,7 +372,7 @@ class BrickletIO4V2(BrickletWithMCU):
|
|
371
372
|
response_expected=response_expected,
|
372
373
|
)
|
373
374
|
|
374
|
-
async def get_all_input_value_callback_configuration(self) ->
|
375
|
+
async def get_all_input_value_callback_configuration(self) -> SimpleCallbackConfiguration:
|
375
376
|
"""
|
376
377
|
Returns the callback configuration as set by
|
377
378
|
:func:`Set All Input Value Callback Configuration`.
|
@@ -379,7 +380,7 @@ class BrickletIO4V2(BrickletWithMCU):
|
|
379
380
|
_, payload = await self.ipcon.send_request(
|
380
381
|
device=self, function_id=FunctionID.GET_ALL_INPUT_VALUE_CALLBACK_CONFIGURATION, response_expected=True
|
381
382
|
)
|
382
|
-
return
|
383
|
+
return SimpleCallbackConfiguration(*unpack_payload(payload, "I !"))
|
383
384
|
|
384
385
|
async def set_monoflop(self, channel: int, value: bool, time: int, response_expected: bool = True) -> None:
|
385
386
|
"""
|
@@ -0,0 +1,307 @@
|
|
1
|
+
"""
|
2
|
+
Module for the Tinkerforge Isolator Bricklet
|
3
|
+
(https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Isolator.html) implemented using Python asyncio. It does
|
4
|
+
the low-level communication with the Tinkerforge ip connection.
|
5
|
+
"""
|
6
|
+
# pylint: disable=duplicate-code # Many sensors of different generations have a similar API
|
7
|
+
from __future__ import annotations
|
8
|
+
|
9
|
+
from enum import Enum, unique
|
10
|
+
from typing import TYPE_CHECKING, AsyncGenerator, NamedTuple
|
11
|
+
|
12
|
+
from .devices import (
|
13
|
+
BrickletWithMCU,
|
14
|
+
DeviceIdentifier,
|
15
|
+
Event,
|
16
|
+
GetSPITFPBaudrateConfig,
|
17
|
+
GetSPITFPErrorCount,
|
18
|
+
SimpleCallbackConfiguration,
|
19
|
+
_FunctionID,
|
20
|
+
)
|
21
|
+
from .ip_connection_helper import base58decode, pack_payload, unpack_payload
|
22
|
+
|
23
|
+
if TYPE_CHECKING:
|
24
|
+
from .ip_connection import IPConnectionAsync
|
25
|
+
|
26
|
+
|
27
|
+
@unique
|
28
|
+
class CallbackID(Enum):
|
29
|
+
"""
|
30
|
+
The callbacks available to this bricklet
|
31
|
+
"""
|
32
|
+
|
33
|
+
STATISTICS = 9
|
34
|
+
|
35
|
+
|
36
|
+
_CallbackID = CallbackID
|
37
|
+
|
38
|
+
|
39
|
+
@unique
|
40
|
+
class FunctionID(_FunctionID):
|
41
|
+
"""
|
42
|
+
The function calls available to this bricklet
|
43
|
+
"""
|
44
|
+
|
45
|
+
GET_STATISTICS = 1
|
46
|
+
SET_SPITFP_BAUDRATE_CONFIG = 2
|
47
|
+
GET_SPITFP_BAUDRATE_CONFIG = 3
|
48
|
+
SET_SPITFP_BAUDRATE = 4
|
49
|
+
GET_SPITFP_BAUDRATE = 5
|
50
|
+
GET_ISOLATOR_SPITFP_ERROR_COUNT = 6
|
51
|
+
SET_STATISTICS_CALLBACK_CONFIGURATION = 7
|
52
|
+
GET_STATISTICS_CALLBACK_CONFIGURATION = 8
|
53
|
+
|
54
|
+
|
55
|
+
class GetStatistics(NamedTuple):
|
56
|
+
messages_from_brick: int
|
57
|
+
messages_from_bricklet: int
|
58
|
+
connected_bricklet_device_identifier: int
|
59
|
+
connected_bricklet_uid: int
|
60
|
+
|
61
|
+
|
62
|
+
class BrickletIsolator(BrickletWithMCU):
|
63
|
+
"""
|
64
|
+
Galvanically isolates the power and data lines of a Bricklet and its Master Brick.
|
65
|
+
"""
|
66
|
+
|
67
|
+
DEVICE_IDENTIFIER = DeviceIdentifier.BRICKLET_ISOLATOR
|
68
|
+
DEVICE_DISPLAY_NAME = "Isolator Bricklet"
|
69
|
+
|
70
|
+
# Convenience imports, so that the user does not need to additionally import them
|
71
|
+
CallbackID = CallbackID
|
72
|
+
FunctionID = FunctionID
|
73
|
+
|
74
|
+
CALLBACK_FORMATS = {
|
75
|
+
CallbackID.STATISTICS: "I I H 8s",
|
76
|
+
}
|
77
|
+
|
78
|
+
SID_TO_CALLBACK = {
|
79
|
+
0: (CallbackID.STATISTICS,),
|
80
|
+
}
|
81
|
+
|
82
|
+
def __init__(self, uid, ipcon: IPConnectionAsync) -> None:
|
83
|
+
"""
|
84
|
+
Creates an object with the unique device ID *uid* and adds it to
|
85
|
+
the IP Connection *ipcon*.
|
86
|
+
"""
|
87
|
+
super().__init__(self.DEVICE_DISPLAY_NAME, uid, ipcon)
|
88
|
+
|
89
|
+
self.api_version = (2, 0, 1)
|
90
|
+
|
91
|
+
async def get_value(self, sid: int) -> GetStatistics:
|
92
|
+
assert sid == 0
|
93
|
+
|
94
|
+
return await self.get_statistics()
|
95
|
+
|
96
|
+
async def set_callback_configuration( # pylint: disable=too-many-arguments
|
97
|
+
self,
|
98
|
+
sid: int,
|
99
|
+
period: int = 0,
|
100
|
+
value_has_to_change: bool = False,
|
101
|
+
response_expected: bool = True,
|
102
|
+
) -> None:
|
103
|
+
assert sid == 0
|
104
|
+
|
105
|
+
await self.set_statistics_callback_configuration(period, value_has_to_change, response_expected)
|
106
|
+
|
107
|
+
async def get_callback_configuration(self, sid: int) -> SimpleCallbackConfiguration:
|
108
|
+
assert sid == 0
|
109
|
+
|
110
|
+
return await self.get_statistics_callback_configuration()
|
111
|
+
|
112
|
+
async def get_statistics(self) -> GetStatistics:
|
113
|
+
"""
|
114
|
+
Returns statistics for the Isolator Bricklet.
|
115
|
+
"""
|
116
|
+
_, payload = await self.ipcon.send_request(
|
117
|
+
device=self, function_id=FunctionID.GET_STATISTICS, response_expected=True
|
118
|
+
)
|
119
|
+
(
|
120
|
+
messages_from_brick,
|
121
|
+
messages_from_bricklet,
|
122
|
+
connected_bricklet_device_identifier,
|
123
|
+
connected_bricklet_uid,
|
124
|
+
) = unpack_payload(payload, "I I H 8s")
|
125
|
+
|
126
|
+
return GetStatistics(
|
127
|
+
messages_from_brick,
|
128
|
+
messages_from_bricklet,
|
129
|
+
connected_bricklet_device_identifier,
|
130
|
+
base58decode(connected_bricklet_uid),
|
131
|
+
)
|
132
|
+
|
133
|
+
async def set_spitfp_baudrate_config(
|
134
|
+
self,
|
135
|
+
enable_dynamic_baudrate: bool = True,
|
136
|
+
minimum_dynamic_baudrate: int = 400000,
|
137
|
+
response_expected: bool = True,
|
138
|
+
) -> None:
|
139
|
+
"""
|
140
|
+
The SPITF protocol can be used with a dynamic baudrate. If the dynamic baudrate is
|
141
|
+
enabled, the Isolator Bricklet will try to adapt the baudrate for the communication
|
142
|
+
between Bricks and Bricklets according to the amount of data that is transferred.
|
143
|
+
|
144
|
+
The baudrate for communication config between
|
145
|
+
Brick and Isolator Bricklet can be set through the API of the Brick.
|
146
|
+
|
147
|
+
The baudrate will be increased exponentially if lots of data is sent/received and
|
148
|
+
decreased linearly if little data is sent/received.
|
149
|
+
|
150
|
+
This lowers the baudrate in applications where little data is transferred (e.g.
|
151
|
+
a weather station) and increases the robustness. If there is lots of data to transfer
|
152
|
+
(e.g. Thermal Imaging Bricklet) it automatically increases the baudrate as needed.
|
153
|
+
|
154
|
+
In cases where some data has to transferred as fast as possible every few seconds
|
155
|
+
(e.g. RS485 Bricklet with a high baudrate but small payload) you may want to turn
|
156
|
+
the dynamic baudrate off to get the highest possible performance.
|
157
|
+
|
158
|
+
The maximum value of the baudrate can be set per port with the function
|
159
|
+
:func:`Set SPITFP Baudrate`. If the dynamic baudrate is disabled, the baudrate
|
160
|
+
as set by :func:`Set SPITFP Baudrate` will be used statically.
|
161
|
+
"""
|
162
|
+
await self.ipcon.send_request(
|
163
|
+
device=self,
|
164
|
+
function_id=FunctionID.SET_SPITFP_BAUDRATE_CONFIG,
|
165
|
+
data=pack_payload((bool(enable_dynamic_baudrate), int(minimum_dynamic_baudrate)), "! I"),
|
166
|
+
response_expected=response_expected,
|
167
|
+
)
|
168
|
+
|
169
|
+
async def get_spitfp_baudrate_config(self) -> GetSPITFPBaudrateConfig:
|
170
|
+
"""
|
171
|
+
Returns the baudrate config, see :func:`Set SPITFP Baudrate Config`.
|
172
|
+
"""
|
173
|
+
_, payload = await self.ipcon.send_request(
|
174
|
+
device=self, function_id=FunctionID.GET_SPITFP_BAUDRATE_CONFIG, response_expected=True
|
175
|
+
)
|
176
|
+
return GetSPITFPBaudrateConfig(*unpack_payload(payload, "! I"))
|
177
|
+
|
178
|
+
async def set_spitfp_baudrate(self, baudrate: int = 1400000, response_expected: bool = True) -> None:
|
179
|
+
"""
|
180
|
+
Sets the baudrate for the communication between Isolator Bricklet
|
181
|
+
and the connected Bricklet. The baudrate for communication between
|
182
|
+
Brick and Isolator Bricklet can be set through the API of the Brick.
|
183
|
+
|
184
|
+
If you want to increase the throughput of Bricklets you can increase
|
185
|
+
the baudrate. If you get a high error count because of high
|
186
|
+
interference (see :func:`Get SPITFP Error Count`) you can decrease the
|
187
|
+
baudrate.
|
188
|
+
|
189
|
+
If the dynamic baudrate feature is enabled, the baudrate set by this
|
190
|
+
function corresponds to the maximum baudrate (see :func:`Set SPITFP Baudrate Config`).
|
191
|
+
|
192
|
+
Regulatory testing is done with the default baudrate. If CE compatibility
|
193
|
+
or similar is necessary in your applications we recommend to not change
|
194
|
+
the baudrate.
|
195
|
+
"""
|
196
|
+
await self.ipcon.send_request(
|
197
|
+
device=self,
|
198
|
+
function_id=FunctionID.SET_SPITFP_BAUDRATE,
|
199
|
+
data=pack_payload((int(baudrate),), "I"),
|
200
|
+
response_expected=response_expected,
|
201
|
+
)
|
202
|
+
|
203
|
+
async def get_spitfp_baudrate(self) -> int:
|
204
|
+
"""
|
205
|
+
Returns the baudrate, see :func:`Set SPITFP Baudrate`.
|
206
|
+
"""
|
207
|
+
_, payload = await self.ipcon.send_request(
|
208
|
+
device=self,
|
209
|
+
function_id=FunctionID.GET_SPITFP_BAUDRATE,
|
210
|
+
data=pack_payload((), ""),
|
211
|
+
response_expected=True,
|
212
|
+
)
|
213
|
+
return unpack_payload(payload, "I")
|
214
|
+
|
215
|
+
async def get_isolator_spitfp_error_count(self) -> GetSPITFPErrorCount:
|
216
|
+
"""
|
217
|
+
Returns the error count for the communication between Isolator Bricklet and
|
218
|
+
the connected Bricklet. Call :func:`Get SPITFP Error Count` to get the
|
219
|
+
error count between Isolator Bricklet and Brick.
|
220
|
+
|
221
|
+
The errors are divided into
|
222
|
+
|
223
|
+
* ACK checksum errors,
|
224
|
+
* message checksum errors,
|
225
|
+
* framing errors and
|
226
|
+
* overflow errors.
|
227
|
+
"""
|
228
|
+
_, payload = await self.ipcon.send_request(
|
229
|
+
device=self,
|
230
|
+
function_id=FunctionID.GET_ISOLATOR_SPITFP_ERROR_COUNT,
|
231
|
+
data=pack_payload((), ""),
|
232
|
+
response_expected=True,
|
233
|
+
)
|
234
|
+
return GetSPITFPErrorCount(*unpack_payload(payload, "I I I I"))
|
235
|
+
|
236
|
+
async def set_statistics_callback_configuration( # pylint: disable=too-many-arguments
|
237
|
+
self,
|
238
|
+
period: int = 0,
|
239
|
+
value_has_to_change: bool = False,
|
240
|
+
response_expected=True,
|
241
|
+
) -> None:
|
242
|
+
"""
|
243
|
+
The period is the period with which the :cb:`Statistics`
|
244
|
+
callback is triggered periodically. A value of 0 turns the callback off.
|
245
|
+
|
246
|
+
If the `value has to change`-parameter is set to true, the callback is only
|
247
|
+
triggered after the value has changed. If the value didn't change within the
|
248
|
+
period, the callback is triggered immediately on change.
|
249
|
+
|
250
|
+
If it is set to false, the callback is continuously triggered with the period,
|
251
|
+
independent of the value.
|
252
|
+
|
253
|
+
.. versionadded:: 2.0.2$nbsp;(Plugin)
|
254
|
+
"""
|
255
|
+
assert period >= 0
|
256
|
+
|
257
|
+
await self.ipcon.send_request(
|
258
|
+
device=self,
|
259
|
+
function_id=FunctionID.SET_STATISTICS_CALLBACK_CONFIGURATION,
|
260
|
+
data=pack_payload(
|
261
|
+
(
|
262
|
+
int(period),
|
263
|
+
bool(value_has_to_change),
|
264
|
+
),
|
265
|
+
"I !",
|
266
|
+
),
|
267
|
+
response_expected=response_expected,
|
268
|
+
)
|
269
|
+
|
270
|
+
async def get_statistics_callback_configuration(self) -> SimpleCallbackConfiguration:
|
271
|
+
"""
|
272
|
+
Returns the callback configuration as set by
|
273
|
+
:func:`Set Statistics Callback Configuration`.
|
274
|
+
|
275
|
+
.. versionadded:: 2.0.2$nbsp;(Plugin)
|
276
|
+
"""
|
277
|
+
_, payload = await self.ipcon.send_request(
|
278
|
+
device=self, function_id=FunctionID.GET_STATISTICS_CALLBACK_CONFIGURATION, response_expected=True
|
279
|
+
)
|
280
|
+
return SimpleCallbackConfiguration(*unpack_payload(payload, "I !"))
|
281
|
+
|
282
|
+
async def read_events(
|
283
|
+
self,
|
284
|
+
events: tuple[int | _CallbackID, ...] | list[int | _CallbackID] | None = None,
|
285
|
+
sids: tuple[int, ...] | list[int] | None = None,
|
286
|
+
) -> AsyncGenerator[Event, None]:
|
287
|
+
registered_events = set()
|
288
|
+
if events:
|
289
|
+
for event in events:
|
290
|
+
registered_events.add(self.CallbackID(event))
|
291
|
+
if sids is not None:
|
292
|
+
for sid in sids:
|
293
|
+
for callback in self.SID_TO_CALLBACK.get(sid, []):
|
294
|
+
registered_events.add(callback)
|
295
|
+
|
296
|
+
if events is None and sids is None:
|
297
|
+
registered_events = set(self.CALLBACK_FORMATS.keys())
|
298
|
+
|
299
|
+
async for header, payload in super()._read_events():
|
300
|
+
try:
|
301
|
+
function_id = CallbackID(header.function_id)
|
302
|
+
except ValueError:
|
303
|
+
# Invalid header. Drop the packet.
|
304
|
+
continue
|
305
|
+
if function_id in registered_events:
|
306
|
+
values = unpack_payload(payload, self.CALLBACK_FORMATS[function_id])
|
307
|
+
yield Event(self, 0, function_id, GetStatistics(*values))
|
@@ -18,6 +18,7 @@ from .bricklet_industrial_dual_analog_in_v2 import BrickletIndustrialDualAnalogI
|
|
18
18
|
from .bricklet_industrial_ptc import BrickletIndustrialPtc
|
19
19
|
from .bricklet_io4_v2 import BrickletIO4V2
|
20
20
|
from .bricklet_io16 import BrickletIO16
|
21
|
+
from .bricklet_isolator import BrickletIsolator
|
21
22
|
from .bricklet_moisture import BrickletMoisture
|
22
23
|
from .bricklet_motion_detector_v2 import BrickletMotionDetectorV2
|
23
24
|
from .bricklet_ptc import BrickletPtc
|
@@ -55,7 +56,7 @@ class DeviceFactory:
|
|
55
56
|
try:
|
56
57
|
return self.__available_devices[device_id](uid, ipcon)
|
57
58
|
except KeyError:
|
58
|
-
raise ValueError(f"No device available for id {device_id}") from None
|
59
|
+
raise ValueError(f"No device available for id {device_id!s}") from None
|
59
60
|
|
60
61
|
|
61
62
|
device_factory = DeviceFactory()
|
@@ -70,8 +71,9 @@ device_factory.register(BrickletHumidity)
|
|
70
71
|
device_factory.register(BrickletHumidityV2)
|
71
72
|
device_factory.register(BrickletIndustrialDualAnalogInV2)
|
72
73
|
device_factory.register(BrickletIndustrialPtc)
|
73
|
-
device_factory.register(BrickletIO16)
|
74
74
|
device_factory.register(BrickletIO4V2)
|
75
|
+
device_factory.register(BrickletIO16)
|
76
|
+
device_factory.register(BrickletIsolator)
|
75
77
|
device_factory.register(BrickletMoisture)
|
76
78
|
device_factory.register(BrickletMotionDetectorV2)
|
77
79
|
device_factory.register(BrickletPtc)
|
tinkerforge_async/devices.py
CHANGED
@@ -60,6 +60,7 @@ class DeviceIdentifier(Enum):
|
|
60
60
|
BRICKLET_TEMPERATURE_V2 = 2113
|
61
61
|
BRICKLET_BAROMETER_V2 = 2117
|
62
62
|
BRICKLET_INDUSTRIAL_DUAL_ANALOG_IN_V2 = 2121
|
63
|
+
BRICKLET_ISOLATOR = 2122
|
63
64
|
BRICKLET_AMBIENT_LIGHT_V3 = 2131
|
64
65
|
BRICKLET_SEGMENT_DISPLAY_4x7_V2 = 2137 # pylint: disable=invalid-name
|
65
66
|
BRICKLET_INDUSTRIAL_PTC = 2164
|
@@ -483,9 +484,19 @@ class BasicCallbackConfiguration(NamedTuple):
|
|
483
484
|
maximum: Decimal
|
484
485
|
|
485
486
|
|
487
|
+
class SimpleCallbackConfiguration(NamedTuple):
|
488
|
+
period: int
|
489
|
+
value_has_to_change: bool
|
490
|
+
|
491
|
+
|
486
492
|
class AdvancedCallbackConfiguration(NamedTuple):
|
487
493
|
period: int
|
488
494
|
value_has_to_change: bool
|
489
495
|
option: ThresholdOption | None
|
490
496
|
minimum: Decimal | None
|
491
497
|
maximum: Decimal | None
|
498
|
+
|
499
|
+
|
500
|
+
class GetSPITFPBaudrateConfig(NamedTuple):
|
501
|
+
enable_dynamic_baudrate: bool
|
502
|
+
minimum_dynamic_baudrate: int
|
@@ -311,14 +311,14 @@ class IPConnectionAsync: # pylint: disable=too-many-instance-attributes
|
|
311
311
|
async for data in self.__event_bus.register(f"/events/{uid}"):
|
312
312
|
yield data
|
313
313
|
|
314
|
-
async def read_enumeration(self, uid: int = None) -> AsyncGenerator[tuple[EnumerationType, Device], None]:
|
314
|
+
async def read_enumeration(self, uid: int | None = None) -> AsyncGenerator[tuple[EnumerationType, Device], None]:
|
315
315
|
data: EnumerationPayload
|
316
316
|
async for data in self.__event_bus.register("/enumerations"):
|
317
317
|
if uid is None or uid == data.uid:
|
318
318
|
try:
|
319
319
|
yield data.enumeration_type, device_factory.get(self, data.device_id, data.uid) # type: ignore
|
320
320
|
except ValueError:
|
321
|
-
self.__logger.warning("No driver for device id '%
|
321
|
+
self.__logger.warning("No driver for device id '%s' found.", data.device_id)
|
322
322
|
|
323
323
|
async def enumerate(self) -> None:
|
324
324
|
"""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
|
-
Name:
|
3
|
-
Version: 1.
|
2
|
+
Name: tinkerforge_async
|
3
|
+
Version: 1.5.0
|
4
4
|
Summary: Python3 AsyncIO Tinkerforge driver
|
5
5
|
Author-email: Patrick Baus <patrick.baus@physik.tu-darmstadt.de>
|
6
6
|
License: GNU General Public License v3 (GPLv3)
|
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.7
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.8
|
14
14
|
Classifier: Programming Language :: Python :: 3.9
|
15
15
|
Classifier: Programming Language :: Python :: 3.10
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
16
17
|
Classifier: Development Status :: 5 - Production/Stable
|
17
18
|
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
18
19
|
Classifier: Operating System :: OS Independent
|
@@ -32,6 +33,7 @@ Requires-Dist: isort ; extra == 'dev'
|
|
32
33
|
Requires-Dist: mypy ; extra == 'dev'
|
33
34
|
Requires-Dist: pre-commit ; extra == 'dev'
|
34
35
|
Requires-Dist: pylint ; extra == 'dev'
|
36
|
+
Requires-Dist: setuptools ; extra == 'dev'
|
35
37
|
Requires-Dist: twine ; extra == 'dev'
|
36
38
|
Provides-Extra: doc
|
37
39
|
Requires-Dist: myst-parser ; extra == 'doc'
|
@@ -41,10 +43,11 @@ Requires-Dist: mypy ; extra == 'test'
|
|
41
43
|
Requires-Dist: pylint ; extra == 'test'
|
42
44
|
Requires-Dist: pytest ; extra == 'test'
|
43
45
|
|
44
|
-
[](../../actions/workflows/pylint.yml)
|
45
47
|
[](https://pypi.org/project/tinkerforge-async/)
|
46
48
|

|
47
49
|

|
50
|
+
[](LICENSE)
|
48
51
|
[](https://github.com/psf/black)
|
49
52
|
# TinkerforgeAsync
|
50
53
|
This is a reimplementation of the Tinkerforge Python bindings ([original Python bindings](https://www.tinkerforge.com/en/doc/Software/API_Bindings_Python.html)) using Python 3 asyncio. The original bindings used threads to manage the blocking operations. A much cleaner implementation is possible using the `await` syntax from asyncio.
|
@@ -58,28 +61,29 @@ The library is fully type-hinted.
|
|
58
61
|
|--|--|--|--|
|
59
62
|
|[Master](https://www.tinkerforge.com/en/doc/Hardware/Bricks/Master_Brick.html)|:heavy_check_mark:|:heavy_check_mark:| |
|
60
63
|
|
61
|
-
|Bricklet|Supported|Tested|
|
62
|
-
|
63
|
-
|[Ambient Light 2.0](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Ambient_Light_V2.html)|:heavy_check_mark:|:heavy_check_mark:|
|
64
|
-
|[Ambient Light 3.0](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Ambient_Light_V3.html)|:heavy_check_mark:|:heavy_check_mark:|
|
65
|
-
|[Analog In](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Analog_In.html)|:heavy_check_mark:|:heavy_check_mark:|
|
66
|
-
|[Barometer](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Barometer.html)|:heavy_check_mark:|:heavy_check_mark:|
|
67
|
-
|[Barometer 2.0](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Barometer_V2.html)|:heavy_check_mark:|:heavy_check_mark:|
|
68
|
-
|[Humidity](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Humidity.html)|:heavy_check_mark:|:heavy_check_mark:|
|
69
|
-
|[Humidity 2.0](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Humidity_V2.html)|:heavy_check_mark:|:heavy_check_mark:|
|
70
|
-
|[Industrial Dual Analog In
|
71
|
-
|[Industrial PTC](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Industrial_PTC.html)|:heavy_check_mark:|:heavy_check_mark:|
|
72
|
-
|[IO-4 2.0](https://www.tinkerforge.com/de/doc/Hardware/Bricklets/IO4_V2.html)|:heavy_check_mark:|:heavy_check_mark:|
|
73
|
-
|[IO-16](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/IO16.html)|:heavy_check_mark:|:heavy_check_mark:|
|
74
|
-
|[
|
75
|
-
|[
|
76
|
-
|[
|
77
|
-
|[PTC
|
78
|
-
|[
|
79
|
-
|[
|
80
|
-
|[Segment Display 4x7
|
81
|
-
|[
|
82
|
-
|[Temperature
|
64
|
+
| Bricklet |Supported|Tested|
|
65
|
+
|--------------------------------------------------------------------------------------------------------------------------|--|--|
|
66
|
+
| [Ambient Light 2.0](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Ambient_Light_V2.html) |:heavy_check_mark:|:heavy_check_mark:|
|
67
|
+
| [Ambient Light 3.0](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Ambient_Light_V3.html) |:heavy_check_mark:|:heavy_check_mark:|
|
68
|
+
| [Analog In](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Analog_In.html) |:heavy_check_mark:|:heavy_check_mark:|
|
69
|
+
| [Barometer](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Barometer.html) |:heavy_check_mark:|:heavy_check_mark:|
|
70
|
+
| [Barometer 2.0](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Barometer_V2.html) |:heavy_check_mark:|:heavy_check_mark:|
|
71
|
+
| [Humidity](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Humidity.html) |:heavy_check_mark:|:heavy_check_mark:|
|
72
|
+
| [Humidity 2.0](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Humidity_V2.html) |:heavy_check_mark:|:heavy_check_mark:|
|
73
|
+
| [Industrial Dual Analog In 2.0](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Industrial_Dual_Analog_In_V2.html) |:heavy_check_mark:|:heavy_check_mark:|
|
74
|
+
| [Industrial PTC](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Industrial_PTC.html) |:heavy_check_mark:|:heavy_check_mark:|
|
75
|
+
| [IO-4 2.0](https://www.tinkerforge.com/de/doc/Hardware/Bricklets/IO4_V2.html) |:heavy_check_mark:|:heavy_check_mark:|
|
76
|
+
| [IO-16](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/IO16.html) |:heavy_check_mark:|:heavy_check_mark:|
|
77
|
+
| [Isolator](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Isolator.html) |:heavy_check_mark:|:heavy_check_mark:|
|
78
|
+
| [Moisture](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Moisture.html) |:heavy_check_mark:|:heavy_check_mark:|
|
79
|
+
| [Motion Detector 2.0](https://www.tinkerforge.com/de/doc/Hardware/Bricklets/Motion_Detector_V2.html) |:heavy_check_mark:|:heavy_check_mark:|
|
80
|
+
| [PTC](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/PTC.html) |:heavy_check_mark:|:heavy_check_mark:|
|
81
|
+
| [PTC 2.0](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/PTC_V2.html) |:heavy_check_mark:|:heavy_check_mark:|
|
82
|
+
| [RS232 2.0](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/RS232_V2.html) |:heavy_check_mark:|:heavy_check_mark:|
|
83
|
+
| [Segment Display 4x7](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Segment_Display_4x7.html) |:heavy_check_mark:|:heavy_check_mark:|
|
84
|
+
| [Segment Display 4x7 2.0](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Segment_Display_4x7_V2.html) |:heavy_check_mark:|:heavy_check_mark:|
|
85
|
+
| [Temperature](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Temperature.html) |:heavy_check_mark:|:heavy_check_mark:|
|
86
|
+
| [Temperature 2.0](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Temperature_V2.html) |:heavy_check_mark:|:heavy_check_mark:|
|
83
87
|
|
84
88
|
## Documentation
|
85
89
|
The documentation is currently work in progress. The full documentation will be moved to
|
@@ -212,11 +216,11 @@ python3 setup.py install
|
|
212
216
|
|
213
217
|
## Versioning
|
214
218
|
I use [SemVer](http://semver.org/) for versioning. For the versions available, see the
|
215
|
-
[tags on this repository](
|
219
|
+
[tags on this repository](../../tags).
|
216
220
|
|
217
221
|
## Authors
|
218
222
|
* **Patrick Baus** - *Initial work* - [PatrickBaus](https://github.com/PatrickBaus)
|
219
223
|
|
220
224
|
## License
|
221
225
|
This project is licensed under the GPL v3 license - see the
|
222
|
-
[LICENSE](
|
226
|
+
[LICENSE](LICENSE) file for details
|
@@ -1,7 +1,7 @@
|
|
1
1
|
tinkerforge_async/__init__.py,sha256=wv8UTQrY0vlHwJEO-50PAeUt1cnrAdtSW-2by3CtaaE,376
|
2
|
-
tinkerforge_async/_version.py,sha256=
|
2
|
+
tinkerforge_async/_version.py,sha256=8tv365RSIevo4FRLjkkw8YGADkX0majxQJmFFD8Qffw,65
|
3
3
|
tinkerforge_async/async_event_bus.py,sha256=Ng1bNw4tfPZUSMBudy47rTxLqJF96qpTEJIzh1MCq44,1806
|
4
|
-
tinkerforge_async/brick_master.py,sha256=
|
4
|
+
tinkerforge_async/brick_master.py,sha256=kZDN_FzuYmGjaZvYFI2ba2Sfv1mwGoFx9ZayH1DJGqI,129607
|
5
5
|
tinkerforge_async/bricklet_ambient_light_v2.py,sha256=6OVxGK8kBU_ZcRXa9iJH_B8GbZ74XGBB5ix7WquS8yw,13402
|
6
6
|
tinkerforge_async/bricklet_ambient_light_v3.py,sha256=oJ9K9HEI5fX0Tz9YDkfjyiGLsVuguOT5ukhnLsULnto,12171
|
7
7
|
tinkerforge_async/bricklet_analog_in.py,sha256=RwHj6VVg95OBbBt3xKTdxU_mCLI6ByUztPfTTyLPggs,17154
|
@@ -9,10 +9,11 @@ tinkerforge_async/bricklet_barometer.py,sha256=tSlI4LuuQ_X0-RIqJdeke1XCryzJ7UAGh
|
|
9
9
|
tinkerforge_async/bricklet_barometer_v2.py,sha256=dO7SP67iASTZZ8pDSBprQTevpMDC8IFHY_MoL6-hfKk,26567
|
10
10
|
tinkerforge_async/bricklet_humidity.py,sha256=_PVk3zUYr4o4o7Eyw2L7dLTS0alR9zrmXNMH2fPe6cE,14948
|
11
11
|
tinkerforge_async/bricklet_humidity_v2.py,sha256=6JwWin22Kr_qtZ9-o7ioGpfk5LQcybHzq1LIahGpOb0,19611
|
12
|
-
tinkerforge_async/bricklet_industrial_dual_analog_in_v2.py,sha256=
|
12
|
+
tinkerforge_async/bricklet_industrial_dual_analog_in_v2.py,sha256=nmkcYArdBXDO7Q6epGAMgGixlrT5kZIrMzlxddeAWGY,20291
|
13
13
|
tinkerforge_async/bricklet_industrial_ptc.py,sha256=psGwgSArRgU-LgagUQVC8DIznHb1kmXSUNUG-1dfevI,608
|
14
14
|
tinkerforge_async/bricklet_io16.py,sha256=bIraXe_vkJrmSlTV9wbSKDRUY4K1fGc8kCaR0PWaKj0,20875
|
15
|
-
tinkerforge_async/bricklet_io4_v2.py,sha256=
|
15
|
+
tinkerforge_async/bricklet_io4_v2.py,sha256=GYb2N44jVV_hvijJ_YPx2Vf0Td-oJzGNT53gI1mNv2U,21506
|
16
|
+
tinkerforge_async/bricklet_isolator.py,sha256=miTYcDMzY6gQ8lNU8ZS6vcPs0HDr8JrJ0y1J7nKsJHs,11159
|
16
17
|
tinkerforge_async/bricklet_moisture.py,sha256=ICnnwPAcWmFcOL73OGWYlLlnAxsr_g7RUe6eZUNDR5I,10078
|
17
18
|
tinkerforge_async/bricklet_motion_detector_v2.py,sha256=nCbYQd4staw62_mYcUVF1qBhzG_04y0jbzXGOyLXcWQ,6451
|
18
19
|
tinkerforge_async/bricklet_ptc.py,sha256=QU4AwystKH4m0lrOLLHTIWHfUhF0s9HDVEI7me3EGyA,21722
|
@@ -22,12 +23,12 @@ tinkerforge_async/bricklet_segment_display_4x7.py,sha256=kl_ctg86w2-uPhEgiraSbtI
|
|
22
23
|
tinkerforge_async/bricklet_segment_display_4x7_v2.py,sha256=T5g-voFLtLAOyWKn_TNuKDJVaG5vi_7eVCNvkE5ziIs,8902
|
23
24
|
tinkerforge_async/bricklet_temperature.py,sha256=wsaI5vq50d7X_FonRZfxpjtNOVM8tdqA74MPVrts8h4,11341
|
24
25
|
tinkerforge_async/bricklet_temperature_v2.py,sha256=uYSnfW1Hr1WxY5M7kVahtpaQEK5XvdIhM_HhdJdSc-g,9702
|
25
|
-
tinkerforge_async/device_factory.py,sha256=
|
26
|
-
tinkerforge_async/devices.py,sha256=
|
27
|
-
tinkerforge_async/ip_connection.py,sha256=
|
26
|
+
tinkerforge_async/device_factory.py,sha256=tkJFlzR87hrUjItGqzKiA5x5m9qsBeD6E7bS5QeNIVs,3260
|
27
|
+
tinkerforge_async/devices.py,sha256=qPltGqMM4-zv0AfxytoG4N2jriC9NmYKQwg7kOtl8OY,15598
|
28
|
+
tinkerforge_async/ip_connection.py,sha256=KPAFGTysuCj8uVWMgVUDvP_zPOpjeYOKVb16SDLRcjE,27671
|
28
29
|
tinkerforge_async/ip_connection_helper.py,sha256=kt4JhONMxJdN4upIpVZlqTKmQcSyG2zXkmnCC2QL91Y,4305
|
29
|
-
tinkerforge_async-1.
|
30
|
-
tinkerforge_async-1.
|
31
|
-
tinkerforge_async-1.
|
32
|
-
tinkerforge_async-1.
|
33
|
-
tinkerforge_async-1.
|
30
|
+
tinkerforge_async-1.5.0.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
31
|
+
tinkerforge_async-1.5.0.dist-info/METADATA,sha256=foukM9LXZmljOpWsdG4JBLiDDfNasRrooHVoHPovho4,16033
|
32
|
+
tinkerforge_async-1.5.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
33
|
+
tinkerforge_async-1.5.0.dist-info/top_level.txt,sha256=YuYlWDVtbFvjqm-GoyH2asasmmn-lH1KeKBBtA17QJ4,18
|
34
|
+
tinkerforge_async-1.5.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|