GCC Code Coverage Report


Directory: ./
File: channeloutput/ColorLight-5a-75.h
Date: 2026-10-29 08:11:58
Exec Total Coverage
Lines: 3 3 100.0%
Functions: 2 2 100.0%
Branches: 1 2 50.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 GPL v2 as described in the
11 * included LICENSE.GPL file.
12 */
13
14 #include <arpa/inet.h>
15 #include "fpp-json-fwd.h"
16 #include <net/if.h>
17 #include <netinet/in.h>
18 #include <sys/uio.h>
19 #include <string>
20 #include <vector>
21
22 #include "ChannelOutput.h"
23 #include "ColorOrder.h"
24 #include "Matrix.h"
25 #include "PanelMatrix.h"
26
27 #define CL_MAX_PIXL_PER_PACKET 497
28 #define CL_MAX_CHAN_PER_PACKET (CL_MAX_PIXL_PER_PACKET * 3)
29
30 #define CL_PACKET_TYPE_OFFSET 12
31 #define CL_PACKET_DATA_OFFSET 13
32
33 #define CL_SYNC_PACKET_TYPE 0x01 // sync memory to outputs
34 #define CL_SYNC_PACKET_SIZE 112
35 #define CL_DISC_PACKET_TYPE 0x07 // discover receivers
36 #define CL_DISC_PACKET_SIZE 284
37 #define CL_RESP_PACKET_TYPE 0x08 // receiver response to discovery
38 #define CL_RESP_PACKET_SIZE 1070
39 #define CL_BRIG_PACKET_TYPE 0x0A // brightness
40 #define CL_BRIG_PACKET_SIZE 77
41 #define CL_PIXL_PACKET_TYPE 0x55 // row data
42 #define CL_PIXL_HEADER_SIZE 8
43
44 typedef struct {
45 int model;
46 int id;
47 int majorFirmwareVersion;
48 int minorFirmwareVersion;
49 int width;
50 int height;
51 int xOffset;
52 int yOffset;
53
54 unsigned int uptime;
55 unsigned int packets;
56 } ColorLightReceiver;
57
58 class ColorLight5a75Output : public ChannelOutput {
59 public:
60 ColorLight5a75Output(unsigned int startChannel, unsigned int channelCount);
61 virtual ~ColorLight5a75Output();
62
63 161 virtual std::string GetOutputType() const override {
64
1/2
✓ Branch 0 taken 161 times.
✗ Branch 1 not taken.
322 return "ColorLight Panels";
65 }
66
67 virtual int Init(Json::Value config) override;
68 virtual int Close(void) override;
69
70 virtual void PrepData(unsigned char* channelData) override;
71 virtual int SendData(unsigned char* channelData) override;
72
73 virtual void DumpConfig(void) override;
74
75 virtual void GetRequiredChannelRanges(const std::function<void(int, int)>& addRange) override;
76
77 virtual void OverlayTestData(unsigned char* channelData, int cycleNum, float percentOfCycle, int testType, const Json::Value& config) override;
78 560 virtual bool SupportsTesting() const override { return true; }
79
80 void GetReceiverInfo();
81
82 private:
83 void BuildRemap(void);
84 void SetHostMACs(void* data);
85 int SendMessagesHelper(struct mmsghdr* msgs, int cnt);
86 bool SendMessages(std::vector<struct mmsghdr>& msgsToSend);
87 bool FrameFits(void);
88 void NoteDroppedFrame(void);
89 void RaiseSendErrorWarning(int err);
90 void ClearSendErrorWarning(void);
91
92 int m_width;
93 int m_height;
94 std::string m_layout;
95 std::string m_ifName;
96 std::string ifspeed_src;
97 int ifspeed;
98
99 FPPColorOrder m_colorOrder;
100
101 int m_fd;
102 int m_rfd;
103 int m_rowSize;
104
105 // Send-buffer accounting: what one frame's packets cost the kernel
106 // (payload plus per-packet overhead), and the buffer that holds them
107 int m_frameCharge;
108 int m_sendBufferSize;
109 bool m_frameSent;
110 // When PrepData() queued the rows, roughly how long they take on the
111 // wire, and how long the sync waits after the last of them has gone
112 long long m_rowsSentTime;
113 int m_rowsWireUS;
114 int m_syncGapUS;
115 int m_droppedFrames;
116 long long m_droppedLogTime;
117 std::string m_sendErrorWarning;
118
119 int m_panelWidth;
120 int m_panelHeight;
121 int m_panels;
122 int m_rows;
123 int m_outputs;
124 int m_longestChain;
125 int m_invertedData;
126 std::unique_ptr<char[]> m_outputFrame;
127 std::unique_ptr<Matrix> m_matrix;
128 std::unique_ptr<PanelMatrix> m_panelMatrix;
129 uint8_t m_gammaCurve[256];
130
131 // PrepData()'s remap, flattened by BuildRemap(): the source channel of
132 // each output-frame pixel, in frame order, consumed by runs of pixels
133 // that are contiguous in the frame and share one color order
134 struct RemapRun {
135 uint32_t dst; // byte offset into m_outputFrame
136 uint32_t count; // pixels
137 uint32_t order[3]; // channel offset of each output byte from the pixel's base
138 };
139 std::vector<RemapRun> m_remapRuns;
140 std::vector<uint32_t> m_remapSrc;
141 int m_flippedLayout;
142 bool m_colorlightDisable;
143
144 int m_highestFirmwareVersion;
145
146 std::vector<ColorLightReceiver> m_receivers;
147
148 // Display Frame
149 std::vector<struct mmsghdr> m_syncMsgs;
150 std::vector<struct iovec> m_synciovecs;
151
152 // Pixel Data, etc.
153 std::vector<struct mmsghdr> m_msgs;
154 std::vector<struct iovec> m_iovecs;
155
156 struct ifreq m_if_idx;
157 struct ifreq m_if_mac;
158 struct ether_header* m_eh;
159
160 std::string m_autoCreatedModelName;
161 std::list<std::string> m_warnings;
162
163 struct sockaddr_ll m_sock_addr;
164 };
165