No output from IIO (character) device output - IIO buffer

谁都会走 提交于 2019-12-12 09:10:01

问题


I'm working on Linux driver for ADC ADS1243 and use IIO framework. I want to add feature to read and store data from ADC to IIO buffer.

I added iio_triggered_buffer_setup() to probe function of driver.

ret = iio_triggered_buffer_setup(indio_dev, NULL, &ads1243_trigger_handler, NULL);

I'm using sysfs trigger and ads1243_trigger_handler is succesfully called.

static irqreturn_t ads1243_trigger_handler(int irq, void *p)
{
    struct iio_poll_func *pf = p;
    struct iio_dev *indio_dev = pf->indio_dev;
    struct ads1243_state *st = iio_priv(indio_dev);
    u32 val[8];
    int ret;

    val[0] = 0x01;
    val[1] = 0x02;
    val[2] = 0x03;
    val[3] = 0x04;

    ret = iio_push_to_buffers_with_timestamp(indio_dev, val,
                                       iio_get_time_ns());
    /* iio_push_to_buffers(indio_dev, val); */

    iio_trigger_notify_done(indio_dev->trig);

    return IRQ_HANDLED;

}

In the handler I use just some test data pushed to iio buffer.

Then I setup the trigger

echo 0 > iio_sysfs_trigger/add_trigger
cat /sys/bus/iio/devices/trigger0/name > /sys/bus/iio/devices/iio:device1/trigger/current_trigger

enable some scan elements, setup and enable the buffer for iio device

echo 1 > scan_elements/in_voltage0-voltage1_en
echo 1 > scan_elements/in_voltage2-voltage3_en

echo 64 > buffer/length
echo 1 > buffer/enable

Fire the trigger

echo 1 > /sys/bus/iio/devices/trigger0/trigger_now

and then try to read the device (buffer)

cat /dev/iio\:device1

But I got no output. Am I missing something important?

Thanks for reply!


回答1:


The code is correct and working. I'm stupid - I didn't realized that cat command won't print invisible caharacters!

Use rather hexdump for example..



来源:https://stackoverflow.com/questions/43134050/no-output-from-iio-character-device-output-iio-buffer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!