GCC Code Coverage Report


Directory: ./
File: channeloutput/serialutil.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 <cstdint>
15
16 // A serial port that is not a kernel tty: a PRU sending on a GPIO pin, for a
17 // header pin with no UART transmit. SerialAttachBackend() takes ownership and
18 // returns an fd that stands for it in the calls below, so an output written
19 // against them drives either kind of port. SerialClose() releases it; it is
20 // deleted once no call is still using it.
21 class SerialPortBackend {
22 public:
23 2 virtual ~SerialPortBackend() {}
24 // queues up to len bytes, waiting up to timeoutMs for room; returns the
25 // number queued
26 virtual int write(const uint8_t* data, int len, int timeoutMs) = 0;
27 // holds the line low for us microseconds, then marks before what follows
28 virtual void sendBreak(int us) = 0;
29 virtual bool waitDrained(int timeoutMs) = 0;
30 };
31 int SerialAttachBackend(SerialPortBackend* backend);
32
33 int SerialOpen(const char* device, int baud, const char* mode, bool output = true);
34 int SerialOpen(const char* device, int baud, const char* mode, bool output, bool configurePin, const char* desc);
35 int SerialClose(int fd);
36 // True when device (after resolving links) is the active kernel console.
37 bool SerialIsConsole(const char* device);
38 int SerialSendBreak(int fd, int duration);
39
40 // The ports are opened O_NONBLOCK, so a plain write() of a frame larger than
41 // the room left in the tty buffer sends part of it, and the next frame then
42 // follows a truncated one. SerialWriteAll() waits (up to timeoutMs) for room
43 // until all of buf is written; it returns the bytes written, short only on an
44 // error or the timeout. For output worker threads, which can afford to wait.
45 int SerialWriteAll(int fd, const void* data, int len, int timeoutMs);
46 // Waits (up to timeoutMs) for everything queued on the tty to be sent.
47 // Returns false on timeout.
48 bool SerialWaitDrained(int fd, int timeoutMs);
49 int SerialResetRTS(int fd);
50 // write() for an output that must not wait: sends what fits now and returns
51 // the bytes taken, as a plain write() to a non-blocking tty does
52 int SerialWrite(int fd, const void* data, int len);
53