115 lines
2.4 KiB
Rust
115 lines
2.4 KiB
Rust
use scpi::error::Result;
|
|
use scpi::expression::numeric_list;
|
|
use scpi::expression::numeric_list::NumericList;
|
|
use scpi::format::{Arbitrary, Character};
|
|
use scpi::prelude::*;
|
|
use scpi::NumericValues;
|
|
|
|
use core::convert::{TryFrom, TryInto};
|
|
use scpi::ieee488::commands::*;
|
|
use scpi::scpi::commands::*;
|
|
use scpi::{
|
|
ieee488_cls,
|
|
ieee488_ese,
|
|
ieee488_esr,
|
|
ieee488_idn,
|
|
ieee488_opc,
|
|
ieee488_rst,
|
|
ieee488_sre,
|
|
ieee488_stb,
|
|
ieee488_tst,
|
|
ieee488_wai,
|
|
nquery,
|
|
//Helpers
|
|
qonly,
|
|
scpi_crate_version,
|
|
scpi_status,
|
|
scpi_system,
|
|
scpi_tree,
|
|
};
|
|
|
|
pub struct MyDevice;
|
|
|
|
pub struct HelloWorldCommand {}
|
|
impl Command for HelloWorldCommand {
|
|
qonly!();
|
|
|
|
fn query(
|
|
&self,
|
|
_context: &mut Context,
|
|
_args: &mut Tokenizer,
|
|
response: &mut ResponseUnit,
|
|
) -> Result<()> {
|
|
response.data(b"Hello world" as &[u8]).finish()
|
|
}
|
|
}
|
|
|
|
impl Device for MyDevice {
|
|
fn cls(&mut self) -> Result<()> {
|
|
Ok(())
|
|
}
|
|
|
|
fn rst(&mut self) -> Result<()> {
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
pub const TREE: &Node = scpi_tree![
|
|
// Create default IEEE488 mandated commands
|
|
ieee488_cls!(),
|
|
ieee488_ese!(),
|
|
ieee488_esr!(),
|
|
ieee488_idn!(b"manufacturer", b"model", b"serial", "0.1.2".as_bytes()),
|
|
ieee488_opc!(),
|
|
ieee488_rst!(),
|
|
ieee488_sre!(),
|
|
ieee488_stb!(),
|
|
ieee488_tst!(),
|
|
ieee488_wai!(),
|
|
// Create default SCPI mandated STATus subsystem
|
|
scpi_status!(),
|
|
// Create default SCPI mandated SYSTem subsystem
|
|
scpi_system!(),
|
|
//
|
|
scpi_crate_version!(),
|
|
//Test
|
|
Node {
|
|
name: b"ABORt",
|
|
handler: None,
|
|
optional: false,
|
|
sub: &[],
|
|
},
|
|
Node {
|
|
name: b"INITiate",
|
|
handler: None,
|
|
optional: false,
|
|
sub: &[
|
|
Node {
|
|
name: b"IMMediate",
|
|
handler: None,
|
|
optional: true,
|
|
sub: &[],
|
|
}
|
|
],
|
|
},
|
|
Node {
|
|
name: b"EXAMple",
|
|
optional: true,
|
|
handler: None,
|
|
sub: &[
|
|
Node {
|
|
name: b"HELLO",
|
|
optional: false,
|
|
handler: None,
|
|
sub: &[
|
|
Node {
|
|
name: b"WORLD",
|
|
optional: true,
|
|
handler: Some(&HelloWorldCommand {}),
|
|
sub: &[],
|
|
}
|
|
],
|
|
},
|
|
],
|
|
}
|
|
]; |