简体   繁体   English

IIO设备缓冲区始终为空

[英]IIO device buffer always null

I am using an IMU sensor called LSM6DSL with the iio drivers. 我正在使用一个名为LSM6DSL的IMU传感器和iio驱动程序。 They work fine if I display the raw values with the command: 如果我使用命令显示原始值,它们工作正常:

cat /sys/bus/iio/devices/iio:device0/in_accel_x_raw

Then I decided to use the libiio so I can read all these values from a C program : 然后我决定使用libiio,这样我就可以从C程序中读取所有这些值:

struct iio_context *context = iio_create_local_context();
struct iio_device *device = iio_context_get_device(context, 1);
struct iio_channel *chan = iio_device_get_channel(device, 0);
iio_channel_enable(chan);
if (iio_channel_is_scan_element(chan) == true)
    printf("OK\n");
struct iio_channel *chan2 = iio_device_get_channel(device, 1);
iio_channel_enable(chan2);
struct iio_buffer *buff = iio_device_create_buffer(device, 1, true);
if (buff == NULL)
{
  printf("Error: %s\n", strerror(errno));
  return (1);
}

And this is the result : 这就是结果:

OK
Error: Device or resource busy

Am I missing something? 我错过了什么吗? Let me know if you need more informations. 如果您需要更多信息,请告诉我。

I guess I found the answer, and I didn't pay attention to the effects of the ncurses library (sorry for not mentioning that I was using it). 我想我找到了答案,并没有注意到ncurses库的影响(抱歉没有提到我正在使用它)。

I moved these functions before the initialization of ncurses and now the buffer is created successful. 我在ncurses初始化之前移动了这些函数,现在缓冲区已成功创建。

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

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