SysFS GPIO Switch#
Standup Records#
2023-11-20#
- Pull request won’t accept changes other than necessary to complete task - Revert all changes that were made to fix upstream errors 
- Update fork (see Working with Git In Our FH-ECE21 Project) 
 
Requirements#
Write a class SysFSGPIOSwitch that uses
Intro: sysfs GPIO
internally.
This class is going to be used to implement switches that software might want to use in real life.
Implementation#
Attention
This task has a dependency on :doc:switch-interface! A real
switch is used under real conditions, whereas a mocking switch
is used for testing - code should not depend on implementations,
but rather on interfaces.
Before you implement a switch interface (and derive your switch class from it), talk to the guys from (DONE) Boiling Pot (The Beginning). Or else it may happen that both groups do duplicate work which results in Git conflicts!
- Write a - class SysFSGPIOSwitchthat has methods- (Constructor). Configures the GPIO. - Export the GPIO. Write - 20(or whatever the pin’s number is) into- /sys/class/gpio/export. Note that one has to wait a bit until the- gpio20directory becomes visible. for output (exports the pin, write- outinto the IO’s- directionfile).
- Configure for output. Write - outinto the GPIO’s- directionfile.
 
- void set_state(bool);- Write - 0or- 1to the IO’s- valuefile, to control the pin’s output voltage.
 
Testing#
It is hard to come up with automatic tests for real hardware. (Although the file operations could somehow be verified.)
Write a test program in bin/ that you use interactively/manually.
Future (Not Part Of This Development Cycle)#
- Should we do the configuration in the constructure? Or is it better to proide a - configure()method that is called later in a program’s lifecycle?
- An alternative GPIO interface, - libgpiod(see Installation Notes). SysFS GPIO is deprecated!
