MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / idealSerialBufferSize

Function idealSerialBufferSize

app/src/IO/Drivers/UART.cpp:38–48  ·  view source on GitHub ↗

* @brief Calculates an ideal read buffer size for a serial port. */

Source from the content-addressed store, hash-verified

36 * @brief Calculates an ideal read buffer size for a serial port.
37 */
38static size_t idealSerialBufferSize(const qint32 baud)
39{
40 size_t bytes = static_cast<size_t>(baud * 0.02);
41 bytes = std::max<size_t>(256, bytes);
42 bytes = std::min<size_t>(16384, bytes);
43
44 constexpr size_t granularity = 256;
45 bytes = ((bytes + granularity - 1) / granularity) * granularity;
46
47 return bytes;
48}
49
50//--------------------------------------------------------------------------------------------------
51// Constructor/destructor & singleton access functions

Callers 1

openMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected