microscpi 0.1.0-alpha.1

A Rust library for creating SCPI interfaces.
Documentation

This crate provides a simple interface to create an async SCPI command interpreter. It is especially suited for embedded devices.

Notable features are:

  • No heap memory allocation required.
  • Compile time creation of the SCPI command tree.
  • Support for async commmand handler functions.

Minimal Example

use microscpi as scpi;

pub struct ExampleInterface {
value: u64
}

#[scpi::interface]
impl<'a> ExampleInterface {
#[scpi(cmd = "SYSTem:VALue?")]
pub async fn system_value(&mut self) -> scpi::Result<'a> {
Ok(self.value.into())
}
}

#[tokio::main]
pub async fn main() {
let mut output = String::new();
let interface = ExampleInterface { value: 42 };

let mut context = scpi::Context::new(interface);
context.process(b"SYSTEM:VAL?\n", &mut output).await;

assert_eq!(output, "42\n");
}