Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate daemon to libgpiod #48

Draft
wants to merge 56 commits into
base: dev
Choose a base branch
from
Draft

Migrate daemon to libgpiod #48

wants to merge 56 commits into from

Conversation

hangeza
Copy link
Contributor

@hangeza hangeza commented Jul 13, 2021

All (but one minor) functionality implemented and successfully tested so far based on libgpiod instead of pigpiod. The low-level interrupt handler now sends signals to an intermediate instance of RateBuffer, which provides protection against sustained high count rates. Following functionalities still need to be implemented or taken care of:

  • user muonpi must be in gpio group (not yet fixed in postinstall script)
  • automatic measurement of the system time against the timepulse not yet implemented as in the previous pigpiod-based version. However, this measurement (affecting only the TPTimeDiff histogram ) only makes sense, when the system is time-synchronized (with eg. chrony or ntpd) and was not regarded up to now by anyone.

closes #40

hangeza and others added 11 commits February 25, 2021 22:49
… a defined run status of the internal thread
…rom the former callback function are not yet forwarded, but the core mechanism of event detection works. Pins may be registered/unregistered during runtime and set/get gpio functions also seem to work. Note, that the executing user must be member of gpio group.
…orward a detected event to the daemon. With this, all basic functions of the daemon seem to work.

Not working yet and to be implemented in the new gpio readout scheme:
- pulse rate limitation for high freq. bursts
- sampling trigger signals (for triggering the ADC readout)
- time and time difference measurements for the population of two histos

Note: For the daemon to work with the new libgpiod based readout, several things have to be changed from the pigpiod scheme:
- the user who is executing the daemon (usually muonuser) must be added to the system group 'gpio' with 'sudo usermod -a -G gpio muonuser'
- the pigpiod daemon must be switched off
- the libgpiod-dev package must be installed on the system prior to compilation
…tion:

- implemented trigger for ADC sampling
- implemented GPIO inhibit
- default eventTrigger signal is now GPIO_UNDEFINED_PIN, i.e. no trigger set up. This still has to be implemented as valid selection in the GUI
…plemented for the tracking of the XOR and AND rates in the daemon.
… by an instance of this class now. RateBuffer contains a smart rate throttling which prevents lock-up of daemon and GUI at excessive rates.

This branch should now privide equal or better functionality compared to the pigpiod daemon.
However, the following features are not yet implemented:
- Measurement of the system time deviation from GNSS (timpulse) time
- Measurement of the GPIO event interval (as in the histogram under statistics tab of the GUI with the same name). This may be implemented easily with the help of the RateBuffer class.
…val"). Adjusted scaling of several histograms.
…signal is explicitly not bound to a fixed GPIO pin.

Corrected some wrong assignments in the GPIO pin list for HW Ver 1.
@hangeza hangeza self-assigned this Jul 13, 2021
@hangeza hangeza linked an issue Jul 14, 2021 that may be closed by this pull request
hangeza added 3 commits July 14, 2021 09:27
…d for running the daemon with access to the gpio kernel subsystem.
- added measurement of time pulse to system time
… the range -0.5s...+0.5s, instead of 0...1s as before
Copy link
Member

@dtreffenstaedt dtreffenstaedt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't comment out code but directly delete it instead.

source/daemon/include/daemon.h Outdated Show resolved Hide resolved
source/daemon/include/pigpiodhandler.h Outdated Show resolved Hide resolved
source/daemon/include/pigpiodhandler.h Outdated Show resolved Hide resolved
source/daemon/include/pigpiodhandler.h Outdated Show resolved Hide resolved
source/daemon/include/pigpiodhandler.h Outdated Show resolved Hide resolved
source/daemon/include/pigpiodhandler.h Outdated Show resolved Hide resolved
source/daemon/src/ratebuffer.cpp Outdated Show resolved Hide resolved
source/gui/src/mainwindow.cpp Outdated Show resolved Hide resolved
source/gui/src/parametermonitorform.cpp Outdated Show resolved Hide resolved
source/gui/src/status.cpp Outdated Show resolved Hide resolved
Copy link
Member

@dtreffenstaedt dtreffenstaedt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a more sturdy preinst script to handle older installations where just the user needs to be added to a new group

source/daemon/config/preinst Outdated Show resolved Hide resolved
Co-authored-by: Daniel Treffenstädt <[email protected]>
@hangeza hangeza marked this pull request as draft July 16, 2021 08:20
hangeza added 2 commits July 18, 2021 11:48
- removed separate the samplingTrigger handling in PigpiodHandler
- merged slots for gpio events in daemon into one onGpioPinEvent() slot
- removed unregistering interrupts in PigpiodHandler before registering them again. This would be the cleanest procedure but somehow it doesn't work from gpiod side
…eBuffer classes to more descriptive event and filteredEvent.

- Added transmission of interrupt timestamp to event and filteredEvent signals.
@dtreffenstaedt dtreffenstaedt added this to the v2.1.0 milestone Jul 30, 2021
- moved all event handlers to separately spawned threads for each interrupt line
- added map to store the last time intervals between events from different gpios in RateBuffer class
- changed filling of gpioTimeIntervalShort histogram to time intervals measured between the currently selected eventTrigger and the rising edge of TIME_MEAS_OUT signal
…prior merge conflict. Added ratebuffer.cpp file which was not commited properly during the last big PR.
…ge descriptor) to make this libgpiod-development branch discernible from the mainstream packages
@hangeza hangeza removed this from the v2.1.0 milestone Feb 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate from pigpiod to libgpiod
3 participants