From 010704fc40f5c2bf1bec0544d02c99b607475304 Mon Sep 17 00:00:00 2001 From: Scott Penrose Date: Mon, 26 Oct 2026 12:31:41 +1100 Subject: [PATCH] Improved language changes to content --- README.md | 86 ++++++++++++++++++++++------------------- docs/CLOUDLOOP.md | 52 ++++++++++++------------- docs/JSPR.md | 4 +- docs/TESTING.md | 37 +++++++----------- docs/boards/stamp_c3.md | 21 +++++----- 5 files changed, 98 insertions(+), 102 deletions(-) diff --git a/README.md b/README.md index 4e9dc53..5d68c42 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ The RockBLOCK 9704, Ground Control's Iridium Certus modem, on Zephyr: a module that builds Ground Control's own C library for any board with a UART, gives it the one thread it needs, and offers a small API, a shell -command and a devicetree binding. With it come host tools in Python and a -fake modem, so the same tests run against Ground Control's Python binding, +command and a devicetree binding. It also includes host tools in Python +and a fake modem, so the same tests run against Ground Control's Python binding, against Zephyr on `native_sim`, and against Zephyr on a board. The 9704 sends and receives IMT messages of up to 100 kB through the @@ -16,7 +16,7 @@ rockblock9704-zephyr is written and maintained by Scott Penrose projects that send data home by satellite: [WII6](https://wii6.au/), a wave-measuring buoy, and [OGLAS](https://oglas.au/), a fleet of LoRa sensors, repeaters and hubs. -Both run it, and neither is needed to use it. +Both projects run it. The module does not depend on either. The source lives at [gitea.sh3d.com.au/Sh3d/rockblock9704-zephyr](https://gitea.sh3d.com.au/Sh3d/rockblock9704-zephyr) @@ -45,36 +45,41 @@ and `CMakeLists.txt` compiles its portable core. What each part does: The library's source shows several things a caller has to work around; `docs/JSPR.md`, section 8, lists them all. The ones this module handles: -- **Provisioning is asked once and kept for good**, a miss included. A - modem provisioned after the first send would refuse every topic until - a reboot. Before a send whose topic is not in what the library kept, - and after the modem refuses one, the module clears the library's cache - so it asks again: one free JSPR round trip. -- **The blocking calls stop working once callbacks are registered.** The - module uses the async path only. -- **A query during a send swallows the modem's segment requests**, since - the reader discards lines it is not waiting for. Info and signal - requests are refused with `-EBUSY` while a message is moving. -- **No locking.** Every library call is on the worker thread. -- **A send has no timeout, and the queue's count survives `rbEnd`.** The - async path only reacts to lines from the modem, so a modem that goes - quiet mid-send leaves the message in flight for good; `rb9704_cancel` - asks the modem to abandon it. `rbBegin` empties the queue but not the - count of it, which would make every send after a stuck one queue - without transmitting; `rb9704_begin` zeroes the count. -- **A line with no status code reads past the library's buffer**, and on - a board it crashed. A modem talks before `rb9704_begin` opens the - library: its boot lines, once its power pins bring it up. The module +- **Provisioning cache.** The library asks the modem for its provisioning + once and keeps the answer for the rest of the process, even when the + topic it wanted was not in it. A modem provisioned after the first send + would be refused on every topic until a reboot. Before a send whose + topic is not in what the library kept, and after the modem refuses one, + the module clears the library's cache so it asks again: one free JSPR + round trip. +- **Blocking calls.** They stop working once callbacks are registered, so + the module uses the async path only. +- **Queries during a send.** The reader discards lines it is not waiting + for, so a query during a send swallows the modem's segment requests. + Info and signal requests are refused with `-EBUSY` while a message is + moving. +- **Locking.** The library has none, so every library call is on the + worker thread. +- **Send timeout and queue count.** The async path only reacts to lines + from the modem, so a modem that goes quiet mid-send leaves the message + in flight for good; `rb9704_cancel` asks the modem to abandon it. + `rbBegin` empties the queue but not the count of it, which would make + every send after a stuck one queue without transmitting; `rb9704_begin` + zeroes the count. +- **Lines without a status code.** One of those reads past the library's + buffer, and on a board it crashed. A modem sends lines before + `rb9704_begin` opens the library: its boot lines, once its power pins + bring it up. The module listens on the UART from boot and throws those bytes away, so a small hardware FIFO never overflows into fragments of old lines, and when the library opens part-way through a line the rest of that line is thrown away too. Others are for upstream to fix, and are listed in `docs/JSPR.md` for that: -`setState` waits for a misspelt target, a line with no status code reads -past its buffer (the module keeps the causes it knows of away from it), -MT segment data is cut at 1446 characters, and the Python binding never -releases the GIL. +`setState` waits for a misspelt target, the overread of a line with no +status code remains for any cause the module does not know of (section +8.2), MT segment data is cut at 1446 characters, and the Python binding +never releases the GIL. ## Using it @@ -91,7 +96,7 @@ library, pinned, at the path the module looks in, and nothing else: - rockblock9704 ``` -In the board overlay, a node on the modem's UART. The pins are optional; +The board overlay needs a node on the modem's UART. The pins are optional; without them the modem is taken to be powered. I_EN starts and stops the modem; P_EN is the supercapacitor charge enable and is active low, so `GPIO_ACTIVE_LOW`, and it can be left unconnected: @@ -110,16 +115,17 @@ modem; P_EN is the supercapacitor charge enable and is active low, so }; ``` -**USB-C and the header are the same serial port.** The 9704's USB-C goes -through an FTDI chip to the modem's UART, on the same lines as the -header's TX and RX. With the USB-C cable plugged in, that chip drives the -modem's RX, and a board on the header can hear the modem but not reach -it: `rb9704_begin` fails with `-EIO`, and the computer on USB gets no -answer either. Unplug the USB-C and power the 9704 from the header; a -board's 5 V pin will do, as the modem draws a few hundred mA +The 9704's USB-C goes through an FTDI chip to the modem's UART, on the +same lines as the header's TX and RX, so the two are one serial port. +With the USB-C cable plugged in, that chip drives the modem's RX, and a +board on the header can receive from the modem but not send to it: +`rb9704_begin` fails with `-EIO`, and the computer on USB gets no answer +either. Unplug the USB-C and power the 9704 from the header; a board's +5 V pin will do, as the modem draws a few hundred mA (`docs/boards/stamp_c3.md`). -`CONFIG_RB9704` follows the node. Then ``: +`CONFIG_RB9704` is selected when the node is present. The API is in +``: ```c static void mo_done(uint16_t topic, uint16_t id, int result, void *user) @@ -195,9 +201,9 @@ real 9704 from Python and from `native_sim`. ## Boards -Any board with a free UART, on any architecture Zephyr runs on. The -library is portable C and the module has nothing tied to one CPU. The -sample has overlays for: +The module runs on any board with a free UART, on any architecture +Zephyr runs on. The library is portable C and the module has nothing tied +to one CPU. The sample has overlays for: | Board | CPU | Run on | | --- | --- | --- | @@ -227,7 +233,7 @@ docs/JSPR.md the protocol as the library speaks docs/CLOUDLOOP.md account to first message docs/TESTING.md the tests and how to run them docs/boards/ notes for one board each: pins, setup -west.yml the pins +west.yml Ground Control's library, pinned ``` ## Credits diff --git a/docs/CLOUDLOOP.md b/docs/CLOUDLOOP.md index b3a4994..a3208aa 100644 --- a/docs/CLOUDLOOP.md +++ b/docs/CLOUDLOOP.md @@ -1,9 +1,10 @@ # Cloudloop and a RockBLOCK 9704, from the box to a message -How to get a RockBLOCK 9704 from its box to a message seen on the -internet, from a computer over its USB-C port: the account, the token, -topics, provisioning, and the order to test things in. `rb9704` is the -command line in `python/` (`python/README.md` has every verb). +A RockBLOCK 9704 comes out of the box with an activation card and no +Cloudloop account behind it. This is how to get from there to a message +seen on the internet, from a computer over the modem's USB-C port. +`rb9704` is the command line in `python/` (`python/README.md` has every +verb). Written 2026-10-09 from Ground Control's and Cloudloop's documentation and the library's source. `rb9704 info` and the free JSPR verbs have run @@ -71,7 +72,8 @@ serves a project. ### 3. The API token The API is how the tool reads messages and sends MT, and how the shore -side will. A token is asked for, not made: +side will. Ground Control issues the token; there is no page to generate +one: 1. Email for a Cloudloop **platform API token** for the account. Ask for one that can send MT: `DoSendImtMessage` needs @@ -139,9 +141,9 @@ rb9704 --log provision.jsonl provision ``` This asks the modem for its signal and its provisioning every 30 s and -stops when topics appear, printing them. It talks JSPR directly, because -the library only asks for provisioning when it is about to send, and -asking this way costs nothing. +stops when topics appear, printing them. It sends the JSPR requests itself, +because the library only asks for provisioning when it is about to send, +and asking this way costs nothing. ## The order to test in @@ -155,7 +157,7 @@ money; the tool asks before each one, and `--yes` skips the question. `rb9704 ports`. The 9704 is the FT234XD, listed first. 3. **Identity, indoors.** `rb9704 info` gives hardware and firmware versions, serial, IMEI, ICCID, whether the SIM is present and - talking, and the board temperature. Record the IMEI and ICCID against + connected, and the board temperature. Record the IMEI and ICCID against the Thing in Cloudloop. 4. **Signal, outdoors.** `rb9704 signal --watch 600` reads the bars (0 to 5) every 5 s for ten minutes and ends with how often @@ -197,30 +199,24 @@ version, SIM, operational state). In order of likelihood: a front-panel port), or the supercapacitor is still charging. - **Something odd.** `rb9704 jspr --setup 'GET hwInfo {}' 'GET simStatus {}'` shows the modem's own answers; a 4xx code names - the problem (`409` unauthorized, `410` SIM not configured, `418` not + the problem (`409` unauthorised, `410` SIM not configured, `418` not provisioned). ## What has run -On 2026-10-25, a RockBLOCK 9704 (firmware v1.5.14) on the header pins of -an M5Stamp-C3 running the shell sample, under open sky, driven over WiFi -by `rb9704 send` in the Zephyr shell (`boards/stamp_c3.md`): +On 2026-10-25 a RockBLOCK 9704 (firmware v1.5.14) on the header pins of +an M5Stamp-C3, running the shell sample under open sky, was found already +provisioned with topics 244 (RAW) and 313 to 317, the Cloudloop colours, +and sent two messages on topic 244 that arrived in Cloudloop whole. The +library only asks the modem for its provisioning when it is about to +send, so the first send is when the module, and `rb9704 status`, learn +the topics. The board, its pins and the overnight run are in +`boards/stamp_c3.md`. -- **Provisioning.** Already done when first asked: topics 244 (RAW) and - 313 to 317, the Cloudloop colours. The library only asks the modem - when it is about to send, so the first send is when the module, and - `rb9704 status`, learn the topics. -- **MO.** Two messages on topic 244, `Stamp-C3 says hi` (16 bytes) and - `Stamp-C3 P_EN low` (17 bytes). Each was with the network 6 to 10 s - after the modem took it, with 3 to 4 bars, and each arrived in - Cloudloop whole. -- **How Cloudloop shows a message.** The same bytes twice: the message - data in Base64 (`U3RhbXAtQzMgUF9FTiBsb3c`, the padding `=` left off) - and the payload in hex (`5374616D702D433320505F454E206C6F77`). The - CRC the library adds on the way out is checked and gone. - -The modem then stayed begun overnight, about 11 h 54 min, still -provisioned and answering in the morning. +Cloudloop shows a message's bytes twice: the message data in Base64 +(`U3RhbXAtQzMgUF9FTiBsb3c`, the padding `=` left off) and the payload in +hex (`5374616D702D433320505F454E206C6F77`). The CRC the library adds on +the way out is checked and gone. Not yet: MT, a session, and this command line's own `provision` and `send` against a real modem. diff --git a/docs/JSPR.md b/docs/JSPR.md index b0386ba..3180554 100644 --- a/docs/JSPR.md +++ b/docs/JSPR.md @@ -328,7 +328,7 @@ Source: `src/jspr_command.c:269-281`, parse `src/jspr.c:934-1007`. - The `messageProvisioning` callback (Python: `set_message_provisioning_callback`) fires only here, after the GET (`src/rockblock_9704.c:1181-1187`). -### 2.12 PUT serviceConfig (resync), with its state dance +### 2.12 PUT serviceConfig (resync), and the state changes around it `rbResyncServiceConfig()` (`src/rockblock_9704.c:1064-1120`): @@ -721,7 +721,7 @@ Everything else is ignored. solicited `200` first, then `299`s. 2. **A line with no 3-digit code in 200..500** makes the code scan run off the end of the line through the zeroed buffer, then `memmove` with a - negative length cast to `size_t` (`src/jspr.c:89-113`). Expect a crash. + negative length cast to `size_t` (`src/jspr.c:89-113`). The result is a crash. Never send banners, prompts or blank-ish lines of 9 bytes or more. On an M5Stamp-C3 it did crash (2026-10-25), when the UART's FIFO had overflowed and handed over fragments of old lines. rockblock9704-zephyr diff --git a/docs/TESTING.md b/docs/TESTING.md index a6784a2..180b277 100644 --- a/docs/TESTING.md +++ b/docs/TESTING.md @@ -1,7 +1,7 @@ # Testing -One fake modem, three places to run the code against it, and a few free -checks against a real modem. +The tests run one fake modem against the code in three places, and a few +free checks against a real modem. | Level | What runs | Against | Needs | | --- | --- | --- | --- | @@ -55,11 +55,11 @@ Every option has an environment variable as well: `RB9704_ZEPHYR_EXE`, On native_sim the modem UART is a `zephyr,native-tty-uart` node (`samples/shell/boards/native_sim.overlay`); the tests give it the fake's pty with `-modem_uart_port=`. The same option takes a real modem's -`/dev/ttyUSB0`, which is how host Zephyr talks to real hardware. +`/dev/ttyUSB0`, which is how host Zephyr reaches real hardware. ## The rig: two boards, one wire -No USB-serial adapter to hand? Two boards with a UART wired between them +Without a USB-serial adapter, two boards with a UART wired between them will do: one runs the sample, the other runs `tests/rig/bridge`, which copies bytes between that UART and its own USB serial port, where the fake answers. @@ -84,8 +84,8 @@ toggle RTS on its USB port, or press reset, before the tests. ## Out of doors: the shell over WiFi -A real modem needs the sky, and the sky is rarely where the USB cable -reaches. `samples/shell/overlay-wifi.conf` puts the same shell on telnet, +A real modem needs a view of the sky, which is usually further than a +USB cable goes. `samples/shell/overlay-wifi.conf` puts the same shell on telnet, on any ESP32 board, so the board needs only power: ```sh @@ -126,8 +126,8 @@ and the WiFi commands. The board overlays for the M5Stamp-C3, ESP32-S3-DevKitC, ESP32 DevKitC and NUCLEO-U575ZI-Q wire all three control lines, so `rb9704 begin` -starts the modem through I_EN and waits for I_BTD to say it has booted, -and `rb9704 power off` waits for I_BTD to say it has shut down. +starts the modem through I_EN and waits for I_BTD to go high, and +`rb9704 power off` waits for I_BTD to go low. | 9704 header | M5Stamp-C3 | ESP32-S3-DevKitC | ESP32 DevKitC | NUCLEO-U575ZI-Q | | --- | --- | --- | --- | --- | @@ -135,7 +135,7 @@ and `rb9704 power off` waits for I_BTD to say it has shut down. | 13, TXD (board RX) | GPIO5 | GPIO18 | GPIO16 | PD9 | | 3, I_EN | GPIO6 | GPIO4 | GPIO25 | PF14 (D4) | | 7, I_BTD | GPIO7 | GPIO5 | GPIO26 | PF13 (D7) | -| 6, P̅_E̅N̅, active low, optional | GPIO10 | GPIO6 | GPIO27 | PF15 (D2) | +| 6, P_EN, active low, optional | GPIO10 | GPIO6 | GPIO27 | PF15 (D2) | | 1, 4 or 10, GND | GND | GND | GND | GND | The modem's supply goes to V_IN+ and V_IN- (pins 15 and 16), 4.0 to @@ -167,18 +167,11 @@ binding 1.0.2: | a real 9704 (firmware v1.5.14), binding and native_sim, free checks | 2 | all pass | On 2026-10-25, the M5Stamp-C3 (ESP32-C3, RISC-V) with the shell over -WiFi, and a real 9704 on its header pins, TX and RX only, powered from -the Stamp's 5V: `begin`, `info` and `signal` all answer, nothing dropped -(`boards/stamp_c3.md`). - -Later the same day, under open sky with P_EN unconnected: provisioned -with topics 244 and 313 to 317, and one message, 16 bytes on topic 244, -sent from the Stamp's shell over telnet and received in Cloudloop. The -first message through a real modem and satellite. - -Then the reworked control pins outside, P_EN wired and active low: a -second message, 17 bytes on topic 244, received in Cloudloop, and the -modem left running overnight, up and answering for about 11 h 54 min with -no drop and no reboot of the Stamp. +WiFi and a real 9704 on its header pins, under open sky: `begin`, `info` +and `signal` answer, the modem was provisioned, two messages on topic +244 were received in Cloudloop, and the modem stayed up overnight with +all three control lines wired. Those were the first messages through a +real modem and a satellite. `boards/stamp_c3.md` has the pins, the runs +and the P_EN fault found on the way. Not yet: an MT message down to the board. diff --git a/docs/boards/stamp_c3.md b/docs/boards/stamp_c3.md index df26370..cc68893 100644 --- a/docs/boards/stamp_c3.md +++ b/docs/boards/stamp_c3.md @@ -18,7 +18,7 @@ The overlay is `samples/shell/boards/stamp_c3.overlay`, with | GPIO5, `uart1` RX | 13, TXD | | | GPIO6 | 3, I_EN | starts and stops the modem | | GPIO7 | 7, I_BTD | high once booted, low once shut down; waited on both ways | -| GPIO10 | 6, P̅_E̅N̅ | the supercapacitor charge enable, **active low**; optional | +| GPIO10 | 6, P_EN | the supercapacitor charge enable, **active low**; optional | | GND | 1, 4 or 10, GND | signal ground | | | 15, V_IN+ and 16, V_IN- | 4.0 to 5.3 V, 500 mA: see Power | | GPIO2 | | the RGB LED, an SK6812, on the board | @@ -32,9 +32,9 @@ GPIO18 and GPIO19 (USB). The 9704's header UART and its USB-C port are the same serial lines. With USB-C plugged in, the 9704's FTDI chip is powered and drives the modem's -RX, and a board on the header cannot talk over it: the modem answers -nobody, the computer on USB included. Its TX still reaches the header, so -a board can listen alongside USB, but not send. +RX, and a board on the header cannot drive the line, so the modem gets +no request from either side, the computer on USB included. Its TX still +reaches the header, so a board can receive alongside USB, but not send. So the 9704 is powered from the header with its USB-C unplugged, on V_IN+ (pin 15) and V_IN- (pin 16): 4.0 to 5.3 V, and the board limits @@ -54,9 +54,10 @@ that is not there: No edit needed: `-DEXTRA_DTC_OVERLAY_FILE=no-control-pins.overlay` takes all three out at build time (below). - I_EN: `rb9704 power off` and `begin` over telnet restart a modem that - has hung, with nobody walking out to it. The one most worth wiring. -- I_BTD as well: start-up and shutdown wait for the modem to say it has - followed I_EN, as Ground Control's page asks, not a fixed 4 s + has hung, with nobody walking out to it. It is the line most worth + wiring. +- I_BTD as well: start-up and shutdown wait for I_BTD to follow I_EN, + as Ground Control's page asks, not a fixed 4 s (`boot-delay-ms`). Moving I_EN back before I_BTD has followed "may result in damage to the 9704 module". - P_EN adds nothing for a modem on V_IN+: left open, the board's @@ -164,8 +165,8 @@ Nothing on the button costs airtime. The LED runs at 24 of 255 flash. 2. With the modem wired: a short press goes white, then red, yellow or green with the signal. -3. Over telnet: `rb9704 spy on`, `rb9704 info`, `rb9704 signal`. All - free. +3. Over telnet: `rb9704 spy on`, `rb9704 info`, `rb9704 signal`. None + of the three costs airtime. A fake modem (`rb9704-fake`) on a USB-serial adapter in the modem's place has no I_BTD: tie GPIO7 to 3.3 V for those runs. @@ -181,7 +182,7 @@ has no I_BTD: tie GPIO7 to 3.3 V for those runs. | under open sky: the constellation visible and 3 to 5 bars within seconds of `begin` | works (2026-10-25) | | staying up while active | failed with P_EN driven the wrong way: see below; with P_EN unconnected, up and answering throughout (2026-10-25) | | provisioning, and a message sent | works (2026-10-25): provisioned with 244 and 313 to 317, and "Stamp-C3 says hi", 16 bytes on topic 244, sent in 10 s with 3 to 4 bars and received in Cloudloop | -| the reworked control pins outside: I_EN and I_BTD in Ground Control's sequence, P_EN wired and `GPIO_ACTIVE_LOW` | works (2026-10-25): "Stamp-C3 P_EN low", 17 bytes on topic 244, sent in 6 s and received in Cloudloop; left out overnight, the modem was up and answering for about 11 h 54 min with no drop and the Stamp did not reboot, where P_EN the wrong way stopped it within 5 minutes every time | +| the reworked control pins outside: I_EN and I_BTD in Ground Control's sequence, P_EN wired and `GPIO_ACTIVE_LOW` | works (2026-10-25): "Stamp-C3 P_EN low", 17 bytes on topic 244, sent in 6 s and received in Cloudloop, and the modem up overnight; see below | | an MT message down to the board | not yet | | the LED and button | the button's short press works; the busy colour reads orange, not white, at this brightness |