#spade #sprig #hackclub #read-write

spade-serial

Communications with Sprig devices over serial port

2 releases

new 0.1.1 Jan 5, 2025
0.1.0 Dec 8, 2024

#577 in Hardware support

Download history 146/week @ 2024-12-04 23/week @ 2024-12-11 2/week @ 2024-12-18 141/week @ 2025-01-01

174 downloads per month
Used in spade-upload

MIT license

14KB
222 lines

spade-serial

Rust crate to communicate with devices running Spade, like the Sprig console. It interacts with Read + Writers, like those provided by the serialport crate.
This crate can test whether the device is running a legacy Spade version and upload games.

Testing

This crate uses a mock serial device for unit testing which emulates the expected behavior of the device. Doc tests and integration tests test with actual devices. The environment variable TEST_DEVICE should be set to the device to use. For example:

TEST_DEVICE=/dev/cu.usbmodem14101 cargo test

lib.rs:

Communication with devices running Spade.

Issues commands to a device running Spade over a provided serial port. It can be used to upload games and check if the device is running a legacy Spade version. This crate is not thread safe.

First, get a Read + Writer for the serial port connected to the device. You can do this by using the serialport crate; this example uses the device at /dev/cu.usbmodem14101.

use std::time::Duration;

let mut port = serialport::new("/dev/cu.usbmodem14101", 115200)
    .timeout(Duration::from_millis(1000))
    .open()?;

Then, pass it to methods in this crate.

#
let legacy = spade_serial::is_running_legacy(&mut port).unwrap_or(false);

No runtime deps