/* * This is an encapsulation of a National Instruments DIO port. * * It presents a simple device abstraction. * * The device can be read and returns a 32-bit unsigned value. */ #ifndef _HWARE_H_ #define _HWARE_H_ #ifdef __cplusplus #else #include #endif struct device_private_t; typedef struct device_private_t* pHWARE; typedef unsigned int HWARE_VALUE; /** * Create a device * * \param card_name the name of the device (e.g. "dev1/port0") * \param ptr address of pointer to opaque private data structure * * \return * 0 OK * !0 Error */ int hware_ctor(const char* card_name, pHWARE* ptr); /** * Read the value of the device * * \param hware pointer to opaque private data structure * \param value address of value to receive the output * * \return * 0 OK * !0 Error */ int hware_read(pHWARE hware, HWARE_VALUE* value); /** * Write the value of the device * * \param hware pointer to opaque private data structure * \param value to be written to the device * * \return * 0 OK * !0 Error */ int hware_write(pHWARE hware, HWARE_VALUE value); /** * Destroy the device * * \param ptr address of pointer to opaque private data structure * * \return * 0 OK * !0 Error */ int hware_dtor(pHWARE* hware); /** * Tests returned error value to see if it represents failure * * \param error a value returned from another hware function * * \return * true the error was a failure * false the error was not a failure (warning) */ bool hware_failed(int error); /** * Retrieves a textual representation of the most recent error * * \param buff a pointer to the buffer to receive the text * \param len the length of the provided buffer */ void hware_errmsg(char* buff, int len); #endif