python-jebao 0.1.5__tar.gz → 0.1.6__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.
- {python_jebao-0.1.5 → python_jebao-0.1.6}/PKG-INFO +1 -1
- {python_jebao-0.1.5 → python_jebao-0.1.6}/jebao/__init__.py +1 -1
- {python_jebao-0.1.5 → python_jebao-0.1.6}/jebao/protocol.py +24 -18
- {python_jebao-0.1.5 → python_jebao-0.1.6}/pyproject.toml +1 -1
- {python_jebao-0.1.5 → python_jebao-0.1.6}/python_jebao.egg-info/PKG-INFO +1 -1
- {python_jebao-0.1.5 → python_jebao-0.1.6}/LICENSE +0 -0
- {python_jebao-0.1.5 → python_jebao-0.1.6}/README.md +0 -0
- {python_jebao-0.1.5 → python_jebao-0.1.6}/jebao/const.py +0 -0
- {python_jebao-0.1.5 → python_jebao-0.1.6}/jebao/device.py +0 -0
- {python_jebao-0.1.5 → python_jebao-0.1.6}/jebao/discovery.py +0 -0
- {python_jebao-0.1.5 → python_jebao-0.1.6}/jebao/exceptions.py +0 -0
- {python_jebao-0.1.5 → python_jebao-0.1.6}/jebao/mdp20000.py +0 -0
- {python_jebao-0.1.5 → python_jebao-0.1.6}/jebao/retry.py +0 -0
- {python_jebao-0.1.5 → python_jebao-0.1.6}/python_jebao.egg-info/SOURCES.txt +0 -0
- {python_jebao-0.1.5 → python_jebao-0.1.6}/python_jebao.egg-info/dependency_links.txt +0 -0
- {python_jebao-0.1.5 → python_jebao-0.1.6}/python_jebao.egg-info/requires.txt +0 -0
- {python_jebao-0.1.5 → python_jebao-0.1.6}/python_jebao.egg-info/top_level.txt +0 -0
- {python_jebao-0.1.5 → python_jebao-0.1.6}/setup.cfg +0 -0
- {python_jebao-0.1.5 → python_jebao-0.1.6}/setup.py +0 -0
|
@@ -530,14 +530,19 @@ class JebaoProtocol:
|
|
|
530
530
|
return bytes(buffer)
|
|
531
531
|
|
|
532
532
|
async def _drain_garbage_bytes(self, timeout: float = 0.1) -> None:
|
|
533
|
-
"""Drain
|
|
533
|
+
"""Drain leftover bytes and unsolicited messages from the socket buffer.
|
|
534
534
|
|
|
535
|
-
The MDP-20000 pump
|
|
536
|
-
|
|
537
|
-
|
|
535
|
+
The MDP-20000 pump emits two things we need to consume before a request:
|
|
536
|
+
- Padding bytes (0xee / 0x00) trailing some responses
|
|
537
|
+
- Unsolicited type 0x00 status broadcasts (header + body + 129-byte padding)
|
|
538
|
+
|
|
539
|
+
If an unsolicited type 0x00 frame is found and we only consume its body,
|
|
540
|
+
the trailing 129-byte padding remains in the buffer and corrupts the next
|
|
541
|
+
read (forcing a slow byte-by-byte resync that often races the pump's
|
|
542
|
+
connection close, surfacing as IncompleteReadError).
|
|
538
543
|
|
|
539
544
|
Args:
|
|
540
|
-
timeout: How long to wait for
|
|
545
|
+
timeout: How long to wait for bytes (default 0.1s)
|
|
541
546
|
"""
|
|
542
547
|
if not self._reader:
|
|
543
548
|
return
|
|
@@ -559,20 +564,21 @@ class JebaoProtocol:
|
|
|
559
564
|
continue
|
|
560
565
|
# Check if it's a valid header
|
|
561
566
|
if header[0:4] == b"\x00\x00\x00\x03":
|
|
562
|
-
#
|
|
563
|
-
#
|
|
564
|
-
# This is a problem - we've consumed a valid message header
|
|
565
|
-
_LOGGER.warning(
|
|
566
|
-
"Found valid header while draining - this shouldn't happen! "
|
|
567
|
-
"Pump may have sent unsolicited message."
|
|
568
|
-
)
|
|
569
|
-
# Read the rest of this message to consume it
|
|
567
|
+
# Pump sent an unsolicited message (e.g. periodic status broadcast).
|
|
568
|
+
# Consume the full frame so we don't desync the stream.
|
|
570
569
|
length = header[4]
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
570
|
+
body = await self._reader.readexactly(length)
|
|
571
|
+
msg_type = body[2] if len(body) > 2 else 0
|
|
572
|
+
total = len(header) + len(body)
|
|
573
|
+
# Type 0x00 messages carry an extra 129-byte padding frame
|
|
574
|
+
# (same as _read_raw). Skip it or stale bytes corrupt the next read.
|
|
575
|
+
if msg_type == MSG_EXTENDED_DATA:
|
|
576
|
+
padding = await self._reader.readexactly(129)
|
|
577
|
+
total += len(padding)
|
|
578
|
+
_LOGGER.debug(
|
|
579
|
+
"Drained unsolicited message: type=0x%02x, %d bytes total",
|
|
580
|
+
msg_type,
|
|
581
|
+
total,
|
|
576
582
|
)
|
|
577
583
|
else:
|
|
578
584
|
# Garbage header - log and continue draining
|
|
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
|
|
File without changes
|