umockdev icon indicating copy to clipboard operation
umockdev copied to clipboard

Support IIO devices

Open hadess opened this issue 11 years ago • 9 comments

This will be useful on tablets and phones to test for accelerometers, compasses, quaternion sensors, etc.

In particular, accelerometers will behave differently if they have a "trigger" or not, if they have scan_elements, etc.

hadess avatar Nov 06 '14 15:11 hadess

I don't seem to have an IIO hardware (at least not on my ThinkPad X230 and on my Google Nexus 4 phone), so I can't investigate for myself what's missing here.

  • The /sys/ bits should certainly be ok, or is there something missing? How far do you get with detection if you umockdev-record such a device and recreate it in a testbed (umockdev-run)?
  • Do these devices have a /dev/ node? If so, do they need any particular ioctls which umockdev needs to learn? Or are these just normal char devices where you read/write from/to?

Some general info (umockdev-record dump, /dev structure, an open/read/write/ioctl/close strace what happens if some program talks to the device) would be appreciated. Thanks!

martinpitt avatar Nov 10 '14 11:11 martinpitt

iio is bus instead of class (fixed by #94)

dlech avatar Aug 28 '19 22:08 dlech

@dlech: Is that the only issue that keeps iio device emulation from working?

martinpitt avatar Sep 01 '19 11:09 martinpitt

Probably. It doesn't use any ioctls that I know of. I haven't done anything fancy with it yet though.

dlech avatar Sep 01 '19 13:09 dlech

Probably. It doesn't use any ioctls that I know of. I haven't done anything fancy with it yet though.

A way to manage the ring-buffers where the latest readouts are kept would be useful, but just being to instantiate the device is nice already.

hadess avatar Sep 02 '19 09:09 hadess

No, there are no ioctls in iio. You can emulate things with a "dummy" kernel device (if you want to compile your own kernel and check things out).

I just ran into umockdev - very cool.

This would be nice to use umockdev for validation automatic test of libiio - right now it's alot of manual testing when we make a release. Since libiio uses multiple backends (local, network, usb, serial), and iiod (which serve up local IIO devices to remote applications over USB or network), getting local working would be the most useful, but we eventually use all.

Since usb looks like it is more supported - I will start with there to get familiar with umockdev.

rgetz avatar May 23 '20 19:05 rgetz

I've managed to make it work. It's not super easy, as I didn't want to rely on the ioctl() capture and replay, as it's not great for interactive tests.

It would be great if umockdev had some helper tools for that, something that could mock /dev devices which are just fancy data buffers (and which could mock -EAGAIN too).

See https://gitlab.freedesktop.org/hadess/iio-sensor-proxy/-/issues/317

hadess avatar Jan 20 '21 17:01 hadess

A few years ago, I did some experimenting using libfuse to provide simulated sysfs devices - mainly to simulate returning errors like that. It looked promising but I didn't get very far with it.

dlech avatar Jan 20 '21 17:01 dlech

The SPI emulation from #125 could be a starting point now. In this case, my guess that custom code by using #132 might be better though. That can also mock -EAGAIN, it cannot mock poll state at this point though.

benzea avatar Jun 25 '21 07:06 benzea