Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions plugins/superstack/skills/s2-lua/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ name: s2-lua
description: >-
Writes and reviews Lua code for the Silicon Witchery S2 Module (nRF9151-based
LTE-M and GNSS cellular module) running on Superstack. Covers digital and
analog IO on PORTA-PORTF, I2C, SPI, UART, PWM, GPS, power and battery,
REST calls from the device, messages from the user's own project, sleep and
timing, and writing I2C sensor drivers from datasheets.
analog IO on PORTA-PORTF, I2C, SPI, UART, PWM, PDM microphones, WS2812
LEDs, GPS, power and battery, REST calls from the device, messages from the
user's own project, sleep and timing, and writing I2C sensor drivers from
datasheets.
Use when the user mentions the S2 Module, Superstack device code or Lua,
wiring sensors to an S2, or IoT code for Silicon Witchery hardware.
license: Apache-2.0
Expand Down Expand Up @@ -107,9 +108,9 @@ in [references/footguns.md](references/footguns.md).
2 KB, or one that arrives while the send queue is full, is dropped without
notice. Log lightly.
9. **Error models differ**: I2C calls return `{ success = boolean, ... }`, so
always check it. SPI, UART, analog and digital calls raise on failure, so
wrap risky sections in `pcall`. Handlers cannot yield, and an error inside
one crashes the program.
always check it. SPI, UART, PDM, WS2812, analog and digital calls raise on
failure, so wrap risky sections in `pcall`. Handlers cannot yield, and an
error inside one crashes the program.
10. **Buffered data dies with the run**: unsent data waits in a Lua table in
RAM, which is lost when the code ends, crashes, stops, restarts or is
replaced, and when the device restarts. A table that outgrows free memory
Expand Down
6 changes: 3 additions & 3 deletions plugins/superstack/skills/s2-lua/references/footguns.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Use this for remote configuration instead of uploading new code.
| API | Failure surface |
|---|---|
| `device.i2c.read/write/write_read` | returns a table with a `success` boolean. **Always check it** |
| `device.spi.*`, `device.uart.*`, `device.analog.*`, `device.digital.*` | no success flag. Bad arguments and failures raise |
| `device.spi.*`, `device.uart.*`, `device.pdm.*`, `device.ws2812.*`, `device.analog.*`, `device.digital.*` | no success flag. Bad arguments and failures raise |
| `device.i2c.scan` | returns nil. Each result line is a separate log |
| network calls | return `response, error`. Bad URLs, headers and oversized bodies raise |

Expand All @@ -213,8 +213,8 @@ end
## Handlers cannot yield, and their errors crash the code

This applies to `device.digital.assign_input_event`,
`device.uart.assign_read_event`, network callbacks and
`network.assign_message_event`:
`device.uart.assign_read_event`, `device.pdm.assign_read_event`, network
callbacks and `network.assign_message_event`:

- A handler runs between instructions of the main code and during
`device.sleep`, then the main code resumes.
Expand Down
Loading