GCC Code Coverage Report


Directory: ./
File: sensors/MuxSensorSource.h
Date: 2026-10-29 08:11:58
Exec Total Coverage
Lines: 1 1 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 #pragma once
2 /*
3 * This file is part of the Falcon Player (FPP) and is Copyright (C)
4 * 2013-2022 by the Falcon Player Developers.
5 *
6 * The Falcon Player (FPP) is free software, and is covered under
7 * multiple Open Source licenses. Please see the included 'LICENSES'
8 * file for descriptions of what files are covered by each license.
9 *
10 * This source file is covered under the LGPL v2.1 as described in the
11 * included LICENSE.LGPL file.
12 */
13
14 #include "Sensors.h"
15 #include "fpp-json-fwd.h"
16 #include "../util/GPIOUtils.h"
17 #include <array>
18 #include <mutex>
19
20 class MuxSensorSource : public SensorSource {
21 public:
22 MuxSensorSource(Json::Value& config);
23 virtual ~MuxSensorSource();
24
25 virtual void Init(std::map<int, std::function<bool(int)>>& callbacks) override;
26
27 virtual void update(bool forceInstant = false) override;
28 virtual void enable(int id) override;
29 virtual int32_t getValue(int id) override;
30
31 virtual void lockToGroup(int i) override;
32
33 4 virtual bool isOK() const override { return source != nullptr; }
34
35 private:
36 void setGroupPins();
37 void nextMux();
38 void getValues();
39 std::vector<int32_t> values;
40 std::vector<bool> enabled;
41 std::vector<bool> current;
42
43 std::vector<const PinCapabilities*> pins;
44 SensorSource* source = nullptr;
45 int channelsPerMux = 0;
46 int muxCount = 0;
47 bool updatingByCallback = false;
48 int muxSwitchDelay = 0;
49 int muxSwitchReadCount = 0;
50
51 // update() runs on the OutputMonitor and string tester threads,
52 // getValue() on HTTP threads (sensor reports), lockToGroup() on the
53 // string tester's, and the IIO callback on the select thread: all of
54 // them walk and resize the vectors above and move the mux pins.
55 // Recursive: update() -> nextMux() -> getValues() and the like. Taken
56 // before the source's own lock, never after it.
57 std::recursive_mutex muxLock;
58
59 volatile int curMux = 0;
60 volatile int updateCount = 0;
61 volatile bool lockedToGroup = false;
62 };
63