3 releases

0.2.5 Feb 4, 2024
0.2.4 Jan 26, 2024
0.2.3 Oct 12, 2022

#194 in Embedded development

Download history 7/week @ 2024-01-23 2/week @ 2024-02-13 17/week @ 2024-02-20 40/week @ 2024-02-27 8/week @ 2024-03-12 3/week @ 2024-03-26 38/week @ 2024-04-02 34/week @ 2024-04-16 21/week @ 2024-04-23

55 downloads per month

MIT license

30KB
390 lines

wake-rs

crates.io docs.rs MIT licensed

wake-rs is a library written in Rust for encoding/decoding Wake protocol.

Wake is a serial communication protocol highly optimized for microcontrollers. It based on SLIP protocol (https://datatracker.ietf.org/doc/html/rfc1055).

debug_print

Main features

  • unique start symbol
  • 7-bit addressing (optional)
  • CRC (8 or 16 bits)
  • low overhead

The protocol doesn't support:

  • error correction
  • compression

Frame structure:

Frame structure

Integrations

There are many architecture-specific implementations:

  • MCS-51
  • AVR
  • STM32
  • x86

in many languages:

  • C
  • C++
  • C#
  • Python
  • Rust

Examples

  1. Demo - basic usage
  2. Serial - how to use with serial port
  3. Relay shield - PC <-> device communication

Quick Start

Add to your Rust project:

cargo add systemd-wake

Create, encode and decode packet:

use wake_rs::{Decode, Encode};

fn main() {
    let wp = wake_rs::Packet {
        address: Some(0x12),
        command: 3,
        data: Some(vec![0x00, 0xeb]),
    };

    let encoded = wp.encode().unwrap();
    let decoded = encoded.decode();
}

Build library:

cargo build --release

Build examples:

cargo build --examples

Resources

Protocol description, libraries, and tools: http://www.leoniv.diod.club/articles/wake/wake.html

TODO

  • Use this library with a microcontroller (nostd)
  • Add a stream decoder (one byte per time with internal buffer)

License

Code released under the MIT License.

No runtime deps