简体   繁体   English

IIO(字符)设备输出无输出-IIO缓冲区

[英]No output from IIO (character) device output - IIO buffer

I'm working on Linux driver for ADC ADS1243 and use IIO framework. 我正在为ADC ADS1243开发Linux驱动程序,并使用IIO框架。 I want to add feature to read and store data from ADC to IIO buffer. 我想添加功能以将数据从ADC读取和存储到IIO缓冲区。

I added iio_triggered_buffer_setup() to probe function of driver. 我添加了iio_triggered_buffer_setup()来探测驱动程序的功能。

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

I'm using sysfs trigger and ads1243_trigger_handler is succesfully called. 我正在使用sysfs触发器,并且成功调用ads1243_trigger_handler

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. 在处理程序中,我仅使用一些推送到iio缓冲区的测试数据。

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 启用一些扫描元素,设置并启用iio设备的缓冲区

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! 谢谢您的回复!

The code is correct and working. 代码正确无误。 I'm stupid - I didn't realized that cat command won't print invisible caharacters ! 我很傻-我没意识到cat命令不会打印看不见的角色

Use rather hexdump for example.. 例如,使用hexdump

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM