Expand description
§daqhats-rs
Rust bindings for the MCC DAQ HAT Library, providing access to Measurement Computing Corporation’s data acquisition HAT devices for Raspberry Pi.
This library provides safe Rust bindings to the C library for MCC DAQ HAT devices including:
- 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 Support
This library is designed to work on Raspberry Pi systems with the appropriate MCC DAQ HAT hardware installed. The underlying C library requires GPIO access and specific hardware drivers that are only available on Raspberry Pi.
§Usage
use daqhats_rs::*;
// List all connected DAQ HATs
let count = unsafe { hat_list(HatIDs_HAT_ID_ANY as u16, std::ptr::null_mut()) };
println!("Found {} DAQ HAT devices", count);
// Check for MCC 118 devices specifically
let mcc118_count = unsafe { hat_list(HatIDs_HAT_ID_MCC_118 as u16, std::ptr::null_mut()) };
if mcc118_count > 0 {
println!("Found {} MCC 118 devices", mcc118_count);
}
§Safety
This library provides direct bindings to the C library, so most functions are marked as unsafe
.
Users should be familiar with the MCC DAQ HAT C library documentation and ensure proper
error handling when using these functions.
Structs§
- HatInfo
- Contains information about a specific board.
- MCC118
Device Info - MCC 118 constant device information.
- MCC128
Device Info - MCC 128 constant device information.
- MCC134
Device Info - MCC 134 constant device information.
- MCC152
Device Info - MCC 152 constant device information.
- MCC172
Device Info - MCC 172 constant device information.
- __
fsid_ t
Constants§
- A_
IN_ MODE_ BIT_ MASK - A_
IN_ MODE_ BIT_ POS - A_
IN_ MODE_ DIFF_ FLAG - A_
IN_ MODE_ SE_ FLAG - A_
IN_ RANGE_ BIP_ 1V_ FLAG - A_
IN_ RANGE_ BIP_ 2V_ FLAG - A_
IN_ RANGE_ BIP_ 5V_ FLAG - A_
IN_ RANGE_ BIP_ 10V_ FLAG - A_
IN_ RANGE_ BIT_ MASK - A_
IN_ RANGE_ BIT_ POS - Analog
Input Mode_ A_ IN_ MODE_ DIFF - Differential
- Analog
Input Mode_ A_ IN_ MODE_ SE - Single-ended
- Analog
Input Range_ A_ IN_ RANGE_ BIP_ 1V - +/- 1 V
- Analog
Input Range_ A_ IN_ RANGE_ BIP_ 2V - +/- 2 V
- Analog
Input Range_ A_ IN_ RANGE_ BIP_ 5V - +/- 5 V
- Analog
Input Range_ A_ IN_ RANGE_ BIP_ 10V - +/- 10 V
- COMMON_
MODE_ TC_ VALUE - DIOConfig
Item_ DIO_ DIRECTION - Configure channel direction
- DIOConfig
Item_ DIO_ INPUT_ INVERT - Configure input inversion
- DIOConfig
Item_ DIO_ INPUT_ LATCH - Configure input latching
- DIOConfig
Item_ DIO_ INT_ MASK - Configure interrupt mask
- DIOConfig
Item_ DIO_ OUTPUT_ TYPE - Configure output type
- DIOConfig
Item_ DIO_ PULL_ CONFIG - Configure pull-up/down resistor
- DIOConfig
Item_ DIO_ PULL_ ENABLE - Enable pull-up/down resistor
- HatI
Ds_ HAT_ ID_ ANY - Match any DAQ HAT ID in hat_list()(@ref hat_list)
- HatI
Ds_ HAT_ ID_ MCC_ 118 - MCC 118 ID
- HatI
Ds_ HAT_ ID_ MCC_ 128 - MCC 128 ID
- HatI
Ds_ HAT_ ID_ MCC_ 134 - MCC 134 ID
- HatI
Ds_ HAT_ ID_ MCC_ 152 - MCC 152 ID
- HatI
Ds_ HAT_ ID_ MCC_ 172 - MCC 172 ID
- HatI
Ds_ HAT_ ID_ MCC_ 118_ BOOTLOADER - MCC 118 in firmware update mode ID
- INT8_
MAX - INT8_
MIN - INT16_
MAX - INT16_
MIN - INT32_
MAX - INT32_
MIN - INTPTR_
MAX - INTPTR_
MIN - INT_
FAST8_ MAX - INT_
FAST8_ MIN - INT_
FAST16_ MAX - INT_
FAST16_ MIN - INT_
FAST32_ MAX - INT_
FAST32_ MIN - INT_
LEAS T8_ MAX - INT_
LEAS T8_ MIN - INT_
LEAS T16_ MAX - INT_
LEAS T16_ MIN - INT_
LEAS T32_ MAX - INT_
LEAS T32_ MIN - MAX_
NUMBER_ HATS - OPEN_
TC_ VALUE - OPTS_
CONTINUOUS - OPTS_
DEFAULT - OPTS_
EXTCLOCK - OPTS_
EXTTRIGGER - OPTS_
NOCALIBRATEDATA - OPTS_
NOSCALEDATA - OVERRANGE_
TC_ VALUE - PTRDIFF_
MAX - PTRDIFF_
MIN - Result
Code_ RESULT_ BAD_ PARAMETER - A parameter passed to the function was incorrect.
- Result
Code_ RESULT_ BUSY - The device is busy.
- Result
Code_ RESULT_ COMMS_ FAILURE - Could not communicate with the device.
- Result
Code_ RESULT_ INVALID_ DEVICE - The device at the specified address is not the correct type.
- Result
Code_ RESULT_ LOCK_ TIMEOUT - There was a timeout while obtaining a resource lock.
- Result
Code_ RESULT_ RESOURCE_ UNAVAIL - A needed resource was not available.
- Result
Code_ RESULT_ SUCCESS - Success, no errors
- Result
Code_ RESULT_ TIMEOUT - There was a timeout accessing a resource.
- Result
Code_ RESULT_ UNDEFINED - Some other error occurred.
- SIG_
ATOMIC_ MAX - SIG_
ATOMIC_ MIN - SIZE_
MAX - STATUS_
BUFFER_ OVERRUN - STATUS_
HW_ OVERRUN - STATUS_
RUNNING - STATUS_
TRIGGERED - Source
Type_ SOURCE_ LOCAL - Use a local-only source.
- Source
Type_ SOURCE_ MASTER - Use a local source and set it as master.
- Source
Type_ SOURCE_ SLAVE - Use a separate master source.
- TcTypes_
TC_ DISABLED - Input disabled
- TcTypes_
TC_ TYPE_ B - B type
- TcTypes_
TC_ TYPE_ E - E type
- TcTypes_
TC_ TYPE_ J - J type
- TcTypes_
TC_ TYPE_ K - K type
- TcTypes_
TC_ TYPE_ N - N type
- TcTypes_
TC_ TYPE_ R - R type
- TcTypes_
TC_ TYPE_ S - S type
- TcTypes_
TC_ TYPE_ T - T type
- Trigger
Mode_ TRIG_ ACTIVE_ HIGH - Start the scan any time TRIG is high.
- Trigger
Mode_ TRIG_ ACTIVE_ LOW - Start the scan any time TRIG is low.
- Trigger
Mode_ TRIG_ FALLING_ EDGE - Start the scan on a falling edge of TRIG.
- Trigger
Mode_ TRIG_ RISING_ EDGE - Start the scan on a rising edge of TRIG.
- UINT8_
MAX - UINT16_
MAX - UINT32_
MAX - UINTPTR_
MAX - UINT_
FAST8_ MAX - UINT_
FAST16_ MAX - UINT_
FAST32_ MAX - UINT_
LEAS T8_ MAX - UINT_
LEAS T16_ MAX - UINT_
LEAS T32_ MAX - WINT_
MAX - WINT_
MIN - _ATFILE_
SOURCE - _BITS_
STDINT_ INTN_ H - _BITS_
STDINT_ LEAST_ H - _BITS_
STDINT_ UINTN_ H - _BITS_
TIME64_ H - _BITS_
TYPESIZES_ H - _BITS_
TYPES_ H - _BITS_
WCHAR_ H - _DEFAULT_
SOURCE - _FEATURES_
H - _POSIX_
C_ SOURCE - _POSIX_
SOURCE - _STDC_
PREDEF_ H - _STDINT_
H - _SYS_
CDEFS_ H - __
FD_ SETSIZE - __
GLIBC_ MINOR__ - __
GLIBC_ USE_ C2X_ STRTOL - __
GLIBC_ USE_ DEPRECATED_ GETS - __
GLIBC_ USE_ DEPRECATED_ SCANF - __
GLIBC_ USE_ IEC_ 60559_ BFP_ EXT - __
GLIBC_ USE_ IEC_ 60559_ BFP_ EXT_ C2X - __
GLIBC_ USE_ IEC_ 60559_ EXT - __
GLIBC_ USE_ IEC_ 60559_ FUNCS_ EXT - __
GLIBC_ USE_ IEC_ 60559_ FUNCS_ EXT_ C2X - __
GLIBC_ USE_ IEC_ 60559_ TYPES_ EXT - __
GLIBC_ USE_ ISOC2X - __
GLIBC_ USE_ LIB_ EXT2 - __
GLIBC__ - __
GNU_ LIBRARY__ - __
HAVE_ GENERIC_ SELECTION - __
INO_ T_ MATCHES_ INO64_ T - __
KERNEL_ OLD_ TIMEVAL_ MATCHES_ TIMEVA L64 - __
LDOUBLE_ REDIRECTS_ TO_ FLOA T128_ ABI - __
OFF_ T_ MATCHES_ OFF64_ T - __
RLIM_ T_ MATCHES_ RLIM64_ T - __
STATFS_ MATCHES_ STATF S64 - __
STDC_ IEC_ 559_ COMPLEX__ - __
STDC_ IEC_ 559__ - __
STDC_ IEC_ 60559_ BFP__ - __
STDC_ IEC_ 60559_ COMPLEX__ - __
STDC_ ISO_ 10646__ - __
SYSCALL_ WORDSIZE - __
TIMESIZE - __
USE_ ATFILE - __
USE_ FORTIFY_ LEVEL - __
USE_ ISOC11 - __
USE_ ISOC95 - __
USE_ ISOC99 - __
USE_ MISC - __
USE_ POSIX - __
USE_ POSI X2 - __
USE_ POSI X199309 - __
USE_ POSI X199506 - __
USE_ POSIX_ IMPLICITLY - __
USE_ XOPE N2K - __
USE_ XOPE N2K8 - __
WORDSIZE - __
WORDSIZE_ TIME64_ COMPA T32 - __
glibc_ c99_ flexarr_ available
Functions§
- check_
result - Convert a C result code to a Rust Result
- error_
message - Get a human-readable error message for a result code (fallback for non-ARM systems)
- hat_
error_ ⚠message - Return a text description for a DAQ HAT result code.
- hat_
interrupt_ ⚠callback_ disable - Disable interrupt callbacks.
- hat_
interrupt_ ⚠callback_ enable - Enable an interrupt callback function.
- hat_
interrupt_ ⚠state - Read the current interrupt status.
- hat_
list ⚠ - Return a list of detected DAQ HAT boards.
- hat_
wait_ ⚠for_ interrupt - Wait for an interrupt to occur.
- mcc118_
a_ ⚠in_ read - @brief Perform a single reading of an analog input channel and return the value.
- mcc118_
a_ ⚠in_ scan_ actual_ rate - @brief Read the actual sample rate per channel for a requested sample rate.
- mcc118_
a_ ⚠in_ scan_ buffer_ size - @brief Returns the size of the internal scan data buffer.
- mcc118_
a_ ⚠in_ scan_ channel_ count - @brief Return the number of channels in the current analog input scan.
- mcc118_
a_ ⚠in_ scan_ cleanup - @brief Free analog input scan resources after the scan is complete.
- mcc118_
a_ ⚠in_ scan_ read - @brief Reads status and multiple samples from an analog input scan.
- mcc118_
a_ ⚠in_ scan_ start - @brief Start a hardware-paced analog input scan.
- mcc118_
a_ ⚠in_ scan_ status - @brief Reads status and number of available samples from an analog input scan.
- mcc118_
a_ ⚠in_ scan_ stop - @brief Stops an analog input scan.
- mcc118_
blink_ ⚠led - @brief Blink the LED on the MCC 118.
- mcc118_
calibration_ ⚠coefficient_ read - @brief Read the MCC 118 calibration coefficients for a single channel.
- mcc118_
calibration_ ⚠coefficient_ write - @brief Temporarily write the MCC 118 calibration coefficients for a single channel.
- mcc118_
calibration_ ⚠date - @brief Read the MCC 118 calibration date
- mcc118_
close ⚠ - @brief Close a connection to an MCC 118 device and free allocated resources.
- mcc118_
firmware_ ⚠version - @brief Return the board firmware and bootloader versions.
- mcc118_
info ⚠ - @brief Return constant device information for all MCC 118s.
- mcc118_
is_ ⚠open - @brief Check if an MCC 118 is open.
- mcc118_
open ⚠ - @brief Open a connection to the MCC 118 device at the specified address.
- mcc118_
serial ⚠ - @brief Read the MCC 118 serial number
- mcc118_
test_ ⚠clock - @brief Test the CLK pin.
- mcc118_
test_ ⚠trigger - @brief Test the TRIG pin by returning the current state.
- mcc118_
trigger_ ⚠mode - @brief Set the trigger input mode.
- mcc128_
a_ ⚠in_ mode_ read - @brief Read the analog input mode.
- mcc128_
a_ ⚠in_ mode_ write - @brief Set the analog input mode.
- mcc128_
a_ ⚠in_ range_ read - @brief Read the analog input range.
- mcc128_
a_ ⚠in_ range_ write - @brief Set the analog input range.
- mcc128_
a_ ⚠in_ read - @brief Perform a single reading of an analog input channel and return the value.
- mcc128_
a_ ⚠in_ scan_ actual_ rate - @brief Read the actual sample rate per channel for a requested sample rate.
- mcc128_
a_ ⚠in_ scan_ buffer_ size - @brief Returns the size of the internal scan data buffer.
- mcc128_
a_ ⚠in_ scan_ channel_ count - @brief Return the number of channels in the current analog input scan.
- mcc128_
a_ ⚠in_ scan_ cleanup - @brief Free analog input scan resources after the scan is complete.
- mcc128_
a_ ⚠in_ scan_ queue_ start - mcc128_
a_ ⚠in_ scan_ read - @brief Reads status and multiple samples from an analog input scan.
- mcc128_
a_ ⚠in_ scan_ start - @brief Start a hardware-paced analog input scan.
- mcc128_
a_ ⚠in_ scan_ status - @brief Reads status and number of available samples from an analog input scan.
- mcc128_
a_ ⚠in_ scan_ stop - @brief Stops an analog input scan.
- mcc128_
blink_ ⚠led - @brief Blink the LED on the MCC 128.
- mcc128_
calibration_ ⚠coefficient_ read - @brief Read the MCC 128 calibration coefficients for a specified input range.
- mcc128_
calibration_ ⚠coefficient_ write - @brief Temporarily write the MCC 128 calibration coefficients for a specified input range.
- mcc128_
calibration_ ⚠date - @brief Read the MCC 128 calibration date
- mcc128_
close ⚠ - @brief Close a connection to an MCC 128 device and free allocated resources.
- mcc128_
firmware_ ⚠version - @brief Return the board firmware version.
- mcc128_
info ⚠ - @brief Return constant device information for all MCC 128s.
- mcc128_
is_ ⚠open - @brief Check if an MCC 128 is open.
- mcc128_
open ⚠ - @brief Open a connection to the MCC 128 device at the specified address.
- mcc128_
serial ⚠ - @brief Read the MCC 128 serial number
- mcc128_
test_ ⚠clock - @brief Test the CLK pin.
- mcc128_
test_ ⚠trigger - @brief Test the TRIG pin by returning the current state.
- mcc128_
trigger_ ⚠mode - @brief Set the trigger input mode.
- mcc134_
a_ ⚠in_ read - @brief Read an analog input channel and return the value.
- mcc134_
calibration_ ⚠coefficient_ read - @brief Read the MCC 134 calibration coefficients for a single channel.
- mcc134_
calibration_ ⚠coefficient_ write - @brief Temporarily write the MCC 134 calibration coefficients for a single channel.
- mcc134_
calibration_ ⚠date - @brief Read the MCC 134 calibration date
- mcc134_
cjc_ ⚠read - @brief Read the cold junction compensation temperature for a specified channel.
- mcc134_
close ⚠ - @brief Close a connection to an MCC 134 device and free allocated resources.
- mcc134_
info ⚠ - @brief Return constant device information for all MCC 134s.
- mcc134_
is_ ⚠open - @brief Check if an MCC 134 is open.
- mcc134_
open ⚠ - @brief Open a connection to the MCC 134 device at the specified address.
- mcc134_
serial ⚠ - @brief Read the MCC 134 serial number
- mcc134_
t_ ⚠in_ read - @brief Read a temperature input channel.
- mcc134_
tc_ ⚠type_ read - @brief Read the thermocouple type for a channel.
- mcc134_
tc_ ⚠type_ write - @brief Write the thermocouple type for a channel.
- mcc134_
update_ ⚠interval_ read - @brief Read the temperature update interval.
- mcc134_
update_ ⚠interval_ write - @brief Write the temperature update interval.
- mcc152_
a_ ⚠out_ write - @brief Perform a write to an analog output channel.
- mcc152_
a_ ⚠out_ write_ all - @brief Perform a write to all analog output channels simultaneously.
- mcc152_
close ⚠ - @brief Close a connection to an MCC 152 device and free allocated resources.
- mcc152_
dio_ ⚠config_ read_ bit - @brief Read a digital I/O configuration value for a single channel.
- mcc152_
dio_ ⚠config_ read_ port - @brief Read a digital I/O configuration value for all channels.
- mcc152_
dio_ ⚠config_ write_ bit - @brief Write a digital I/O configuration value for a single channel.
- mcc152_
dio_ ⚠config_ write_ port - @brief Write a digital I/O configuration value for all channels.
- mcc152_
dio_ ⚠input_ read_ bit - @brief Read a single digital input channel.
- mcc152_
dio_ ⚠input_ read_ port - @brief Read all digital input channels simultaneously.
- mcc152_
dio_ ⚠int_ status_ read_ bit - @brief Read the interrupt status for a single channel.
- mcc152_
dio_ ⚠int_ status_ read_ port - @brief Read the interrupt status for all channels.
- mcc152_
dio_ ⚠output_ read_ bit - @brief Read a single digital output register.
- mcc152_
dio_ ⚠output_ read_ port - @brief Read all digital output registers simultaneously.
- mcc152_
dio_ ⚠output_ write_ bit - @brief Write a single digital output channel.
- mcc152_
dio_ ⚠output_ write_ port - @brief Write all digital output channels simultaneously.
- mcc152_
dio_ ⚠reset - @brief Reset the digital I/O to the default configuration.
- mcc152_
info ⚠ - @brief Return constant device information for all MCC 152s.
- mcc152_
is_ ⚠open - @brief Check if an MCC 152 is open.
- mcc152_
open ⚠ - @brief Open a connection to the MCC 152 device at the specified address.
- mcc152_
serial ⚠ - @brief Read the MCC 152 serial number
- mcc172_
a_ ⚠in_ clock_ config_ read - @brief Read the sampling clock configuration.
- mcc172_
a_ ⚠in_ clock_ config_ write - @brief Write the sampling clock configuration.
- mcc172_
a_ ⚠in_ scan_ buffer_ size - @brief Returns the size of the internal scan data buffer.
- mcc172_
a_ ⚠in_ scan_ channel_ count - @brief Return the number of channels in the current analog input scan.
- mcc172_
a_ ⚠in_ scan_ cleanup - @brief Free analog input scan resources after the scan is complete.
- mcc172_
a_ ⚠in_ scan_ read - @brief Reads status and multiple samples from an analog input scan.
- mcc172_
a_ ⚠in_ scan_ start - @brief Start capturing analog input data from the specified channels
- mcc172_
a_ ⚠in_ scan_ status - @brief Reads status and number of available samples from an analog input scan.
- mcc172_
a_ ⚠in_ scan_ stop - @brief Stops an analog input scan.
- mcc172_
a_ ⚠in_ sensitivity_ read - @brief Read the MCC 172 analog input sensitivity scaling factor for a single channel.
- mcc172_
a_ ⚠in_ sensitivity_ write - @brief Write the MCC 172 analog input sensitivity scaling factor for a single channel.
- mcc172_
blink_ ⚠led - @brief Blink the LED on the MCC 172.
- mcc172_
calibration_ ⚠coefficient_ read - @brief Read the MCC 172 calibration coefficients for a single channel.
- mcc172_
calibration_ ⚠coefficient_ write - @brief Temporarily write the MCC 172 calibration coefficients for a single channel.
- mcc172_
calibration_ ⚠date - @brief Read the MCC 172 calibration date
- mcc172_
close ⚠ - @brief Close a connection to an MCC 172 device and free allocated resources.
- mcc172_
firmware_ ⚠version - @brief Return the board firmware version.
- mcc172_
iepe_ ⚠config_ read - @brief Read the MCC 172 IEPE configuration for a single channel.
- mcc172_
iepe_ ⚠config_ write - @brief Write the MCC 172 IEPE configuration for a single channel.
- mcc172_
info ⚠ - @brief Return constant device information for all MCC 172s.
- mcc172_
is_ ⚠open - @brief Check if an MCC 172 is open.
- mcc172_
open ⚠ - @brief Open a connection to the MCC 172 device at the specified address.
- mcc172_
serial ⚠ - @brief Read the MCC 172 serial number
- mcc172_
test_ ⚠signals_ read - @brief Read the state of shared signals for testing.
- mcc172_
test_ ⚠signals_ write - @brief Write values to shared signals for testing.
- mcc172_
trigger_ ⚠config - @brief Configure the digital trigger.
Type Aliases§
- Analog
Input Mode - Analog input modes.
- Analog
Input Range - Analog input ranges
- DIOConfig
Item - DIO Configuration Items
- DaqResult
- Result type for DAQ HAT operations
- HatIDs
- Known DAQ HAT IDs.
- Result
Code - Return values from the library functions.
- Source
Type - Clock / trigger source definitions.
- TcTypes
- Thermocouple type constants
- Trigger
Mode - Scan trigger input modes.
- __
blkcnt64_ t - __
blkcnt_ t - __
blksize_ t - __
caddr_ t - __
clock_ t - __
clockid_ t - __
daddr_ t - __dev_t
- __
fsblkcnt64_ t - __
fsblkcnt_ t - __
fsfilcnt64_ t - __
fsfilcnt_ t - __
fsword_ t - __gid_t
- __id_t
- __
ino64_ t - __ino_t
- __
int8_ t - __
int16_ t - __
int32_ t - __
int64_ t - __
int_ least8_ t - __
int_ least16_ t - __
int_ least32_ t - __
int_ least64_ t - __
intmax_ t - __
intptr_ t - __key_t
- __
loff_ t - __
mode_ t - __
nlink_ t - __
off64_ t - __off_t
- __pid_t
- __
quad_ t - __
rlim64_ t - __
rlim_ t - __
sig_ atomic_ t - __
socklen_ t - __
ssize_ t - __
suseconds64_ t - __
suseconds_ t - __
syscall_ slong_ t - __
syscall_ ulong_ t - __
time_ t - __
timer_ t - __
u_ char - __u_int
- __
u_ long - __
u_ quad_ t - __
u_ short - __uid_t
- __
uint8_ t - __
uint16_ t - __
uint32_ t - __
uint64_ t - __
uint_ least8_ t - __
uint_ least16_ t - __
uint_ least32_ t - __
uint_ least64_ t - __
uintmax_ t - __
useconds_ t - int_
fast8_ t - int_
fast16_ t - int_
fast32_ t - int_
fast64_ t - int_
least8_ t - int_
least16_ t - int_
least32_ t - int_
least64_ t - intmax_
t - uint_
fast8_ t - uint_
fast16_ t - uint_
fast32_ t - uint_
fast64_ t - uint_
least8_ t - uint_
least16_ t - uint_
least32_ t - uint_
least64_ t - uintmax_
t