Skip to content

Commit

Permalink
iox-eclipse-iceoryx#989 Use new SubscriberOptions serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
elBoberido committed Jan 5, 2022
1 parent 403efa8 commit d6b218f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 39 deletions.
44 changes: 9 additions & 35 deletions iceoryx_posh/source/roudi/roudi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void RouDi::processMessage(const runtime::IpcMessage& message,
}
case runtime::IpcMessageType::CREATE_SUBSCRIBER:
{
if (message.getNumberOfElements() != 9)
if (message.getNumberOfElements() != 5)
{
LogError() << "Wrong number of parameters for \"IpcMessageType::CREATE_SUBSCRIBER\" from \"" << runtimeName
<< "\"received!";
Expand All @@ -288,53 +288,27 @@ void RouDi::processMessage(const runtime::IpcMessage& message,
}

const auto& service = deserializationResult.value();
cxx::Serialization portConfigInfoSerialization(message.getElementAtIndex(8));

if (!service.isValid())
{
LogError() << "Invalid service description '" << message.getElementAtIndex(2).c_str() << "' provided\n";
break;
}

popo::SubscriberOptions options;
uint64_t historyRequest;
if (!cxx::convert::fromString(message.getElementAtIndex(3).c_str(), historyRequest))
{
LogError() << "Invalid parameter for \"IpcMessageType::CREATE_SUBSCRIBER\"! '"
<< message.getElementAtIndex(3).c_str() << "' cannot be extracted from string\n";
break;
}
options.historyRequest = historyRequest;
uint64_t queueCapacity;
if (!cxx::convert::fromString(message.getElementAtIndex(4).c_str(), queueCapacity))
auto subscriberOptionsDeserializationResult =
popo::SubscriberOptions::deserialize(cxx::Serialization(message.getElementAtIndex(3)));
if (subscriberOptionsDeserializationResult.has_error())
{
LogError() << "Invalid parameter for \"IpcMessageType::CREATE_SUBSCRIBER\"! '"
<< message.getElementAtIndex(4).c_str() << "' cannot be extracted from string\n";
break;
}
options.queueCapacity = queueCapacity;
options.nodeName = NodeName_t(cxx::TruncateToCapacity, message.getElementAtIndex(5));

uint32_t subscribeOnCreate;
if (!cxx::convert::fromString(message.getElementAtIndex(6).c_str(), subscribeOnCreate))
{
LogError() << "Invalid parameter for \"IpcMessageType::CREATE_SUBSCRIBER\"! '"
<< message.getElementAtIndex(6).c_str() << "' cannot be extracted from string\n";
LogError() << "Deserialization of 'SubscriberOptions' failed when '"
<< message.getElementAtIndex(3).c_str() << "' was provided\n";
break;
}
options.subscribeOnCreate = (0U == subscribeOnCreate ? false : true);
const auto& subscriberOptions = subscriberOptionsDeserializationResult.value();

uint8_t queueFullPolicy{};
if (!cxx::convert::fromString(message.getElementAtIndex(7).c_str(), queueFullPolicy))
{
LogError() << "Invalid parameter for \"IpcMessageType::CREATE_SUBSCRIBER\"! '"
<< message.getElementAtIndex(7).c_str() << "' cannot be extracted from string\n";
break;
}
options.queueFullPolicy = static_cast<popo::QueueFullPolicy>(queueFullPolicy);
cxx::Serialization portConfigInfoSerialization(message.getElementAtIndex(4));

m_prcMgr->addSubscriberForProcess(
runtimeName, service, options, iox::runtime::PortConfigInfo(portConfigInfoSerialization));
runtimeName, service, subscriberOptions, iox::runtime::PortConfigInfo(portConfigInfoSerialization));
}
break;
}
Expand Down
5 changes: 1 addition & 4 deletions iceoryx_posh/source/runtime/posh_runtime_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,7 @@ PoshRuntimeImpl::getMiddlewareSubscriber(const capro::ServiceDescription& servic

IpcMessage sendBuffer;
sendBuffer << IpcMessageTypeToString(IpcMessageType::CREATE_SUBSCRIBER) << m_appName
<< static_cast<cxx::Serialization>(service).toString() << cxx::convert::toString(options.historyRequest)
<< cxx::convert::toString(options.queueCapacity) << options.nodeName
<< cxx::convert::toString(options.subscribeOnCreate)
<< cxx::convert::toString(static_cast<uint8_t>(options.queueFullPolicy))
<< static_cast<cxx::Serialization>(service).toString() << options.serialize().toString()
<< static_cast<cxx::Serialization>(portConfigInfo).toString();

auto maybeSubscriber = requestSubscriberFromRoudi(sendBuffer);
Expand Down

0 comments on commit d6b218f

Please sign in to comment.