aamio-serial 0.1.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.
@@ -0,0 +1,4 @@
1
+ """aamio through a modem on a serial port: a transport under contract 3 (see transport.py and aamio-addon.json)."""
2
+
3
+ NAME = "serial"
4
+ __version__ = "0.1.0"
@@ -0,0 +1,13 @@
1
+ {
2
+ "aamio_addon": 3,
3
+ "name": "serial",
4
+ "version": "0.1.0",
5
+ "description": "aamio over a serial port. Through a modem, each frame goes as TX and the frame, or as TXID with a transmission ID that the modem echoes in its answer. Frames heard come back as RX and the frame: what the modem is, a LoRa, Zigbee or ESP-NOW radio, the transport does not know. Or straight to another aamio, over a cable or a pair of radio modules that pass on what they are given. The port, the largest frame and the speed are settings. The core seals and verifies. With a radio, everyone in range sees that frames go, how big they are and when, and the radio's rules for airtime are the modem's and yours to keep: the transport counts none.",
6
+ "transport": {
7
+ "medium": "serial",
8
+ "start": {"python": "aamio_serial.transport"},
9
+ "platforms": ["linux", "darwin", "win32"],
10
+ "permissions": ["serial", "radio"]
11
+ },
12
+ "environment": ["AAMIO_SERIAL_PORT", "AAMIO_SERIAL_BAUD", "AAMIO_SERIAL_MAX_FRAME", "AAMIO_SERIAL_RATE", "AAMIO_SERIAL_DIRECT", "AAMIO_SERIAL_PROTOCOL", "AAMIO_SERIAL_ANSWER", "AAMIO_SERIAL_LATE", "AAMIO_SERIAL_LINK_ACK", "AAMIO_SERIAL_VISIBLE", "AAMIO_SERIAL_DTR", "AAMIO_SERIAL_RTS"]
13
+ }
@@ -0,0 +1,624 @@
1
+ """serial: a transport under contract 3: frames over a serial port, through a modem or straight to another aamio.
2
+
3
+ Through a modem. Each line ends with a line feed and each frame is base64url without padding. Legacy modems use:
4
+
5
+ TX <frame> to the modem: send this frame
6
+ TXOK ... from the modem: the frame was handed to the medium
7
+ TXERR <why> from the modem: it was not
8
+ RX <frame> ... from the modem: a frame it heard
9
+
10
+ What follows TXOK, and the frame of an RX, is the modem's own, as a signal strength. Any other line is the modem's own
11
+ talk and goes to the log, also one that begins with the letters of an answer, as TXOKAY: an answer is the whole first
12
+ word. The transport gives the modem one frame at a time and waits for its answer before the next.
13
+
14
+ A legacy modem returns exactly one terminal answer per TX, in order. A TX whose outcome is unknown holds the next
15
+ frame until that answer arrives, also across a port that goes away and comes back. The core's state_dir records the
16
+ outstanding TX, so a transport that is started again knows an answer is owed: it waits for it as long as the modem has
17
+ to answer, and then takes it as lost. The core starts a transport again when it has given no room for a minute and
18
+ leaves it down after three such stops, so one that waited for good for an answer the modem never gives would carry
19
+ nothing again, in either direction, until somebody removed a file by hand. The README says what this leaves open.
20
+ Tagged mode closes it.
21
+
22
+ In tagged mode, TXID <id> <frame> requests transmission and TXOKID <id> or TXERRID <id> <reason> answers it.
23
+ Each attempt has a fresh 32-digit lowercase hex id. RX is unchanged. A timeout or disconnect retires the id.
24
+ Only the matching reply can acknowledge an attempt, including after a restart.
25
+
26
+ Straight to another aamio, with AAMIO_SERIAL_DIRECT. The port is then a line that carries bytes as they are to the same
27
+ transport at the other end: a cable between two machines, or a pair of radio modules that pass on what they are given.
28
+ No modem answers, so the transport writes "RX <frame>" itself, which the other end reads as a frame heard, and the frame
29
+ is sent when it is written and its time at the rate in AAMIO_SERIAL_RATE has passed.
30
+
31
+ The transport encrypts and checks nothing: the core seals and verifies (contract 3, part A). What the modem and the
32
+ medium show to others, it cannot hide: with a radio, anyone in range sees that frames go, how big and when. It counts no
33
+ airtime either: a radio's rules for airtime are the modem's and its owner's to keep. A frame that comes back as it was
34
+ sent, as an echo on the line, is let go.
35
+
36
+ A probe, as enable makes before anything is recorded, gets a description and nothing more: no port is opened and no room
37
+ is given, and it needs none of the variables below, which a probe is not given (contract 3, B3). A real start reads
38
+ them; one it cannot start with ends it with a line that names it.
39
+
40
+ AAMIO_SERIAL_PORT the modem's serial port, as COM8 or /dev/ttyACM0, or a pyserial URL as socket://127.0.0.1:7070
41
+ AAMIO_SERIAL_BAUD its speed, 115200 if left out
42
+ AAMIO_SERIAL_MAX_FRAME the largest frame the modem takes, in bytes, 64 if left out, from 10 to 65535
43
+ AAMIO_SERIAL_RATE bytes a second the medium carries, 200 if left out
44
+ AAMIO_SERIAL_DIRECT 1 when the port is a line straight to another aamio and no modem answers, 0 if left out
45
+ AAMIO_SERIAL_PROTOCOL legacy (default) or tagged; tagged requires a modem that supports TXID
46
+ AAMIO_SERIAL_ANSWER seconds the modem has to answer a TX, 12 if left out, from 1 to 25
47
+ AAMIO_SERIAL_LATE seconds after a TX before a missing answer is reported as link down (default: twice ANSWER)
48
+ AAMIO_SERIAL_LINK_ACK 1 when the modem says TXOK only once the medium confirmed the frame, 0 if left out
49
+ AAMIO_SERIAL_VISIBLE who sees that frames go: range (a radio, if left out), local (a wire) or operator
50
+ AAMIO_SERIAL_DTR on or off: the DTR line is set so before the port opens. Left out, the driver decides
51
+ AAMIO_SERIAL_RTS the same for the RTS line
52
+ """
53
+
54
+ import base64
55
+ import collections
56
+ import hashlib
57
+ import json
58
+ import math
59
+ import os
60
+ import queue
61
+ import secrets
62
+ import sys
63
+ import threading
64
+ import time
65
+ from pathlib import Path
66
+
67
+ NAME, VERSION = "serial", "0.1.0"
68
+ CREDIT = 1 # one frame at a time: the modem answers each before the next is given
69
+ BAUD = 115200
70
+ MAX_FRAME, RATE = 64, 200.0 # the careful corner: what the smallest and the slowest of the known modems take
71
+ ANSWER_SECONDS = 12.0
72
+ WRITE_SECONDS = 5 # a line to the modem that is not taken in this time: the port is stuck
73
+ REOPEN_SECONDS = 5.0
74
+ LINE_MOST = 131_072 # a line from the modem longer than this is no line: an RX of the largest frame is 87 388 bytes
75
+ TALK_A_MINUTE = 20 # lines of the modem's own talk that go to the log in a minute; the rest are counted
76
+ OWN_SECONDS = 30.0 # a frame heard this long after it was sent, with the same bytes, is its own echo
77
+ LINE_SHARE = 0.7 # the share of a line's bytes that are the frame's: base64url, and RX and the line feed around it
78
+ VISIBLE = ("range", "local", "operator")
79
+ ALPHABET = frozenset("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_")
80
+
81
+
82
+ class SettingError(Exception):
83
+ """A setting the transport cannot start with: said on standard error, naming the variable, and it ends with 1."""
84
+
85
+
86
+ def note(text):
87
+ sys.stderr.write("aamio-serial: %s\n" % text)
88
+ sys.stderr.flush()
89
+
90
+
91
+ def b64url(data):
92
+ return base64.urlsafe_b64encode(data).decode("ascii").rstrip("=")
93
+
94
+
95
+ def unb64url(text):
96
+ """The bytes of base64url without padding, or ValueError: the standard library takes other characters in silence."""
97
+ if not isinstance(text, str) or not text or any(character not in ALPHABET for character in text) or len(text) % 4 == 1:
98
+ raise ValueError("not base64url")
99
+ return base64.urlsafe_b64decode(text + "=" * (-len(text) % 4))
100
+
101
+
102
+ def whole_of(env, name, default, lowest, highest, what):
103
+ text = env.get(name, "").strip()
104
+ if not text:
105
+ return default
106
+ try:
107
+ value = int(text)
108
+ except ValueError:
109
+ raise SettingError("%s is %s" % (name, what)) from None
110
+ if not lowest <= value <= highest:
111
+ raise SettingError("%s is %s" % (name, what))
112
+ return value
113
+
114
+
115
+ def number_of(env, name, default, lowest, highest, what):
116
+ text = env.get(name, "").strip()
117
+ if not text:
118
+ return default
119
+ try:
120
+ value = float(text)
121
+ except ValueError:
122
+ raise SettingError("%s is %s" % (name, what)) from None
123
+ if math.isnan(value) or not lowest <= value <= highest:
124
+ raise SettingError("%s is %s" % (name, what))
125
+ return value
126
+
127
+
128
+ def choice_of(env, name, default, choices, what):
129
+ text = env.get(name, "").strip().lower()
130
+ if not text:
131
+ return default
132
+ if text not in choices:
133
+ raise SettingError("%s is %s" % (name, what))
134
+ return choices[text]
135
+
136
+
137
+ class Settings:
138
+ """What a real start runs with, read and checked before the port is opened."""
139
+
140
+ def __init__(self, env):
141
+ self.port = env.get("AAMIO_SERIAL_PORT", "").strip()
142
+ if not self.port:
143
+ raise SettingError("AAMIO_SERIAL_PORT is the modem's serial port, as COM8 or /dev/ttyACM0, and it is not set")
144
+ self.baud = whole_of(env, "AAMIO_SERIAL_BAUD", BAUD, 1, 10_000_000, "the port's speed in bits a second, a whole number from 1")
145
+ self.max_frame = whole_of(env, "AAMIO_SERIAL_MAX_FRAME", MAX_FRAME, 10, 65_535,
146
+ "the largest frame the modem takes in bytes, a whole number from 10 to 65535")
147
+ self.rate = number_of(env, "AAMIO_SERIAL_RATE", None, 0.001, 1e9, "bytes a second the medium carries, above 0")
148
+ # At most 25: the core waits 30 seconds for a frame's answer.
149
+ self.answer = number_of(env, "AAMIO_SERIAL_ANSWER", ANSWER_SECONDS, 1, 25, "seconds the modem has to answer a TX, from 1 to 25")
150
+ self.late = number_of(env, "AAMIO_SERIAL_LATE", None, 1, 86_400,
151
+ "seconds after a TX before a missing answer is reported as link down, from 1 to 86400")
152
+ if self.late is not None and self.late <= self.answer:
153
+ raise SettingError("AAMIO_SERIAL_LATE is more than AAMIO_SERIAL_ANSWER: an answer is late only after the time it has")
154
+ self.direct = choice_of(env, "AAMIO_SERIAL_DIRECT", False, {"1": True, "0": False},
155
+ "1 when the port is a line straight to another aamio and no modem answers, or 0")
156
+ self.protocol = choice_of(env, "AAMIO_SERIAL_PROTOCOL", "legacy", {"legacy": "legacy", "tagged": "tagged"},
157
+ "legacy or tagged")
158
+ if self.direct and self.protocol == "tagged":
159
+ raise SettingError("AAMIO_SERIAL_PROTOCOL=tagged needs a modem that answers; turn off AAMIO_SERIAL_DIRECT")
160
+ self.link_ack = choice_of(env, "AAMIO_SERIAL_LINK_ACK", False, {"1": True, "0": False},
161
+ "1 when TXOK means the medium confirmed the frame, or 0")
162
+ if self.direct and self.link_ack:
163
+ raise SettingError("AAMIO_SERIAL_LINK_ACK is for a modem that answers, and with AAMIO_SERIAL_DIRECT there is none: set one of them")
164
+ if self.rate is None:
165
+ # Through a modem, the careful corner. Straight, what the port's own speed carries: ten bits a byte, and a
166
+ # frame of n bytes is a line of about 1.37 n, so seven tenths of the line's bytes are the frame's.
167
+ self.rate = self.baud / 10 * LINE_SHARE if self.direct else RATE
168
+ self.visible = choice_of(env, "AAMIO_SERIAL_VISIBLE", "range", {name: name for name in VISIBLE},
169
+ "who sees that frames go: range, local or operator")
170
+ lines = {"on": True, "off": False}
171
+ self.dtr = choice_of(env, "AAMIO_SERIAL_DTR", None, lines, "on or off")
172
+ self.rts = choice_of(env, "AAMIO_SERIAL_RTS", None, lines, "on or off")
173
+
174
+
175
+ def open_port(settings, serial):
176
+ """The port, opened. DTR and RTS are set before it opens where the settings say so: the USB serial of some
177
+ boards restarts the chip when they change, and others send nothing until DTR is on."""
178
+ port = serial.serial_for_url(settings.port, settings.baud, timeout=0.5, write_timeout=WRITE_SECONDS, do_not_open=True)
179
+ if settings.dtr is not None:
180
+ port.dtr = settings.dtr
181
+ if settings.rts is not None:
182
+ port.rts = settings.rts
183
+ port.open()
184
+ return port
185
+
186
+
187
+ class Modem:
188
+ def __init__(self):
189
+ self.out = threading.Lock()
190
+ self.settings = None
191
+ self.serial = None
192
+ self.port = None
193
+ self.stopping = False
194
+ self.sends_read = 0
195
+ self.sends = queue.Queue()
196
+ self.answers = queue.Queue()
197
+ self.link = threading.Lock() # port, outstanding TX and publication of up/down/credit
198
+ self.reported_up = None
199
+ self.reported_reason = None
200
+ self.tx_state = "idle" # idle -> waiting (write attempted) -> answered -> idle (marker removed)
201
+ self.tx_id = None # tagged attempt whose terminal reply the reader can still accept
202
+ self.pending_file = None
203
+ self.given_at = 0.0
204
+ self.inherited = False # the answer owed is to a frame given before this start
205
+ self.opened_at = None # when the port that is open now was opened
206
+ # Frames given and not answered yet, and those of them the core has cancelled: a cancelled frame is answered
207
+ # cancelled when its TX has not been written, and is sent when it has (contract 3, B3.2).
208
+ self.turns = threading.Lock()
209
+ self.pending = set()
210
+ self.cancelled = set()
211
+ self.talk = collections.deque()
212
+ self.talk_left_out = 0
213
+ self.not_frames = 0
214
+ self.own = {} # SHA-256 of each frame sent of late -> when: what comes back is an echo
215
+ self.echoes = 0
216
+
217
+ def say(self, message):
218
+ line = json.dumps(message, separators=(",", ":")) + "\n"
219
+ with self.out:
220
+ sys.stdout.write(line)
221
+ sys.stdout.flush()
222
+
223
+ def describe(self):
224
+ """What the medium is: with its own settings once started, with the defaults to a probe, which has none."""
225
+ settings = self.settings
226
+ max_frame = settings.max_frame if settings else MAX_FRAME
227
+ rate = settings.rate if settings else RATE
228
+ return {"t": "describe", "name": NAME, "version": VERSION, "aamio_addon": 3, "medium": "serial",
229
+ "properties": {"max_frame_up": max_frame, "max_frame_down": max_frame, "rate_up": rate, "rate_down": rate,
230
+ "direction": "half", "addressing": "none", "link_ack": settings.link_ack if settings else False,
231
+ "airtime": None, "metadata_visible_to": settings.visible if settings else "range",
232
+ "medium_encrypts": False}}
233
+
234
+ def start(self, state_dir):
235
+ """A real start: the settings read and checked, and the port opened by the thread that reads it."""
236
+ self.settings = Settings(os.environ)
237
+ try:
238
+ import serial # pyserial
239
+ except ImportError:
240
+ raise SettingError("pyserial is not installed in this Python: pip install pyserial") from None
241
+ self.serial = serial
242
+ if state_dir and not self.settings.direct and self.settings.protocol == "legacy":
243
+ port_id = hashlib.sha256(self.settings.port.encode("utf-8")).hexdigest()
244
+ self.pending_file = Path(state_dir) / ("serial-pending-" + port_id)
245
+ if self.pending_file.exists():
246
+ self.tx_state = "waiting"
247
+ self.inherited = True
248
+ self.given_at = time.monotonic()
249
+
250
+ # ---------------------------------------------------------------- the modem
251
+
252
+ def status(self, up, reason):
253
+ """With self.link held, say that the link went up or down, and a new reason for being down: what was said last
254
+ is then why it is down now, also when the port is back and an answer is still owed."""
255
+ if self.reported_up != up or (not up and reason != self.reported_reason):
256
+ self.say({"t": "status", "state": "up" if up else "down", "reason": reason})
257
+ self.reported_up, self.reported_reason = up, reason
258
+
259
+ def ready(self):
260
+ """With self.link held, publish credit only for a connected port with no outstanding reply."""
261
+ if self.port is not None and self.tx_state == "idle" and not self.stopping:
262
+ reason = "a line on %s straight to another aamio" if self.settings.direct else "a modem on %s"
263
+ self.status(True, reason % self.settings.port)
264
+ with self.turns:
265
+ if not self.pending:
266
+ self.say({"t": "ready", "credit": CREDIT, "sends_read": self.sends_read})
267
+
268
+ def hear(self):
269
+ """Open the port and read its lines. While it cannot be opened, say down once and try again."""
270
+ while not self.stopping:
271
+ try:
272
+ port = open_port(self.settings, self.serial)
273
+ except (OSError, ValueError) as error:
274
+ with self.link:
275
+ self.status(False, "the port %s does not open: %s. Tried again every %d seconds"
276
+ % (self.settings.port, error, REOPEN_SECONDS))
277
+ self.sleep(REOPEN_SECONDS)
278
+ continue
279
+ with self.link:
280
+ self.port = port
281
+ self.opened_at = time.monotonic()
282
+ if self.tx_state != "idle" and self.inherited:
283
+ self.status(False, "the port %s is open, and the answer to a frame given before this start is owed: it "
284
+ "has %g seconds to come and is then taken as lost" % (self.settings.port, self.settings.answer))
285
+ elif self.tx_state != "idle" and self.settings.protocol == "legacy":
286
+ self.status(False, "the port %s is open, and the answer to the frame given last is still owed: no frame "
287
+ "is given until it has come" % self.settings.port)
288
+ else:
289
+ self.ready()
290
+ why = self.read(port)
291
+ with self.link:
292
+ self.port = None
293
+ self.opened_at = None
294
+ if not self.stopping:
295
+ self.status(False, "the port %s went away: %s" % (self.settings.port, why))
296
+ if self.tx_state == "waiting":
297
+ self.tx_id = None
298
+ self.answers.put(None)
299
+ try:
300
+ port.close()
301
+ except (OSError, ValueError):
302
+ pass
303
+ if self.stopping:
304
+ return
305
+ self.sleep(1.0)
306
+
307
+ def sleep(self, seconds):
308
+ """So long and no longer, in pieces short enough that a stop is not waited on."""
309
+ until = time.monotonic() + seconds
310
+ while not self.stopping:
311
+ left = until - time.monotonic()
312
+ if left <= 0:
313
+ return
314
+ time.sleep(min(left, 0.1))
315
+
316
+ def read(self, port):
317
+ """The lines that come in, until the port fails or the transport stops: why it ended."""
318
+ buffer = b""
319
+ try:
320
+ while not self.stopping:
321
+ # One byte or the timeout, then what has come with it: a read of many bytes waits out the timeout
322
+ # for every line, and each answer then comes half a second late.
323
+ data = port.read(1)
324
+ if data:
325
+ data += port.read(port.in_waiting)
326
+ elif not getattr(port, "is_open", True):
327
+ return "the port was closed"
328
+ buffer += data
329
+ while b"\n" in buffer:
330
+ raw, buffer = buffer.split(b"\n", 1)
331
+ self.line(raw.decode("ascii", "replace").strip())
332
+ if len(buffer) > LINE_MOST:
333
+ buffer = b""
334
+ self.said("more than %d bytes without the end of a line: let go" % LINE_MOST)
335
+ except (OSError, ValueError, TypeError, AttributeError) as error:
336
+ return "%s: %s" % (error.__class__.__name__, error)
337
+ return "stopped"
338
+
339
+ def line(self, text):
340
+ # The whole first word says what a line is. TXOKAY is the modem's own talk, and was taken for TXOK.
341
+ word = text.split(None, 1)[0] if text else ""
342
+ if word == "RX":
343
+ parts = text.split()[1:]
344
+ try:
345
+ frame = unb64url(parts[0]) if parts else b""
346
+ except ValueError:
347
+ frame = b""
348
+ # A frame as contract 3 makes them: at least ten bytes, AF first, and no larger than the medium takes.
349
+ if 10 <= len(frame) <= self.settings.max_frame and frame[:2] == b"AF":
350
+ if self.is_own(frame):
351
+ self.echoes += 1
352
+ if self.echoes == 1:
353
+ note("a frame came back with the bytes it was sent with: the line echoes, and echoes are let go")
354
+ else:
355
+ self.say({"t": "received", "from": None, "frame": b64url(frame)})
356
+ else:
357
+ self.not_frames += 1
358
+ if self.not_frames in (1, 10, 100) or self.not_frames % 1000 == 0:
359
+ note("%d RX line(s) so far did not hold a frame of 10 to %d bytes that begins with AF: let go"
360
+ % (self.not_frames, self.settings.max_frame))
361
+ elif word in ("TXOK", "TXERR", "TXOKID", "TXERRID"):
362
+ with self.link:
363
+ if self.tx_state == "waiting":
364
+ if self.settings.protocol == "tagged":
365
+ parts = text.split(None, 2)
366
+ if word in ("TXOKID", "TXERRID") and len(parts) >= 2 and parts[1] == self.tx_id:
367
+ self.tx_id = None # consume the id before a duplicate can enter the queue
368
+ self.answers.put(text)
369
+ return
370
+ elif word in ("TXOK", "TXERR"):
371
+ self.answers.put(text)
372
+ return
373
+ self.said("an answer nobody waited for: %s" % text[:120])
374
+ elif text:
375
+ self.said("modem: " + text[:200])
376
+
377
+ def said(self, text):
378
+ """The modem's own talk, to the log: at most TALK_A_MINUTE lines a minute, and the rest counted and said once."""
379
+ now = time.monotonic()
380
+ while self.talk and now - self.talk[0] > 60:
381
+ self.talk.popleft()
382
+ if len(self.talk) >= TALK_A_MINUTE:
383
+ self.talk_left_out += 1
384
+ return
385
+ if self.talk_left_out:
386
+ note("%d more line(s) from the modem were left out of the log" % self.talk_left_out)
387
+ self.talk_left_out = 0
388
+ self.talk.append(now)
389
+ note(text)
390
+
391
+ # ---------------------------------------------------------------- the frames
392
+
393
+ def remember_own(self, frame):
394
+ now = time.monotonic()
395
+ with self.turns:
396
+ for digest in [digest for digest, at in self.own.items() if now - at > OWN_SECONDS]:
397
+ del self.own[digest]
398
+ self.own[hashlib.sha256(frame).digest()] = now
399
+
400
+ def is_own(self, frame):
401
+ with self.turns:
402
+ at = self.own.get(hashlib.sha256(frame).digest())
403
+ return at is not None and time.monotonic() - at <= OWN_SECONDS
404
+
405
+ def given(self, frame_id):
406
+ with self.turns:
407
+ self.sends_read += 1
408
+ self.pending.add(frame_id)
409
+
410
+ def cancel(self, frame_id):
411
+ """The core cancelled a frame. One already answered is ignored, as contract 3 says, and is not kept."""
412
+ with self.turns:
413
+ if frame_id in self.pending:
414
+ self.cancelled.add(frame_id)
415
+
416
+ def was_cancelled(self, frame_id):
417
+ with self.turns:
418
+ return frame_id in self.cancelled
419
+
420
+ def speak(self):
421
+ """Give the modem what the core gives, one frame at a time, each when the one before is answered."""
422
+ if self.tx_state == "waiting": # the previous process left a TX outstanding
423
+ self.settle()
424
+ with self.link:
425
+ self.ready()
426
+ while not self.stopping:
427
+ try:
428
+ message = self.sends.get(timeout=0.2)
429
+ except queue.Empty:
430
+ continue
431
+ frame_id = message.get("id")
432
+ self.say(self.send(frame_id, message))
433
+ if self.tx_state != "idle":
434
+ self.settle()
435
+ with self.turns:
436
+ self.pending.discard(frame_id)
437
+ self.cancelled.discard(frame_id)
438
+ # Room for the next only now: the frame is answered, and no answer of the modem's is owed.
439
+ with self.link:
440
+ self.ready()
441
+
442
+ def retire_answer(self):
443
+ """A terminal reply is known. Clear its marker before granting the next credit."""
444
+ with self.link:
445
+ self.tx_state = "answered"
446
+ if self.pending_file is not None:
447
+ try:
448
+ self.pending_file.unlink(missing_ok=True)
449
+ except OSError as error:
450
+ self.status(False, "could not clear the pending TX in %s: %s" % (self.pending_file, error))
451
+ return
452
+ self.tx_state = "idle"
453
+
454
+ def settle(self):
455
+ """Retire a legacy TX only after its terminal reply, also across a port that went away and came back. An answer
456
+ owed from before this start has the time the modem has to answer, and is then taken as lost."""
457
+ threshold = self.settings.late or 2 * self.settings.answer
458
+ said_down = False
459
+ while self.tx_state == "waiting" and not self.stopping:
460
+ if self.inherited:
461
+ # Counted on a port that is open in this process: an answer can come on no other. Without this end, an
462
+ # answer the modem never gives stops the transport for good. The core starts a transport again when it
463
+ # has given no room for a minute, and that start would find the file and wait again, every time.
464
+ with self.link:
465
+ opened_at = self.opened_at
466
+ if opened_at is not None and time.monotonic() - opened_at >= self.settings.answer:
467
+ note("the answer to a frame given before this start has not come in the %g seconds the modem has: "
468
+ "taken as lost, and frames are given again" % self.settings.answer)
469
+ self.retire_answer()
470
+ break
471
+ waited = time.monotonic() - self.given_at
472
+ if not self.inherited and not said_down and waited >= threshold:
473
+ with self.link:
474
+ self.status(False, "the modem has not answered a frame given at least %g seconds ago; "
475
+ "its answers do not say which frame they are for" % threshold)
476
+ said_down = True
477
+ try:
478
+ late = self.answers.get(timeout=0.2)
479
+ except queue.Empty:
480
+ continue
481
+ if late is None:
482
+ # A closed port can be reopened while the same modem still holds the reply.
483
+ continue
484
+ self.retire_answer()
485
+ if self.inherited:
486
+ note("the answer to a frame given before this start came: %s" % late[:120])
487
+ else:
488
+ note("the modem answered after the %g seconds it has: %s" % (self.settings.answer, late[:120]))
489
+ while self.tx_state == "answered" and not self.stopping:
490
+ self.sleep(1.0)
491
+ self.retire_answer()
492
+ if self.tx_state == "idle":
493
+ self.inherited = False
494
+
495
+ def send(self, frame_id, message):
496
+ """Give one frame to the modem. A legacy write with no terminal reply keeps the slot outstanding."""
497
+ def failed(code, text):
498
+ return {"t": "error", "id": frame_id, "code": code, "message": text}
499
+
500
+ try:
501
+ frame = unb64url(message.get("frame"))
502
+ except ValueError:
503
+ return failed("bad_frame", "the frame is not base64url")
504
+ if len(frame) > self.settings.max_frame:
505
+ return failed("too_large", "a frame is at most %d bytes here, as AAMIO_SERIAL_MAX_FRAME says" % self.settings.max_frame)
506
+ # The medium has no addresses: whatever to says, the frame goes to everyone the modem reaches.
507
+ if self.was_cancelled(frame_id):
508
+ return failed("cancelled", "cancelled before it was given to the modem: nothing was sent")
509
+ direct = self.settings.direct
510
+ # Core frame IDs start at f-1 in each new process; the same bytes may also be retried.
511
+ wire_id = secrets.token_hex(16) if self.settings.protocol == "tagged" else None
512
+ with self.link:
513
+ port = self.port
514
+ if port is None:
515
+ return failed("down", "the port %s is not open" % self.settings.port)
516
+ if not direct:
517
+ while not self.answers.empty(): # disconnect notifications after the previous terminal reply
518
+ self.answers.get_nowait()
519
+ if self.pending_file is not None:
520
+ try:
521
+ self.pending_file.touch(exist_ok=False)
522
+ except OSError as error:
523
+ return failed("send_failed", "could not record the pending TX in %s: %s" % (self.pending_file, error))
524
+ self.tx_state = "waiting"
525
+ self.tx_id = wire_id
526
+ began = self.given_at = time.monotonic()
527
+ command = "TXID " + wire_id if wire_id is not None else ("RX" if direct else "TX")
528
+ self.remember_own(frame)
529
+ line = ("%s %s\n" % (command, b64url(frame))).encode("ascii")
530
+ try:
531
+ try:
532
+ if port.write(line) != len(line):
533
+ raise OSError("short serial write")
534
+ except (OSError, ValueError, TypeError, AttributeError) as error:
535
+ # Do not grant new credit for this failed handle before the reader reopens it.
536
+ if wire_id is not None:
537
+ with self.link:
538
+ if self.port is port:
539
+ self.port = None
540
+ self.tx_id = None
541
+ # A failed write may already have handed bytes to the modem.
542
+ try:
543
+ port.close()
544
+ except (OSError, ValueError):
545
+ pass
546
+ return failed("send_failed", "the %s could not be written to: %s" % ("line" if direct else "modem", error))
547
+ if direct:
548
+ # Nobody answers on a line: the frame is sent when it is written and its time at the rate has passed, so
549
+ # the next one is not written into a line that still carries this one.
550
+ self.sleep(len(frame) / self.settings.rate - (time.monotonic() - began))
551
+ return {"t": "sent", "id": frame_id}
552
+ try:
553
+ said = self.answers.get(timeout=self.settings.answer)
554
+ except queue.Empty:
555
+ return failed("send_failed", "the modem did not answer within %g seconds: whether the frame went is not known"
556
+ % self.settings.answer)
557
+ if said is None:
558
+ return failed("send_failed", "the port went away before the modem answered: whether the frame went is not known")
559
+ finally:
560
+ if wire_id is not None:
561
+ # A stale answer (including one arriving just as the wait expires) cannot acquire the next credit.
562
+ with self.link:
563
+ self.tx_id = None
564
+ self.tx_state = "idle"
565
+ if wire_id is None:
566
+ self.retire_answer()
567
+ if said.split(None, 1)[0] in ("TXOK", "TXOKID"):
568
+ if self.settings.link_ack:
569
+ self.say({"t": "sent", "id": frame_id})
570
+ return {"t": "link_ack", "id": frame_id}
571
+ return {"t": "sent", "id": frame_id}
572
+ return failed("send_failed", "the modem said %s" % said[:200])
573
+
574
+ def run(self):
575
+ for line in sys.stdin:
576
+ try:
577
+ message = json.loads(line)
578
+ except ValueError:
579
+ continue
580
+ if not isinstance(message, dict):
581
+ continue
582
+ kind = message.get("t")
583
+ if kind == "hello":
584
+ if message.get("probe"):
585
+ self.say(self.describe())
586
+ continue
587
+ if self.settings is not None:
588
+ continue
589
+ try:
590
+ self.start(message.get("state_dir"))
591
+ except SettingError as error:
592
+ note(str(error))
593
+ sys.exit(1)
594
+ self.say(self.describe())
595
+ threading.Thread(target=self.hear, daemon=True).start()
596
+ threading.Thread(target=self.speak, daemon=True).start()
597
+ elif kind == "send":
598
+ if self.settings is None:
599
+ self.sends_read += 1
600
+ self.say({"t": "error", "id": message.get("id"), "code": "down", "message": "the transport was not started"})
601
+ continue
602
+ self.given(message.get("id"))
603
+ self.sends.put(message)
604
+ elif kind == "cancel":
605
+ self.cancel(message.get("id"))
606
+ elif kind == "stop":
607
+ break
608
+ self.stopping = True
609
+ port = self.port
610
+ if port is not None:
611
+ try:
612
+ port.close()
613
+ except (OSError, ValueError):
614
+ pass
615
+
616
+
617
+ def main():
618
+ # UTF-8, as contract 3 asks, whatever code page a pipe gets on Windows.
619
+ sys.stderr.reconfigure(encoding="utf-8", errors="backslashreplace")
620
+ Modem().run()
621
+
622
+
623
+ if __name__ == "__main__":
624
+ main()
@@ -0,0 +1,252 @@
1
+ Metadata-Version: 2.4
2
+ Name: aamio-serial
3
+ Version: 0.1.0
4
+ Summary: aamio transport under contract 3 for serial modems with ordered legacy replies or ID-matched replies. Supports LoRa, Zigbee and ESP-NOW modems, plus direct links over cables or transparent radio modules.
5
+ Author: AI SENSE AS
6
+ License: MIT
7
+ Project-URL: Homepage, https://aamio.at/docs/addons
8
+ Project-URL: Source, https://github.com/aisenseapi/aamio-python/tree/main/addons/serial
9
+ Project-URL: Changelog, https://github.com/aisenseapi/aamio-python/blob/main/addons/serial/CHANGELOG.md
10
+ Project-URL: Issues, https://github.com/aisenseapi/aamio-python/issues
11
+ Keywords: aamio,agents,transport,serial,modem,radio,lora
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: aamio>=0.7.6
16
+ Requires-Dist: pyserial>=3.5
17
+ Dynamic: license-file
18
+
19
+ # aamio-serial
20
+
21
+ aamio over a serial port: a transport under contract 3. Two machines can then
22
+ exchange aamio messages without aamio.at between them and without a network,
23
+ over whatever a serial port reaches:
24
+
25
+ - **straight to another aamio**, over a cable between two serial ports, or a
26
+ pair of radio modules that pass on what they are given
27
+ - **through a modem** that supports one of the serial protocols, over LoRa,
28
+ Zigbee, ESP-NOW or something else
29
+
30
+ The transport is a dumb pipe. The core seals each message for its recipient,
31
+ signs it, counts it and receipts it; the transport only moves frames. It does
32
+ not know what is at the other end of the port, so the port, the largest frame
33
+ and the speed are settings.
34
+
35
+ ## Straight to another aamio
36
+
37
+ Join the two ports with a cable that crosses the data lines, or put a radio
38
+ module that passes bytes on as they are on each port. On each machine, in
39
+ PowerShell, with the other machine's key from `aamio whoami` there:
40
+
41
+ ```powershell
42
+ pip install aamio-serial
43
+ aamio addon enable serial
44
+ $env:AAMIO_SERIAL_PORT = "COM5"
45
+ $env:AAMIO_SERIAL_BAUD = "9600"
46
+ $env:AAMIO_SERIAL_DIRECT = "1"
47
+ aamio partner add other KEY_OF_THE_OTHER
48
+ aamio transport bind other serial
49
+ aamio serve
50
+ ```
51
+
52
+ In bash the same lines set the variables with `export AAMIO_SERIAL_PORT=/dev/ttyUSB0`.
53
+ In PowerShell, `set NAME=value` makes a variable of the shell and not of the
54
+ environment, so nothing reaches aamio. The variables are set in the shell that
55
+ runs `aamio serve`, `aamio send` or `aamio read --wait`: the core passes a
56
+ transport only the variables its manifest lists, taken from its own
57
+ environment.
58
+
59
+ With `AAMIO_SERIAL_DIRECT=1` no modem answers. The transport writes
60
+ `RX <frame>` itself, which the other end reads as a frame heard, and a frame is
61
+ sent when it is written and its time at the rate has passed. Left out, the rate
62
+ is what the port's own speed carries: at 9600 baud the line carries 960 bytes a
63
+ second, and about seven tenths of them are the frame's, so 672. A radio module
64
+ that sends more slowly than its port takes needs `AAMIO_SERIAL_RATE` set to
65
+ what the air carries, or frames are written into a module that is still
66
+ sending.
67
+
68
+ ## Through a modem
69
+
70
+ ```powershell
71
+ pip install aamio-serial
72
+ aamio addon enable serial
73
+ $env:AAMIO_SERIAL_PORT = "COM8"
74
+ $env:AAMIO_SERIAL_MAX_FRAME = "255"
75
+ $env:AAMIO_SERIAL_RATE = "200"
76
+ aamio partner add other KEY_OF_THE_OTHER
77
+ aamio transport bind other serial
78
+ aamio serve
79
+ ```
80
+
81
+ The largest frame and the rate are the modem's. Left out they are 64 bytes and
82
+ 200 bytes a second, which the smallest and the slowest of the modems these
83
+ lines were made for take. Numbers that have carried aamio:
84
+
85
+ | Medium | `AAMIO_SERIAL_MAX_FRAME` | `AAMIO_SERIAL_RATE` | Other |
86
+ |---|---|---|---|
87
+ | LoRa, 125 kHz, SF9 | 255 | 200 | |
88
+ | ESP-NOW | 240 | 20000 | `AAMIO_SERIAL_LINK_ACK=1` when the modem waits for the acknowledgement |
89
+ | Zigbee, one command a frame | 64 | 2000 | |
90
+
91
+ ### Modem lines
92
+
93
+ Each line ends in LF. A CR before LF is allowed. A frame is base64url without
94
+ padding. Both protocols accept `RX <frame> [meta]` from the modem. The decoded
95
+ frame must start with the two bytes `AF` and have 10 to
96
+ `AAMIO_SERIAL_MAX_FRAME` bytes. The host ignores optional RX metadata, such
97
+ as signal strength. Brackets below denote optional fields. Terminal words
98
+ match exactly. For example, `TXOKAY` is modem chatter.
99
+
100
+ | Protocol | Host requests transmission | Modem accepts | Modem reports failure |
101
+ |---|---|---|---|
102
+ | `legacy` (default) | `TX <frame>` | `TXOK [meta]` | `TXERR [reason]` |
103
+ | `tagged` | `TXID <id> <frame>` | `TXOKID <id> [meta]` | `TXERRID <id> [reason]` |
104
+
105
+ A positive modem answer reports local handoff to the medium. Set
106
+ `AAMIO_SERIAL_LINK_ACK=1` only when the firmware actually waits for a
107
+ link-layer acknowledgement before answering. In either case, only the
108
+ recipient's signed receipt confirms delivery of the aamio message. A timeout
109
+ returns `send_failed` even when the modem may already have sent the frame.
110
+
111
+ ### Legacy modems and outstanding answers
112
+
113
+ Legacy firmware must return exactly one terminal answer per `TX`, in order.
114
+ The host allows one outstanding transmission. Before writing it, the host
115
+ records that an answer is owed. Later frames wait until the old `TXOK` or
116
+ `TXERR` arrives, also after a timeout and on a port that went away and came
117
+ back. The old answer releases the port for another frame. The original
118
+ timed-out attempt keeps its failure result.
119
+
120
+ While the port is open, incoming `RX` frames can still be read.
121
+ `AAMIO_SERIAL_LATE` controls when the transport reports a missing answer as
122
+ link down. The transport goes on waiting.
123
+
124
+ ### An answer a legacy modem never gives
125
+
126
+ A modem that restarts in the middle of a `TX`, as one whose power dips when it
127
+ sends, never answers that `TX`. The transport cannot tell that from an answer
128
+ that is only late, and while it waits, nothing goes out.
129
+
130
+ The core ends that wait. It starts a transport again when it has given no room
131
+ for a minute. The new start finds the record of the owed answer, waits for it
132
+ for `AAMIO_SERIAL_ANSWER` seconds on the open port, and then takes it as
133
+ lost. About a minute and a half after an answer that never came, frames go
134
+ again with nothing to do by hand, and the core sends the message that was on
135
+ its way again. After three such stops in ten minutes the core leaves a
136
+ transport down until aamio is started again, as it does with any transport.
137
+
138
+ The record is an empty file `serial-pending-<digest>` in the transport's
139
+ working directory, where the digest is the SHA-256 of the configured port
140
+ string. The answer removes it, and so does a new start that has waited.
141
+
142
+ **What this leaves open.** An answer that comes after it was taken as lost is
143
+ let go when no frame waits. One that comes just after the next `TX` was
144
+ written is taken for that frame's. For a frame the modem refused to be
145
+ reported sent, the modem must give the old answer later than the
146
+ `AAMIO_SERIAL_ANSWER` seconds it has, counted again from the new start, and in
147
+ the moment between the next `TX` and its answer. The core takes no message as
148
+ arrived on a `TXOK`, only on the recipient's signed receipt, and sends again
149
+ what has none. Tagged mode closes this: there an answer names its attempt.
150
+
151
+ ### Tagged modems
152
+
153
+ Set `AAMIO_SERIAL_PROTOCOL=tagged` only with firmware that implements both
154
+ tagged terminal replies. The host generates a fresh ID of 32 lowercase
155
+ hexadecimal characters for every attempt, including a retry of the same
156
+ frame. The modem copies that exact ID into its single terminal reply. The
157
+ ID travels only between host and modem. It adds no bytes to the radio frame,
158
+ changes no recipient keys or receipts, and leaves `RX` unchanged.
159
+
160
+ Only a terminal reply bearing the active attempt's ID can complete it. A
161
+ timeout or disconnect retires the ID. Once the port is available another
162
+ attempt can use a fresh ID, even after a process restart. Late, duplicate
163
+ and untagged replies cannot acknowledge a new attempt. There is no automatic
164
+ downgrade to legacy. An incompatible modem can therefore time out every
165
+ request. Direct cable mode (`AAMIO_SERIAL_DIRECT=1`) rejects `tagged` because
166
+ there is no modem to answer.
167
+
168
+ ## Settings
169
+
170
+ The manifest declares these variables, and the core passes them on:
171
+
172
+ | Variable | Meaning |
173
+ |---|---|
174
+ | `AAMIO_SERIAL_PORT` | the serial port, as `COM8` or `/dev/ttyACM0`, or a pyserial URL as `socket://127.0.0.1:7070` |
175
+ | `AAMIO_SERIAL_BAUD` | its speed, 115200 if left out |
176
+ | `AAMIO_SERIAL_MAX_FRAME` | the largest frame in bytes, 10 to 65535, 64 if left out |
177
+ | `AAMIO_SERIAL_RATE` | bytes a second the medium carries. Left out: 200 through a modem, and what the port's speed carries straight |
178
+ | `AAMIO_SERIAL_DIRECT` | `1`: the port is a line straight to another aamio, and no modem answers |
179
+ | `AAMIO_SERIAL_PROTOCOL` | modem protocol, `legacy` by default. Select `tagged` only with compatible firmware and direct mode off. |
180
+ | `AAMIO_SERIAL_ANSWER` | seconds the modem has to answer a transmission, 1 to 25, 12 if left out |
181
+ | `AAMIO_SERIAL_LATE` | in legacy mode, seconds after a `TX` before a missing reply triggers link-down status, greater than `AAMIO_SERIAL_ANSWER`. Defaults to twice that value. The transport still waits for the reply. |
182
+ | `AAMIO_SERIAL_LINK_ACK` | `1`: the modem returns a positive terminal answer only once the medium confirmed the frame. Not with `AAMIO_SERIAL_DIRECT` |
183
+ | `AAMIO_SERIAL_VISIBLE` | who sees that frames go: `range` (a radio, if left out), `local` (a cable) or `operator` |
184
+ | `AAMIO_SERIAL_DTR`, `AAMIO_SERIAL_RTS` | `on` or `off`: the line is set so before the port opens. Left out, the driver decides |
185
+
186
+ A setting the transport cannot start with, as a frame size out of range, ends
187
+ it with a line on standard error that names the variable. A port that does not
188
+ open is said once, and tried again every five seconds. A port that goes away,
189
+ as a modem pulled from USB, is reported. The transport takes frames again
190
+ when the port is back and any outstanding reply has been accounted for.
191
+
192
+ On Linux a serial port belongs to a group, usually `dialout`, and a user outside
193
+ it cannot open the port: the status then says `Permission denied`.
194
+ `sudo usermod -aG dialout $USER`, and a new login, gives the user the port.
195
+
196
+ `AAMIO_SERIAL_DTR` and `AAMIO_SERIAL_RTS` are for boards whose USB serial
197
+ restarts the chip when these lines change: set both `off`. Other boards send
198
+ nothing until DTR is on.
199
+
200
+ ## What it does not do
201
+
202
+ - **It counts no airtime.** A radio's rules for the band, as how much of an
203
+ hour it may send, how strongly and with what licence, are the modem's and
204
+ yours to keep. The manifest says `radio` among what the add-on uses, since a
205
+ modem may be one.
206
+ - **It hides nothing the medium shows.** With a radio, everyone in range sees
207
+ that frames go, how big they are and when. What the frames say, only the
208
+ recipient reads, since the core seals them.
209
+ - **It has no addresses.** A frame goes to everyone the modem or the line
210
+ reaches. A frame for somebody else is let go by the core of whoever hears it.
211
+ - **One port for each home.** Two modems on one machine need two homes.
212
+ - **A frame that comes back with the bytes it was sent with** within thirty
213
+ seconds is taken for an echo on the line and let go.
214
+
215
+ ## Where it runs
216
+
217
+ Python on Windows, macOS and Linux, with [pyserial](https://pypi.org/project/pyserial/),
218
+ which pip brings with it. It needs aamio 0.7.6 or later. aamio-php and aamio-js
219
+ have no serial transport; they list it and do not run it.
220
+
221
+ ## Tried
222
+
223
+ `tests/test_transport_serial.py` in aamio-python runs the transport as its own
224
+ process against a modem on 127.0.0.1, spoken to as the core speaks to it: a
225
+ probe, every setting, a frame sent, refused and never answered, an answer that
226
+ comes late and one that comes later than twice its time, a line of talk that
227
+ begins as an answer does, what the modem hears and says, a cancel, a stop, an
228
+ echo, and a port that does not open or goes away and comes back. The tests
229
+ also hold an old reply across a disconnect and a restart of the transport
230
+ process: a legacy start waits for the old reply as long as the modem has to
231
+ answer and then takes it as lost. Tagged tests distinguish previous and
232
+ current attempts, including retries of the same frame.
233
+ `tests/test_transport_serial_service.py` exercises sealed messages between
234
+ two homes through a pair of modems and over a direct line. With a terminal
235
+ answer dropped, it checks through the core that a legacy modem is back after
236
+ one restart of the transport, and that a tagged modem never stops.
237
+
238
+ The modems in the November 2026 field tests spoke the legacy lines over LoRa,
239
+ Zigbee and ESP-NOW. The rate and size examples above come from those tests.
240
+ Tagged firmware still needs verification on each physical modem.
241
+
242
+ `tests/test_transport_serial_pty.py` runs the transport on a real tty: a pty
243
+ opened by its name through pyserial's own port class, as `/dev/ttyUSB0` is, with
244
+ the other end played as a modem and as a cable. Frames both ways, a line that
245
+ comes in two pieces, noise and 240 000 bytes without the end of a line, a modem
246
+ that refuses and one that says nothing, DTR and RTS set, and a port that goes
247
+ away and comes back under its name. It has run on Linux, under WSL, with
248
+ Python 3.10. It is written for macOS as well and has not been run there, and
249
+ Windows has no pty.
250
+
251
+ That is the port code of the operating system, and no hardware: aamio-serial
252
+ has not yet been tried with a physical modem, a cable or a radio module.
@@ -0,0 +1,9 @@
1
+ aamio_serial/__init__.py,sha256=qaagg6UgKIavYEwY1lkXYGRrv2fwlZG2ZhTFe7WofJI,155
2
+ aamio_serial/aamio-addon.json,sha256=kgZdbHkHxVuGX7SCsWgKqXAeHOcmQpjdyTGnEVwYT9k,1198
3
+ aamio_serial/transport.py,sha256=3aP_tONN0Ut5cvfHAMUtTxUouIQMldjZy-vBwE2HJIw,32136
4
+ aamio_serial-0.1.0.dist-info/licenses/LICENSE,sha256=1XHp9R5Pw9ETJmQ0tRM_BO7PrhZfJ4FLQhMQntdz3qM,1068
5
+ aamio_serial-0.1.0.dist-info/METADATA,sha256=5Z9WI2J7ovOhQY3j20FTuYa6kCqqqV-_FNBPWt4QKY0,13556
6
+ aamio_serial-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
7
+ aamio_serial-0.1.0.dist-info/entry_points.txt,sha256=UiMpnGSXhHXDruyhqddhpYTFa9pCXbdD7BimxeiIras,37
8
+ aamio_serial-0.1.0.dist-info/top_level.txt,sha256=5EH-Ch536SWBiBcJLv107MRjrtTmzhagTvL8lsIspEo,13
9
+ aamio_serial-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [aamio.addons]
2
+ serial = aamio_serial
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AI SENSE AS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ aamio_serial