-
Notifications
You must be signed in to change notification settings - Fork 0
pourd
Paul Cowan edited this page Jul 9, 2013
·
4 revisions
pourd is the KegNet client pour monitoring daemon
- Listens for flow meter pulses on a single GPIO pin
- Groups pulses into pours based on configuration parameters
- Writes pulse counts and metadata to .pour files
- KegNet uses WiringPi pin numbers for flow sensors
- See GPIO for KegNet's Raspberry Pi GPIO pin assignments
- See General Purpose Input/Output (GPIO) at the elinux.org Wiki for more information on the GPIO pins
- Also see GPIO Connector Pins at WiringPi for WiringPi pin number assignments
- Written in C, source at src/pourd.c
- Compile using make-pourd script
- Uses GLib GKeyFile library to read configuration
- Uses WiringPi Library to listen for pulses on designated Raspberry Pi GPIO pin
- Uses WiringPi's wiringPiISR to receive interrupt driven callbacks on each "edge rising" pulse
- Uses syslog library to write logs
- Executable located at /usr/share/kegnet-client/lib/pourd
- Started via bash script at /usr/share/kegnet-client/bin/pourd.sh
- The Raspberry Pi GPIO pin number is passed via command-line as the only argument
- Started and managed as a daemon by systemd
- Service configuration is located at /usr/share/kegnet-client/service/[email protected]
- .service files are linked into /etc/systemd/system/multi-user.target.wants to start up on multi-user run level
- [email protected] uses parameterization, and is linked to 2 times for pins 0 and 3 [email protected], [email protected]
- .service files are configured with ConditionPathExists=/usr/share/kegnet-client/conf/pourd#.conf such that a daemon will only be started if the configuration file exists
- Because Raspberry Pi does not have a realtime clock, and pourd must timestamp .pour files, startup depends on an internet connection and ntp
- To manually start pourd execute /usr/share/kegnet-client/start-pourd or systemctl start -client@#.service (where # is the pin number)
- To manually stop pourd execute /usr/share/kegnet-client/stop-pourd or systemctl stop pourd@#.service (where # is the pin number)
- Reads configuration from /usr/share/kegnet-client/conf/pourd#.conf (where # is the pin number), see file conf/pourd0.conf
- pourd#.conf contains 2 configuration parameters: pour_delay_ms and min_pour_pulses
- pour_delay_ms (default 1000) is the number of milliseconds of no pulse activity to consider a pour complete - in other words there must be at least 1 second of no flow between pours or they will be grouped as the same pour
- min_pour_pulses (default 200) is the minimum number of pulses that will be considered a real pour - this filters out random pulses causes by leakage, backflow, or foam buildup passing through the flow meter
- Writes valid pours to /usr/share/kegnet-client/spool
- Each pour is written as a separate file named in the format pin numberpour start time.pour
- The format of the .pour file is pin number,pulse count,elapsed pour time in seconds,pour start time
- Logs using syslog to /var/log/user.log