Simulate gpios for libgpiod

1k Views Asked by At

I have an existing C++ code that reads periodically from /sys/class/gpio. Since this is depreciated, I want to change it and use libgpiod.

I have got component tests that run independently from the actual hardware. It runs on my dev machine that does not have those gpios. My code reads an environment variable with a different path, then uses the files there instead of /sys/class/gpio. I created simple text files there. I can now change these files to manipulate what my code reads and test its behaviour.

Is there a similar possibility for libgpiod?

1

There are 1 best solutions below

2
On

There's a GPIO testing driver called gpio-mockup you can load. It creates mock GPIO devices. You need to enable it in your kernel or load it as a module.