MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ add_port()

uint32_t MayaFlux::Core::SerialInputBackend::add_port ( const SerialPortConfig & port)

List a port that was not configured, or update one that was while it is closed.

Returns
The device id, or 0 before initialize().

A port already listed under the same path keeps its id and takes the new line setup and protocol unless it is open.

Definition at line 412 of file SerialInputBackend.cpp.

413{
414 if (!m_initialized.load()) {
415 return 0;
416 }
417
418 uint32_t id = 0;
419 m_roster.update([&](Roster& roster) {
420 id = id_for(roster, "c:" + port.port_name);
421 const auto it = roster.entries.find(id);
422 if (it == roster.entries.end()) {
423 roster.entries.insert_or_assign(id,
424 make_entry(id, port.port_name, port.port_name, port.line, port.protocol, true));
425 return true;
426 }
427 if (it->second.device) {
428 return false;
429 }
430 Entry changed = make_entry(id, port.port_name, port.port_name, port.line, port.protocol, true);
431 changed.info.is_connected = it->second.info.is_connected;
432 roster.entries.insert_or_assign(id, std::move(changed));
433 return true;
434 });
435 return id;
436}
static uint32_t id_for(Roster &roster, const std::string &key)
static Entry make_entry(uint32_t id, const std::string &path, const std::string &name, const SerialLineSettings &line, const SerialProtocolSettings &protocol, bool configured)
Memory::SnapshotCell< Roster > m_roster

References add_port(), MayaFlux::Core::SerialInputBackend::Roster::entries, id_for(), MayaFlux::Core::SerialInputBackend::Entry::info, MayaFlux::Core::InputDeviceInfo::is_connected, MayaFlux::Core::SerialPortConfig::line, m_initialized, m_roster, make_entry(), MayaFlux::Core::SerialPortConfig::port_name, and MayaFlux::Core::SerialPortConfig::protocol.

Referenced by add_port().

Here is the call graph for this function:
Here is the caller graph for this function: