syndesi 0.5.0__py3-none-any.whl → 0.5.1__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.
- syndesi/adapters/adapter.py +32 -24
- syndesi/adapters/adapter_worker.py +28 -10
- syndesi/adapters/ip.py +7 -13
- syndesi/adapters/serialport.py +70 -12
- syndesi/adapters/stop_conditions.py +9 -16
- syndesi/adapters/timeout.py +1 -3
- syndesi/adapters/tracehub.py +229 -0
- syndesi/adapters/visa.py +96 -75
- syndesi/cli/shell.py +6 -5
- syndesi/component.py +2 -2
- syndesi/protocols/delimited.py +16 -28
- syndesi/protocols/modbus.py +0 -3
- syndesi/protocols/protocol.py +19 -5
- syndesi/protocols/raw.py +13 -8
- syndesi/scripts/syndesi_trace.py +711 -0
- syndesi/version.py +1 -1
- {syndesi-0.5.0.dist-info → syndesi-0.5.1.dist-info}/METADATA +3 -3
- syndesi-0.5.1.dist-info/RECORD +43 -0
- {syndesi-0.5.0.dist-info → syndesi-0.5.1.dist-info}/WHEEL +1 -1
- {syndesi-0.5.0.dist-info → syndesi-0.5.1.dist-info}/entry_points.txt +1 -1
- syndesi-0.5.0.dist-info/RECORD +0 -41
- {syndesi-0.5.0.dist-info → syndesi-0.5.1.dist-info}/licenses/LICENSE +0 -0
- {syndesi-0.5.0.dist-info → syndesi-0.5.1.dist-info}/top_level.txt +0 -0
syndesi/protocols/protocol.py
CHANGED
|
@@ -12,7 +12,11 @@ from dataclasses import dataclass
|
|
|
12
12
|
from types import EllipsisType
|
|
13
13
|
from typing import Generic, TypeVar
|
|
14
14
|
|
|
15
|
-
from syndesi.adapters.adapter_worker import
|
|
15
|
+
from syndesi.adapters.adapter_worker import (
|
|
16
|
+
AdapterDisconnectedEvent,
|
|
17
|
+
AdapterEvent,
|
|
18
|
+
AdapterFrameEvent,
|
|
19
|
+
)
|
|
16
20
|
from syndesi.adapters.stop_conditions import StopCondition
|
|
17
21
|
from syndesi.component import AdapterFrame, Component, Event, Frame, ReadScope
|
|
18
22
|
|
|
@@ -70,7 +74,6 @@ class Protocol(Component[T], Generic[T]):
|
|
|
70
74
|
event_callback: Callable[[ProtocolEvent], None] | None = None,
|
|
71
75
|
) -> None:
|
|
72
76
|
super().__init__(LoggerAlias.PROTOCOL)
|
|
73
|
-
# TODO : Convert the callable from AdapterSignal to ProtocolSignal or something similar
|
|
74
77
|
self._adapter = auto_adapter(adapter)
|
|
75
78
|
self._event_callback = event_callback
|
|
76
79
|
|
|
@@ -88,9 +91,18 @@ class Protocol(Component[T], Generic[T]):
|
|
|
88
91
|
def _default_timeout(self) -> Timeout | None:
|
|
89
92
|
pass
|
|
90
93
|
|
|
91
|
-
@abstractmethod
|
|
92
94
|
def _on_event(self, event: AdapterEvent) -> None:
|
|
93
|
-
|
|
95
|
+
if self._event_callback is not None:
|
|
96
|
+
output_event: ProtocolEvent | None = None
|
|
97
|
+
if isinstance(event, AdapterDisconnectedEvent):
|
|
98
|
+
output_event = ProtocolDisconnectedEvent()
|
|
99
|
+
if isinstance(event, AdapterFrameEvent):
|
|
100
|
+
output_event = ProtocolFrameEvent(
|
|
101
|
+
frame=self._adapter_to_protocol(event.frame)
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
if output_event is not None:
|
|
105
|
+
self._event_callback(output_event)
|
|
94
106
|
|
|
95
107
|
@abstractmethod
|
|
96
108
|
def _adapter_to_protocol(self, adapter_frame: AdapterFrame) -> ProtocolFrame[T]: ...
|
|
@@ -138,7 +150,9 @@ class Protocol(Component[T], Generic[T]):
|
|
|
138
150
|
stop_conditions: StopCondition | EllipsisType | list[StopCondition] = ...,
|
|
139
151
|
scope: str = ReadScope.BUFFERED.value,
|
|
140
152
|
) -> ProtocolFrame[T]:
|
|
141
|
-
adapter_frame = await self._adapter.aread_detailed(
|
|
153
|
+
adapter_frame = await self._adapter.aread_detailed(
|
|
154
|
+
timeout=timeout, stop_conditions=stop_conditions, scope=scope
|
|
155
|
+
)
|
|
142
156
|
return self._adapter_to_protocol(adapter_frame)
|
|
143
157
|
|
|
144
158
|
def read_detailed(
|
syndesi/protocols/raw.py
CHANGED
|
@@ -10,14 +10,10 @@ from dataclasses import dataclass
|
|
|
10
10
|
from types import EllipsisType
|
|
11
11
|
|
|
12
12
|
from ..adapters.adapter import Adapter
|
|
13
|
-
from ..adapters.adapter_worker import AdapterEvent
|
|
14
13
|
from ..adapters.timeout import Timeout
|
|
15
14
|
from ..component import AdapterFrame
|
|
16
15
|
from .protocol import Protocol, ProtocolEvent, ProtocolFrame
|
|
17
16
|
|
|
18
|
-
# Raw protocols provide the user with the binary data directly,
|
|
19
|
-
# without converting it to string first
|
|
20
|
-
|
|
21
17
|
|
|
22
18
|
@dataclass
|
|
23
19
|
class RawFrame(ProtocolFrame[bytes]):
|
|
@@ -46,7 +42,7 @@ class Raw(Protocol[bytes]):
|
|
|
46
42
|
timeout: Timeout | None | EllipsisType = ...,
|
|
47
43
|
event_callback: Callable[[ProtocolEvent], None] | None = None,
|
|
48
44
|
) -> None:
|
|
49
|
-
super().__init__(adapter, timeout)
|
|
45
|
+
super().__init__(adapter, timeout, event_callback)
|
|
50
46
|
|
|
51
47
|
def _default_timeout(self) -> Timeout | None:
|
|
52
48
|
return Timeout(response=2, action="error")
|
|
@@ -54,9 +50,18 @@ class Raw(Protocol[bytes]):
|
|
|
54
50
|
def __str__(self) -> str:
|
|
55
51
|
return f"Raw({self._adapter})"
|
|
56
52
|
|
|
57
|
-
def _on_event(self, event: AdapterEvent) -> None:
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
# def _on_event(self, event: AdapterEvent) -> None:
|
|
54
|
+
# if self._event_callback is not None:
|
|
55
|
+
# output_event: ProtocolEvent | None = None
|
|
56
|
+
# if isinstance(event, AdapterDisconnectedEvent):
|
|
57
|
+
# output_event = ProtocolDisconnectedEvent()
|
|
58
|
+
# if isinstance(event, AdapterFrameEvent):
|
|
59
|
+
# output_event = ProtocolFrameEvent(
|
|
60
|
+
# frame=self._adapter_to_protocol(event.frame)
|
|
61
|
+
# )
|
|
62
|
+
|
|
63
|
+
# if output_event is not None:
|
|
64
|
+
# self._event_callback(output_event)
|
|
60
65
|
|
|
61
66
|
def _adapter_to_protocol(self, adapter_frame: AdapterFrame) -> RawFrame:
|
|
62
67
|
payload = adapter_frame.get_payload()
|