MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
NetworkSerialLink.hpp
Go to the documentation of this file.
1#pragma once
2
4
6struct NetworkService;
7}
8
9namespace MayaFlux::Core {
10
11/**
12 * @class NetworkSerialLink
13 * @brief An ISerialLink over a SERIAL endpoint of the NetworkService.
14 *
15 * The endpoint is opened with framing NONE, so every chunk the port yields reaches the
16 * chunk callback as it is. Reconnection, settle time and line control are the endpoint's,
17 * driven by the SerialLineSettings given to open(). The state callback also reports the
18 * endpoint's state at the moment open() returns, so a transition that happened before
19 * the callbacks were registered is not lost.
20 *
21 * Without a service, open() fails.
22 */
23class MAYAFLUX_API NetworkSerialLink : public ISerialLink {
24public:
25 /**
26 * @param service The registered NetworkService. Not owned, and it must outlive the link.
27 */
29 ~NetworkSerialLink() override;
30
35
36 bool open(const std::string& path, const SerialLineSettings& line) override;
37 void close() override;
38 [[nodiscard]] EndpointState state() const override;
39 bool write(std::span<const uint8_t> bytes) override;
40 [[nodiscard]] size_t backlog() const override;
41 bool set_control_lines(std::optional<bool> dtr, std::optional<bool> rts) override;
42 bool send_break() override;
43 TimerToken post_after(std::chrono::milliseconds delay, std::function<void()> callback) override;
44 void cancel_post(TimerToken token) override;
45 void set_chunk_callback(ChunkCallback callback) override;
46 void set_state_callback(StateCallback callback) override;
47
48private:
49 struct Shared;
50
52 uint64_t m_endpoint { 0 };
55 std::shared_ptr<Shared> m_shared;
56};
57
58} // namespace MayaFlux::Core
EndpointState
Observable connection state for an endpoint.
Line setup applied when a serial endpoint opens.
Backend network transport service interface.