This commit is contained in:
2026-07-28 04:22:46 +02:00
parent aa513b884f
commit 70157b8bd9
2 changed files with 179 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
import sys
import struct
class PulseWire:
def __init__(self):
...
def on_raw_engine_request(self, data: bytes):
...
def send_raw(self, data: bytes):
sys.stdout.buffer.write(len(data).to_bytes(8, "little"))
sys.stdout.buffer.write(data)
sys.stdout.flush()
def start(self):
while True:
len_buf = sys.stdin.buffer.read(struct.calcsize("P"))
if len(len_buf) == 0:
return None
length = int.from_bytes(len_buf, "little")
if length == 0:
return None
buffer = sys.stdin.buffer.read(length)
if len(buffer) != length:
raise EOFError("Unexpected EOF while reading payload")
self.on_raw_engine_request(buffer)