Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
LinuxCNC HAL interface for Rust
Please consider becoming a sponsor so I may continue to maintain this crate in my spare time!
[Documentation](https://docs.rs/linuxcnc-
A safe, high-level interface to LinuxCNC's HAL (Hardware Abstraction Layer) module.
For lower level, unsafe use, see the linuxcnc-hal-sys
crate.
Development setup
bindgen
must be set up correctly. Follow the requirements section of its docs.
To run and debug any HAL components, the LinuxCNC simulator can be set up. There's a guide here for Linux Mint (and other Debian derivatives).
Project setup
This crate depends on the linuxcnc-hal-sys
crate which requires the LINUXCNC_SRC
environment variable toi be set to correctly generate the C bindings. The value must be the absolute path to the root of the LinuxCNC source code.
The version of the LinuxCNC sources must match the LinuxCNC version used in the machine control.
# Clone LinuxCNC source code into linuxcnc/
# Check out a specific version tag. This may also be a commit, but must match the version in use by the machine control.
&& &&
# Create your component lib
# Add LinuxCNC HAL bindings as a Cargo dependency with cargo-edit
LINUXCNC_SRC=/path/to/linuxcnc/source/code
Examples
Create a component with input and output
This example creates a component called "pins"
with a single input ("input-1"
) and output
pin ("output-1"
). It enters an infinite loop which updates the value of output-1
every
second. LinuxCNC convention dictates that component and pin names should be dash-cased
.
This example can be loaded into LinuxCNC with a .hal
file that looks similar to this:
loadusr -W /path/to/your/component/target/debug/comp_bin_name
net input-1 spindle.0.speed-out pins.input-1
net output-1 pins.output-1
Pins and other resources are registered using the [Resources
] trait. This example creates a
Pins
struct which holds the two pins. [HalComponent::new()
] handles component creation,
resources (pin, signal, etc) initialisation and UNIX signal handler registration.
use ;
use ;
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.