问题描述
我正在为ADC ADS1243开发Linux驱动程序,并使用IIO框架.我想添加功能以将数据从ADC读取和存储到IIO缓冲区.
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.
我添加了iio_triggered_buffer_setup()来探测驱动程序的功能.
I added iio_triggered_buffer_setup() to probe function of driver.
ret = iio_triggered_buffer_setup(indio_dev, NULL, &ads1243_trigger_handler, NULL);
我正在使用sysfs触发器,并且成功调用了ads1243_trigger_handler
.
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;
}
在处理程序中,我只使用一些推送到iio缓冲区的测试数据.
In the handler I use just some test data pushed to iio buffer.
然后我设置触发器
echo 0 > iio_sysfs_trigger/add_trigger
cat /sys/bus/iio/devices/trigger0/name > /sys/bus/iio/devices/iio:device1/trigger/current_trigger
启用一些扫描元素,设置并启用iio设备的缓冲区
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
触发扳机
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?
感谢您的回复!
推荐答案
该代码正确且有效.我很傻-我没意识到 cat 命令不会显示不可见字符!
The code is correct and working. I'm stupid - I didn't realized that cat command won't print invisible caharacters!
例如使用 hexdump .
这篇关于IIO(字符)设备输出无输出-IIO缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!