Package: trimarlib-sysfsgpio
trimarlib-sysfsgpioPython GPIO library, using Linuxsysfsinterface.Getting startedThese instructions will get you a copy of the project on your local machine for development and testing purposes.
SeeDeploymentfor notes on how to deploy the project on a live system.PrerequisitesThe build process requires some basic development tools:make- GNU Make program, either for *nix or Windows system, used to execute build and test targetsgit- used not only to clone the repository, but also in auto-versioning (seeVersioning)python3Two standard Python packages are used for build and installation steps:setuptoolswheelThe library has no dependencies on any third-party packages.Building and releasingInvokingmake all(default target) prepares archives for distribution. It is done in two steps:query Git repository for tags (git describecommand) to determine current version and generateversion.pyfile,invoke Python interpreter passingsetup.pyscript to prepare source and wheel distributions.The Python interpreter invoked by theMakefiledefaults topythonwhen running on Windows machine andpython3otherwise. In both cases it is possible to override it passing aPYTHONvariable to the command,
e.g.make all PYTHON=python3.The release process is automated and based on GitLab CI/CD environment - each commit triggers a build job
which attempts to make and install built packages (no testing implemented yet, requires an available hardware
platform). If the commit is tagged the built wheel distribution is passed to the deployment stage and
the runner attempts to upload the package to the repository specified in project settings.TestingTest source files are located insysfsgpio/testsdirectory. Testing is based onunittestPython
built-in package. TheMakefiledefinestesttarget which invokes all tests.Testing is divided into two steps:utility functions testing - performs unit tests of all ancillary features. Those tests are
platform independent (i.e. shall pass on either a *nix or a Windows machine);Pintesting - performs unit tests ofPinclass. Those tests depend on thesysfsLinux
filesystem and are skipped when running on Windows machine.DeploymentThe library is not intended to be used in a standalone configuration - the primary purpose is to be used
by higher-level applications, which should define it as a dependency. However it is perfectly correct
to install it manually usingpip.Please keep in mind that there are some platform dependent steps needed to be taken before the
pins are accessible without super-user privileges. The package designates 3 entry points (accessible
as command-line tools) to ease-up the set-up process (the scripts are developed and confirmed to be
working on Orange Pi platform running Armbian distribution). These entry points are:sysfsgpio-install-service- this command installs and enablessystemdgpio-exporterservice,
which exports all free pins available on the Orange Pi SBC at system boot;sysfsgpio-install-rules- this command installudevrules file which ensures that each exported
pin hasrwmode available tostaffgroup;sysfsgpio-install- this one invokes the above to reduce number of commands needed to set-up system.Each of the commands may be invoked with--forceswitch to overwrite existing files - without that
switch commands fail printing proper message.NOTE:The user needs to become member of thestaffgroup to use the pins without super-user rights.VersioningThe project is versioned using a simple pattern based on repository tagging feature. SeeMakefilefor implementation details, for versions available seetags on this repository.UsageSee docstrings for API documentation.Example of using pin PA21 as input:fromsysfsgpioimportPindefcallback(sender,value):print('pin={}, value={}'.format(sender,value))pin=Pin('PA21')pin.direction='in'pin.register_callback(callback)pin.enabled=TrueExample of using pin PA20 as output:fromsysfsgpioimportPinimporttimepin=Pin('PA20')pin.direction='out'foriinrange(10):time.sleep(.1)pin.value=pin.value^1Example of using pin PA7 as inverted output to generate timed pulses:fromsysfsgpioimportPinpin=Pin('PA20')pin.direction='out'pin.configuration=dict(ontime=3.33,offtime=6.67,repeat=3)pin.enable()LicenseThis software is licensed under the MIT License - seeLICENSE.