Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
{
public:
virtual void onIioEvent(const IioEventData& eventData) = 0;
};
{
public:
virtual void onIioEvent(const IioEventData& eventData) = 0;
};
/**
* @brief API to Industrial IO
*
/**
* @brief API to Industrial IO
*
*
* @returns The device name
*/
*
* @returns The device name
*/
- * Read a float value from specified attribute.
+ * Read a float value from specified attribute.
*
* @param attributeName attribute mame
*
*
* @param attributeName attribute mame
*
- * Write an int value to specified attribute.
+ * Write an int value to specified attribute.
*
* @param attributeName attribute mame
* @param value int value
*
* @param attributeName attribute mame
* @param value int value
- * Write a float value to specified attribute.
+ * Write a float value to specified attribute.
*
* @param attributeName attribute mame
* @param value float value
*
* @param attributeName attribute mame
* @param value float value
- * Register event handler.
+ * Register event handler.
*
* @param handler handler class that implements IioHandler
*
*
* @param handler handler class that implements IioHandler
*
eventData.diff = different;
handler->onIioEvent(eventData);
}
eventData.diff = different;
handler->onIioEvent(eventData);
}
mraa_iio_context m_iio;
};
mraa_iio_context m_iio;
};
-IIO is the kernel's framework for supporting sensors.
+IIO is the kernel's framework for supporting sensors.
## Using dummy_iio driver
## Using dummy_iio driver
-For platforms without IIO hardware the iio_dummy driver can be used. You can add the driver by either rebuilding the kernel with IIO component enabled or just building the IIO modules and load them.
-You must add the following config fragment. Known to work for kernel 3.19 and later.
+For platforms without IIO hardware the iio_dummy driver can be used. You can
+add the driver by either rebuilding the kernel with IIO component enabled or
+just building the IIO modules and load them. You must add the following config
+fragment. Known to work for kernel 3.19 and later.
<pre><code>
CONFIG_IIO_DUMMY_EVGEN=m
CONFIG_IIO_SIMPLE_DUMMY=m
<pre><code>
CONFIG_IIO_DUMMY_EVGEN=m
CONFIG_IIO_SIMPLE_DUMMY=m
#include <math.h>
#include <float.h>
#include "mraa/iio.hpp"
#include <math.h>
#include <float.h>
#include "mraa/iio.hpp"
else
result = success ? "FAIL" : "PASS";
if (attr_name.empty())
else
result = success ? "FAIL" : "PASS";
if (attr_name.empty())
- fprintf(stdout, "%s: %s\n", test_name.c_str(), result.c_str());
+ fprintf(stdout, "%s: %s\n", test_name.c_str(), result.c_str());
else
fprintf(stdout, "%s(%s): %s\n", test_name.c_str(), attr_name.c_str(), result.c_str());
}
else
fprintf(stdout, "%s(%s): %s\n", test_name.c_str(), attr_name.c_str(), result.c_str());
}
IioTestHandler testHandler;
std::string deviceName;
try {
IioTestHandler testHandler;
std::string deviceName;
try {
- mraa::Iio* iio_device0 = new mraa::Iio(0);
+ mraa::Iio* iio_device0 = new mraa::Iio(0);
std::cout << "IIO device 0 found by id." << std::endl;
std::cout << "IIO device 0 found by id." << std::endl;
- deviceName = iio_device0->getDeviceName();
- delete iio_device0;
+ deviceName = iio_device0->getDeviceName();
+ delete iio_device0;
} catch (std::exception& e) {
std::cerr << "IIO device 0 not found." << std::endl;
return EXIT_FAILURE;
}
try {
} catch (std::exception& e) {
std::cerr << "IIO device 0 not found." << std::endl;
return EXIT_FAILURE;
}
try {
- mraa::Iio* iio_device1 = new mraa::Iio(1);
+ mraa::Iio* iio_device1 = new mraa::Iio(1);
delete iio_device1;
} catch (std::exception& e) {
std::cerr << "IIO device 1 not found. This is expected behavior." << std::endl;
}
try {
delete iio_device1;
} catch (std::exception& e) {
std::cerr << "IIO device 1 not found. This is expected behavior." << std::endl;
}
try {
- iio_device = new mraa::Iio(deviceName);
- std::cout << "IIO device 0 found by name." << std::endl;
+ iio_device = new mraa::Iio(deviceName);
+ std::cout << "IIO device 0 found by name." << std::endl;
} catch (std::exception& e) {
std::cerr << "IIO device 0 not found." << std::endl;
return EXIT_FAILURE;
}
} catch (std::exception& e) {
std::cerr << "IIO device 0 not found." << std::endl;
return EXIT_FAILURE;
}
- std::cout << "Using IIO device0. Name is " << iio_device->getDeviceName() << std::endl;
+ std::cout << "Using IIO device0. Name is " << iio_device->getDeviceName() << std::endl;
IIO_RUN(writeFloat, "in_accel_x_raw", 100, EXPECT_FAILURE);
IIO_RUN(writeFloat, "in_accel_x_raw", 100, EXPECT_FAILURE);
- IIO_RUN(writeFloat, "in_voltage0_scale", 100, EXPECT_FAILURE);
- IIO_RUN(writeInt, "out_voltage0_raw", 100, EXPECT_SUCCESS);
+ IIO_RUN(writeFloat, "in_voltage0_scale", 100, EXPECT_FAILURE);
+ IIO_RUN(writeInt, "out_voltage0_raw", 100, EXPECT_SUCCESS);
IIO_TEST(readInt, "in_accel_x_raw", 34, EXPECT_SUCCESS);
IIO_TEST(readFloat, "in_voltage0_scale", 0.001333, EXPECT_SUCCESS);
IIO_RUN(writeInt, "events/in_voltage0_thresh_rising_en", 1, EXPECT_SUCCESS);
IIO_TEST(readInt, "in_accel_x_raw", 34, EXPECT_SUCCESS);
IIO_TEST(readFloat, "in_voltage0_scale", 0.001333, EXPECT_SUCCESS);
IIO_RUN(writeInt, "events/in_voltage0_thresh_rising_en", 1, EXPECT_SUCCESS);
- IIO_TRY(registerEventHandler(&testHandler));
+ IIO_TRY(registerEventHandler(&testHandler));
eventCount = 0;
generate_event();
usleep(500000);
eventCount = 0;
generate_event();
usleep(500000);
if (stat(IIO_CONFIGFS_TRIGGER, &configfs_status) == 0) {
memset(buf, 0, MAX_SIZE);
snprintf(buf, MAX_SIZE, IIO_CONFIGFS_TRIGGER "%s", trigger);
if (stat(IIO_CONFIGFS_TRIGGER, &configfs_status) == 0) {
memset(buf, 0, MAX_SIZE);
snprintf(buf, MAX_SIZE, IIO_CONFIGFS_TRIGGER "%s", trigger);
- // we actually don't care if this doesn't succeed, as it just means
- // it's already been initialised
- mkdir(buf, configfs_status.st_mode);
+ // we actually don't care if this doesn't succeed, as it just means
+ // it's already been initialised
+ mkdir(buf, configfs_status.st_mode);
}
return MRAA_ERROR_UNSPECIFIED;
}
return MRAA_ERROR_UNSPECIFIED;
mraa_iio_detect()
{
plat_iio = (mraa_iio_info_t*) calloc(1, sizeof(mraa_iio_info_t));
mraa_iio_detect()
{
plat_iio = (mraa_iio_info_t*) calloc(1, sizeof(mraa_iio_info_t));
- plat_iio->iio_device_count = num_iio_devices;
+ plat_iio->iio_device_count = num_iio_devices;
// Now detect IIO devices, linux only
// find how many iio devices we have if we haven't already
if (num_iio_devices == 0) {
// Now detect IIO devices, linux only
// find how many iio devices we have if we haven't already
if (num_iio_devices == 0) {