Announcing linuxcnc-hal and linuxcnc-hal-sys

I'd like to announce two crates I've been working to integrate Rust HAL components into LinuxCNC: linuxcnc-hal (high-level interface) and linuxcnc-hal-sys (low-level interface).

I've written an introductory blog post to help people get started.

To make this announcements post a bit shinier, here's the code sample used in the post:

use linuxcnc_hal::{hal_pin::HalPinF64, HalComponentBuilder};
use std::{
    error::Error,
    thread,
    time::{Duration, Instant},
};

fn main() -> Result<(), Box<dyn Error>> {
    let mut builder = HalComponentBuilder::new("hello-comp")?;

    let input_1 = builder.register_input_pin::<HalPinF64>("input-1")?;

    let output_1 = builder.register_output_pin::<HalPinF64>("output-1")?;

    let comp = builder.ready()?;

    let start = Instant::now();

    while !comp.should_exit() {
        let time = start.elapsed().as_secs() as i32;

        output_1.set_value(time.into())?;

        println!("Input: {:?}", input_1.value());

        thread::sleep(Duration::from_millis(1000));
    }

    Ok(())
}
3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.