MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
SerialSource.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace MayaFlux::Vruta {
6class NetworkSource;
7}
8
10
11/**
12 * @brief Read a serial device as network messages, framed the way @p framing says.
13 * @param device_id Id of a serial device from open_serial_port().
14 * @param framing Only its framing, terminator, gap and message limit are used. Every message is
15 * delivered as bytes whatever its parser says.
16 * @return A source fed with one NetworkMessage per framed message, or nothing when serial
17 * input is not enabled or the device is unknown.
18 *
19 * The source reads the same bytes as the device and as every other reader, cut by its own
20 * framing, so the device's own reading and the nodes bound to it are unaffected. The message
21 * carries the device id as endpoint_id and no sender address. Hand it to on_message_received()
22 * or await it like any other NetworkSource. Dropping the last reference stops the reading.
23 *
24 * @code
25 * auto board = open_serial_port(port);
26 * auto frames = Portal::Network::serial_source(board->id, Core::SerialSpec::cobs());
27 * on_message_received(frames, [](const Core::NetworkMessage& message) { });
28 * @endcode
29 */
30MAYAFLUX_API std::shared_ptr<Vruta::NetworkSource> serial_source(uint32_t device_id, const Core::SerialSpec& framing);
31
32} // namespace MayaFlux::Portal::Network
Awaitable broadcast message stream for a network endpoint.
std::shared_ptr< Vruta::NetworkSource > serial_source(uint32_t device_id, const Core::SerialSpec &framing)
Read a serial device as network messages, framed the way framing says.