analogdevicesinc / libiio

A cross platform library for interfacing with local and remote Linux IIO devices
http://analogdevicesinc.github.io/libiio/
GNU Lesser General Public License v2.1
483 stars 311 forks source link

Failed to create iio buffer #941

Open panxishan opened 1 year ago

panxishan commented 1 year ago

Via iio device create_ Buffer () creates a buffer to read the information of the gyroscope's iio device. There is a segment error, error code 22. What is the reason

pcercuei commented 1 year ago

Error code 22 is "invalid value". What hardware and Linux driver are you using, and how do you call iio_device_create_buffer?

panxishan commented 1 year ago

Error code 22 is "invalid value". What hardware and Linux driver are you using, and how do you call iio_device_create_buffer?

I wrote an iio driver test for mpu6050 and created a buffer in qt through the (struct iio_buffer * buf=iio_device_create_buffer (dev, 1024, false) function

pcercuei commented 1 year ago

I would think that your mpu6050 driver does not support the buffer interface. It does not really need to, if the sample rate is very low (which is typically the case on a gyroscope).

Instead, you should be able to use channel.find_attribute("raw").read() to get a snapshot of the channel's value at a given time.