LightBarrier/GPIO#

Meetings/News#

Goal#

Create a LightBarrier implementation LightBarrierGPIO that uses libgpiod to read the state of the light barrier.

How#

class LightBarrierGPIO : public LightBarrier
{
public:
    LightBarrierGPIO(const std::string& gpiodevice, int line_number);
    ...
};
  • gpiodevice is for example /dev/gpiochip0

  • line_number is the number of the GPIO line (see for example the Raspberry Pi pinout diagram)

Use the libgpiod library to implement the get_state() method.

Testing#

Real hardware cannot be tested using unit tests (at least not easily). Write a test program (in tests/) that uses LightBarrierGPIO to read the switch state and output its value.