daqhats-rs 0.1.0

Rust bindings for the MCC DAQ HAT Library for Raspberry Pi data acquisition devices
Documentation
  • Coverage
  • 51.89%
    220 out of 424 items documented12 out of 21 items with examples
  • Size
  • Source code size: 594.96 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 8.73 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 25s Average build duration of successful builds.
  • all releases: 25s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • vincent-uden/daqhats-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • vincent-uden

daqhats-rs

Crates.io Documentation License

Rust bindings for the MCC DAQ HAT Library, providing access to Measurement Computing Corporation's data acquisition HAT devices for Raspberry Pi.

Supported Devices

  • MCC 118: 8-Channel Analog Input HAT
  • MCC 128: 8-Channel Analog Input HAT with thermocouple support
  • MCC 134: 4-Channel Thermocouple Input HAT
  • MCC 152: 2-Channel Analog Output / 8-Channel Digital I/O HAT
  • MCC 172: 2-Channel 24-bit Sigma-Delta A/D HAT

Platform Requirements

This library is designed for Raspberry Pi systems with MCC DAQ HAT hardware installed. The underlying C library requires:

  • Raspberry Pi OS (or compatible Linux distribution)
  • GPIO access and hardware drivers
  • libgpiod library

Installation

Add this to your Cargo.toml:

[dependencies]
daqhats-rs = "0.1"

Usage

use daqhats_rs::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // List all connected DAQ HATs
    let count = unsafe { hat_list(HatIDs_HAT_ID_ANY, std::ptr::null_mut()) };
    println!("Found {} DAQ HAT devices", count);

    if count > 0 {
        // Allocate memory for device info
        let mut devices = vec![HatInfo::default(); count as usize];
        unsafe {
            hat_list(HatIDs_HAT_ID_ANY, devices.as_mut_ptr());
        }

        for device in devices {
            println!("Device at address {}: ID = {}", device.address, device.id);
        }
    }

    Ok(())
}

Safety

This library provides direct bindings to the C library, so most functions are marked as unsafe. Users should:

Building

The library will automatically:

  1. Generate Rust bindings from C headers using bindgen
  2. On Raspberry Pi (ARM/AArch64): Compile the C library and link against it
  3. On other platforms: Generate bindings only (for development)

License

Licensed under either of:

at your option.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.