33{
36 "Serial link {} needs a NetworkService", path);
37 return false;
38 }
39
41
42 auto shared = std::make_shared<Shared>();
45
46 EndpointInfo info;
50 info.remote_path = path;
51 info.label = path;
53
54 const uint64_t endpoint =
m_service->open_endpoint(info);
55 if (endpoint == 0) {
57 "Serial link could not open {}: the port must exist, or the serial transport must be enabled in GlobalNetworkConfig and set to reconnect",
58 path);
59 return false;
60 }
61
64 const std::weak_ptr<Shared> weak = shared;
65
66 m_service->set_endpoint_receive_callback(endpoint,
67 [weak](uint64_t, const uint8_t* data, size_t size, std::string_view) {
68 if (const auto held = weak.lock(); held && held->chunk) {
69 held->chunk(std::span<const uint8_t> { data, size });
70 }
71 });
72
73 if (
m_service->set_endpoint_state_callback) {
74 m_service->set_endpoint_state_callback(endpoint,
76 if (const auto held = weak.lock()) {
77 held->report(current);
78 }
79 });
80 }
81
83 shared->report(
m_service->get_endpoint_state(endpoint));
84 }
85
86 return true;
87}
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
Registry::Service::NetworkService * m_service
void close() override
Close the port.
std::shared_ptr< Shared > m_shared
EndpointState
Observable connection state for an endpoint.
@ InputBackend
Input device backend (HID, MIDI, OSC).
@ Core
Core engine, backend, subsystems.
Vruta::SoundRoutine line(float start_value, float end_value, float duration_seconds, uint32_t step_duration, bool restartable)
Creates a continuous interpolation generator between two values over time.