aamio-serial 0.1.0__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.
@@ -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,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,234 @@
1
+ # aamio-serial
2
+
3
+ aamio over a serial port: a transport under contract 3. Two machines can then
4
+ exchange aamio messages without aamio.at between them and without a network,
5
+ over whatever a serial port reaches:
6
+
7
+ - **straight to another aamio**, over a cable between two serial ports, or a
8
+ pair of radio modules that pass on what they are given
9
+ - **through a modem** that supports one of the serial protocols, over LoRa,
10
+ Zigbee, ESP-NOW or something else
11
+
12
+ The transport is a dumb pipe. The core seals each message for its recipient,
13
+ signs it, counts it and receipts it; the transport only moves frames. It does
14
+ not know what is at the other end of the port, so the port, the largest frame
15
+ and the speed are settings.
16
+
17
+ ## Straight to another aamio
18
+
19
+ Join the two ports with a cable that crosses the data lines, or put a radio
20
+ module that passes bytes on as they are on each port. On each machine, in
21
+ PowerShell, with the other machine's key from `aamio whoami` there:
22
+
23
+ ```powershell
24
+ pip install aamio-serial
25
+ aamio addon enable serial
26
+ $env:AAMIO_SERIAL_PORT = "COM5"
27
+ $env:AAMIO_SERIAL_BAUD = "9600"
28
+ $env:AAMIO_SERIAL_DIRECT = "1"
29
+ aamio partner add other KEY_OF_THE_OTHER
30
+ aamio transport bind other serial
31
+ aamio serve
32
+ ```
33
+
34
+ In bash the same lines set the variables with `export AAMIO_SERIAL_PORT=/dev/ttyUSB0`.
35
+ In PowerShell, `set NAME=value` makes a variable of the shell and not of the
36
+ environment, so nothing reaches aamio. The variables are set in the shell that
37
+ runs `aamio serve`, `aamio send` or `aamio read --wait`: the core passes a
38
+ transport only the variables its manifest lists, taken from its own
39
+ environment.
40
+
41
+ With `AAMIO_SERIAL_DIRECT=1` no modem answers. The transport writes
42
+ `RX <frame>` itself, which the other end reads as a frame heard, and a frame is
43
+ sent when it is written and its time at the rate has passed. Left out, the rate
44
+ is what the port's own speed carries: at 9600 baud the line carries 960 bytes a
45
+ second, and about seven tenths of them are the frame's, so 672. A radio module
46
+ that sends more slowly than its port takes needs `AAMIO_SERIAL_RATE` set to
47
+ what the air carries, or frames are written into a module that is still
48
+ sending.
49
+
50
+ ## Through a modem
51
+
52
+ ```powershell
53
+ pip install aamio-serial
54
+ aamio addon enable serial
55
+ $env:AAMIO_SERIAL_PORT = "COM8"
56
+ $env:AAMIO_SERIAL_MAX_FRAME = "255"
57
+ $env:AAMIO_SERIAL_RATE = "200"
58
+ aamio partner add other KEY_OF_THE_OTHER
59
+ aamio transport bind other serial
60
+ aamio serve
61
+ ```
62
+
63
+ The largest frame and the rate are the modem's. Left out they are 64 bytes and
64
+ 200 bytes a second, which the smallest and the slowest of the modems these
65
+ lines were made for take. Numbers that have carried aamio:
66
+
67
+ | Medium | `AAMIO_SERIAL_MAX_FRAME` | `AAMIO_SERIAL_RATE` | Other |
68
+ |---|---|---|---|
69
+ | LoRa, 125 kHz, SF9 | 255 | 200 | |
70
+ | ESP-NOW | 240 | 20000 | `AAMIO_SERIAL_LINK_ACK=1` when the modem waits for the acknowledgement |
71
+ | Zigbee, one command a frame | 64 | 2000 | |
72
+
73
+ ### Modem lines
74
+
75
+ Each line ends in LF. A CR before LF is allowed. A frame is base64url without
76
+ padding. Both protocols accept `RX <frame> [meta]` from the modem. The decoded
77
+ frame must start with the two bytes `AF` and have 10 to
78
+ `AAMIO_SERIAL_MAX_FRAME` bytes. The host ignores optional RX metadata, such
79
+ as signal strength. Brackets below denote optional fields. Terminal words
80
+ match exactly. For example, `TXOKAY` is modem chatter.
81
+
82
+ | Protocol | Host requests transmission | Modem accepts | Modem reports failure |
83
+ |---|---|---|---|
84
+ | `legacy` (default) | `TX <frame>` | `TXOK [meta]` | `TXERR [reason]` |
85
+ | `tagged` | `TXID <id> <frame>` | `TXOKID <id> [meta]` | `TXERRID <id> [reason]` |
86
+
87
+ A positive modem answer reports local handoff to the medium. Set
88
+ `AAMIO_SERIAL_LINK_ACK=1` only when the firmware actually waits for a
89
+ link-layer acknowledgement before answering. In either case, only the
90
+ recipient's signed receipt confirms delivery of the aamio message. A timeout
91
+ returns `send_failed` even when the modem may already have sent the frame.
92
+
93
+ ### Legacy modems and outstanding answers
94
+
95
+ Legacy firmware must return exactly one terminal answer per `TX`, in order.
96
+ The host allows one outstanding transmission. Before writing it, the host
97
+ records that an answer is owed. Later frames wait until the old `TXOK` or
98
+ `TXERR` arrives, also after a timeout and on a port that went away and came
99
+ back. The old answer releases the port for another frame. The original
100
+ timed-out attempt keeps its failure result.
101
+
102
+ While the port is open, incoming `RX` frames can still be read.
103
+ `AAMIO_SERIAL_LATE` controls when the transport reports a missing answer as
104
+ link down. The transport goes on waiting.
105
+
106
+ ### An answer a legacy modem never gives
107
+
108
+ A modem that restarts in the middle of a `TX`, as one whose power dips when it
109
+ sends, never answers that `TX`. The transport cannot tell that from an answer
110
+ that is only late, and while it waits, nothing goes out.
111
+
112
+ The core ends that wait. It starts a transport again when it has given no room
113
+ for a minute. The new start finds the record of the owed answer, waits for it
114
+ for `AAMIO_SERIAL_ANSWER` seconds on the open port, and then takes it as
115
+ lost. About a minute and a half after an answer that never came, frames go
116
+ again with nothing to do by hand, and the core sends the message that was on
117
+ its way again. After three such stops in ten minutes the core leaves a
118
+ transport down until aamio is started again, as it does with any transport.
119
+
120
+ The record is an empty file `serial-pending-<digest>` in the transport's
121
+ working directory, where the digest is the SHA-256 of the configured port
122
+ string. The answer removes it, and so does a new start that has waited.
123
+
124
+ **What this leaves open.** An answer that comes after it was taken as lost is
125
+ let go when no frame waits. One that comes just after the next `TX` was
126
+ written is taken for that frame's. For a frame the modem refused to be
127
+ reported sent, the modem must give the old answer later than the
128
+ `AAMIO_SERIAL_ANSWER` seconds it has, counted again from the new start, and in
129
+ the moment between the next `TX` and its answer. The core takes no message as
130
+ arrived on a `TXOK`, only on the recipient's signed receipt, and sends again
131
+ what has none. Tagged mode closes this: there an answer names its attempt.
132
+
133
+ ### Tagged modems
134
+
135
+ Set `AAMIO_SERIAL_PROTOCOL=tagged` only with firmware that implements both
136
+ tagged terminal replies. The host generates a fresh ID of 32 lowercase
137
+ hexadecimal characters for every attempt, including a retry of the same
138
+ frame. The modem copies that exact ID into its single terminal reply. The
139
+ ID travels only between host and modem. It adds no bytes to the radio frame,
140
+ changes no recipient keys or receipts, and leaves `RX` unchanged.
141
+
142
+ Only a terminal reply bearing the active attempt's ID can complete it. A
143
+ timeout or disconnect retires the ID. Once the port is available another
144
+ attempt can use a fresh ID, even after a process restart. Late, duplicate
145
+ and untagged replies cannot acknowledge a new attempt. There is no automatic
146
+ downgrade to legacy. An incompatible modem can therefore time out every
147
+ request. Direct cable mode (`AAMIO_SERIAL_DIRECT=1`) rejects `tagged` because
148
+ there is no modem to answer.
149
+
150
+ ## Settings
151
+
152
+ The manifest declares these variables, and the core passes them on:
153
+
154
+ | Variable | Meaning |
155
+ |---|---|
156
+ | `AAMIO_SERIAL_PORT` | the serial port, as `COM8` or `/dev/ttyACM0`, or a pyserial URL as `socket://127.0.0.1:7070` |
157
+ | `AAMIO_SERIAL_BAUD` | its speed, 115200 if left out |
158
+ | `AAMIO_SERIAL_MAX_FRAME` | the largest frame in bytes, 10 to 65535, 64 if left out |
159
+ | `AAMIO_SERIAL_RATE` | bytes a second the medium carries. Left out: 200 through a modem, and what the port's speed carries straight |
160
+ | `AAMIO_SERIAL_DIRECT` | `1`: the port is a line straight to another aamio, and no modem answers |
161
+ | `AAMIO_SERIAL_PROTOCOL` | modem protocol, `legacy` by default. Select `tagged` only with compatible firmware and direct mode off. |
162
+ | `AAMIO_SERIAL_ANSWER` | seconds the modem has to answer a transmission, 1 to 25, 12 if left out |
163
+ | `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. |
164
+ | `AAMIO_SERIAL_LINK_ACK` | `1`: the modem returns a positive terminal answer only once the medium confirmed the frame. Not with `AAMIO_SERIAL_DIRECT` |
165
+ | `AAMIO_SERIAL_VISIBLE` | who sees that frames go: `range` (a radio, if left out), `local` (a cable) or `operator` |
166
+ | `AAMIO_SERIAL_DTR`, `AAMIO_SERIAL_RTS` | `on` or `off`: the line is set so before the port opens. Left out, the driver decides |
167
+
168
+ A setting the transport cannot start with, as a frame size out of range, ends
169
+ it with a line on standard error that names the variable. A port that does not
170
+ open is said once, and tried again every five seconds. A port that goes away,
171
+ as a modem pulled from USB, is reported. The transport takes frames again
172
+ when the port is back and any outstanding reply has been accounted for.
173
+
174
+ On Linux a serial port belongs to a group, usually `dialout`, and a user outside
175
+ it cannot open the port: the status then says `Permission denied`.
176
+ `sudo usermod -aG dialout $USER`, and a new login, gives the user the port.
177
+
178
+ `AAMIO_SERIAL_DTR` and `AAMIO_SERIAL_RTS` are for boards whose USB serial
179
+ restarts the chip when these lines change: set both `off`. Other boards send
180
+ nothing until DTR is on.
181
+
182
+ ## What it does not do
183
+
184
+ - **It counts no airtime.** A radio's rules for the band, as how much of an
185
+ hour it may send, how strongly and with what licence, are the modem's and
186
+ yours to keep. The manifest says `radio` among what the add-on uses, since a
187
+ modem may be one.
188
+ - **It hides nothing the medium shows.** With a radio, everyone in range sees
189
+ that frames go, how big they are and when. What the frames say, only the
190
+ recipient reads, since the core seals them.
191
+ - **It has no addresses.** A frame goes to everyone the modem or the line
192
+ reaches. A frame for somebody else is let go by the core of whoever hears it.
193
+ - **One port for each home.** Two modems on one machine need two homes.
194
+ - **A frame that comes back with the bytes it was sent with** within thirty
195
+ seconds is taken for an echo on the line and let go.
196
+
197
+ ## Where it runs
198
+
199
+ Python on Windows, macOS and Linux, with [pyserial](https://pypi.org/project/pyserial/),
200
+ which pip brings with it. It needs aamio 0.7.6 or later. aamio-php and aamio-js
201
+ have no serial transport; they list it and do not run it.
202
+
203
+ ## Tried
204
+
205
+ `tests/test_transport_serial.py` in aamio-python runs the transport as its own
206
+ process against a modem on 127.0.0.1, spoken to as the core speaks to it: a
207
+ probe, every setting, a frame sent, refused and never answered, an answer that
208
+ comes late and one that comes later than twice its time, a line of talk that
209
+ begins as an answer does, what the modem hears and says, a cancel, a stop, an
210
+ echo, and a port that does not open or goes away and comes back. The tests
211
+ also hold an old reply across a disconnect and a restart of the transport
212
+ process: a legacy start waits for the old reply as long as the modem has to
213
+ answer and then takes it as lost. Tagged tests distinguish previous and
214
+ current attempts, including retries of the same frame.
215
+ `tests/test_transport_serial_service.py` exercises sealed messages between
216
+ two homes through a pair of modems and over a direct line. With a terminal
217
+ answer dropped, it checks through the core that a legacy modem is back after
218
+ one restart of the transport, and that a tagged modem never stops.
219
+
220
+ The modems in the November 2026 field tests spoke the legacy lines over LoRa,
221
+ Zigbee and ESP-NOW. The rate and size examples above come from those tests.
222
+ Tagged firmware still needs verification on each physical modem.
223
+
224
+ `tests/test_transport_serial_pty.py` runs the transport on a real tty: a pty
225
+ opened by its name through pyserial's own port class, as `/dev/ttyUSB0` is, with
226
+ the other end played as a modem and as a cable. Frames both ways, a line that
227
+ comes in two pieces, noise and 240 000 bytes without the end of a line, a modem
228
+ that refuses and one that says nothing, DTR and RTS set, and a port that goes
229
+ away and comes back under its name. It has run on Linux, under WSL, with
230
+ Python 3.10. It is written for macOS as well and has not been run there, and
231
+ Windows has no pty.
232
+
233
+ That is the port code of the operating system, and no hardware: aamio-serial
234
+ has not yet been tried with a physical modem, a cable or a radio module.
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ # A transport under contract 3: aamio over a serial port, through a modem with ordered legacy replies or ID-matched replies, or straight to another
7
+ # aamio over a line that carries bytes as they are. A distribution of its own: `pip install aamio-serial` brings it,
8
+ # and `pip install aamio` alone does not. It lives in the aamio-python repository and is tested with the core, and the
9
+ # core finds it through the entry point below.
10
+ name = "aamio-serial"
11
+ dynamic = ["version"]
12
+ description = "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."
13
+ readme = "README.md"
14
+ requires-python = ">=3.10"
15
+ license = { text = "MIT" }
16
+ authors = [{ name = "AI SENSE AS" }]
17
+ # The core it is tested with, and pyserial for the port: also for a pyserial URL, as socket://, which the tests use.
18
+ dependencies = ["aamio>=0.7.6", "pyserial>=3.5"]
19
+ keywords = ["aamio", "agents", "transport", "serial", "modem", "radio", "lora"]
20
+
21
+ [project.urls]
22
+ Homepage = "https://aamio.at/docs/addons"
23
+ Source = "https://github.com/aisenseapi/aamio-python/tree/main/addons/serial"
24
+ Changelog = "https://github.com/aisenseapi/aamio-python/blob/main/addons/serial/CHANGELOG.md"
25
+ Issues = "https://github.com/aisenseapi/aamio-python/issues"
26
+
27
+ [project.entry-points."aamio.addons"]
28
+ serial = "aamio_serial"
29
+
30
+ [tool.setuptools.dynamic]
31
+ version = { attr = "aamio_serial.__version__" }
32
+
33
+ [tool.setuptools.packages.find]
34
+ where = ["src"]
35
+
36
+ [tool.setuptools.package-data]
37
+ aamio_serial = ["aamio-addon.json"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -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
+ }