43 if (!writer.
writeString(
"getRemoteProtocolVersion")) {
57 if (!helper_proto.read(connection)) {
67 if(!
yarp().canWrite()) {
68 yError(
" Missing server method ISerialMsgs::getRemoteProtocolVersion");
73 return helper.helper_proto;}
84 if (remproto.protocol_version != locproto.protocol_version)
86 yCError(SERVICE_LOG_COMPONENT) <<
"Invalid communication protocol.";
87 yCError(SERVICE_LOG_COMPONENT) <<
"Local Protocol Version: " << locproto.toString();
88 yCError(SERVICE_LOG_COMPONENT) <<
"Remote Protocol Version: " << remproto.toString();
163 static constexpr const char*
s_tag{
"setDTR"};
167 static constexpr const char*
s_prototype{
"bool ISerialMsgs::setDTR(const bool enable)"};
221 static constexpr const char*
s_tag{
"flush"};
225 static constexpr const char*
s_prototype{
"std::int32_t ISerialMsgs::flush()"};
256 return write(writer);
271 if (!writeTag(writer)) {
274 if (!writeArgs(writer)) {
298 if (!readTag(reader)) {
301 if (!readArgs(reader)) {
340 return write(writer);
371 if (!reader.
readBool(return_helper)) {
400 return write(writer);
415 if (!writeTag(writer)) {
418 if (!writeArgs(writer)) {
439 if (!readTag(reader)) {
442 if (!readArgs(reader)) {
473 return write(writer);
488 if (!writer.
writeI32(return_helper)) {
504 if (!reader.
readI32(return_helper)) {
519 yarp().setOwner(*
this);
524 if (!
yarp().canWrite()) {
528 bool ok =
yarp().write(helper, helper);
529 return ok ? helper.reply.return_helper :
bool{};
534 if (!
yarp().canWrite()) {
538 bool ok =
yarp().write(helper, helper);
539 return ok ? helper.reply.return_helper : std::int32_t{};
545 bool showAll = (functionName ==
"--all");
546 std::vector<std::string> helpString;
548 helpString.emplace_back(
"*** Available commands:");
551 helpString.emplace_back(
"help");
559 if (functionName ==
"help") {
560 helpString.emplace_back(
"std::vector<std::string> help(const std::string& functionName = \"--all\")");
561 helpString.emplace_back(
"Return list of available commands, or help message for a specific function");
562 helpString.emplace_back(
"@param functionName name of command for which to get a detailed description. If none or '--all' is provided, print list of available commands");
563 helpString.emplace_back(
"@return list of strings (one string per line)");
566 if (helpString.empty()) {
567 helpString.emplace_back(
"Command not found");
575 constexpr size_t max_tag_len = 1;
585 std::string tag = reader.
readTag(1);
586 bool direct = (tag ==
"__direct__");
590 while (tag_len <= max_tag_len && !reader.
isError()) {
591 if(tag ==
"getRemoteProtocolVersion") {
598 auto proto = getLocalProtocolVersion();
604 if (!writer.
write(proto)) {
642 std::string functionName;
644 functionName =
"--all";
646 auto help_strings = help(functionName);
652 if (!writer.
writeTag(
"many", 1, 0)) {
658 for (
const auto& help_string : help_strings) {
674 std::string next_tag = reader.
readTag(1);
675 if (next_tag.empty()) {
678 tag.append(
"_").append(next_tag);
679 tag_len = std::count(tag.begin(), tag.end(),
'_') + 1;
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
~Command() override=default
bool writeTag(const yarp::os::idl::WireWriter &writer) const
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool readArgs(yarp::os::idl::WireReader &reader)
bool readTag(yarp::os::idl::WireReader &reader)
std::int32_t return_helper
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
~Reply() override=default
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr size_t s_reply_len
static constexpr size_t s_tag_len
static constexpr const char * s_tag
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
std::int32_t(*)() funcptr_t
static constexpr size_t s_cmd_len
static constexpr const char * s_help
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
ISerialMsgs_flush_helper()=default
void call(ISerialMsgs *ptr)
static constexpr const char * s_prototype
ISerialMsgs_getRemoteProtocolVersion_helper()=default
yarp::os::ApplicationNetworkProtocolVersion helper_proto
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
~Command() override=default
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool readArgs(yarp::os::idl::WireReader &reader)
bool readTag(yarp::os::idl::WireReader &reader)
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool writeTag(const yarp::os::idl::WireWriter &writer) const
~Reply() override=default
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr const char * s_help
bool(*)(const bool) funcptr_t
static constexpr size_t s_tag_len
void call(ISerialMsgs *ptr)
static constexpr const char * s_tag
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr size_t s_reply_len
ISerialMsgs_setDTR_helper()=default
static constexpr size_t s_cmd_len
static constexpr const char * s_prototype
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
virtual yarp::os::ApplicationNetworkProtocolVersion getRemoteProtocolVersion()
virtual bool checkProtocolVersion()
virtual std::vector< std::string > help(const std::string &functionName="--all")
virtual bool setDTR(const bool enable)
virtual yarp::os::ApplicationNetworkProtocolVersion getLocalProtocolVersion()
virtual std::int32_t flush()
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
short int protocol_version
An interface for reading from a network connection.
An interface for writing to a network connection.
This is a base class for objects that can be both read from and be written to the YARP network.
bool write(PortWriter &writer)
Write a message to the associated port or reader.
yarp::os::WireLink & yarp()
Get YARP state associated with this object.
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
IDL-friendly connection reader.
bool readString(std::string &str, bool *is_vocab=nullptr)
bool readI32(std::int32_t &x)
std::string readTag(size_t len=static_cast< size_t >(-1))
IDL-friendly connection writer.
bool writeBool(bool x, bool skip_tag=false) const
bool write(const WirePortable &obj) const
bool writeI32(std::int32_t x, bool skip_tag=false) const
bool writeListHeader(int len) const
bool writeTag(const char *tag, int split, int len) const
bool writeString(const std::string &str, bool skip_tag=false) const
bool writeListEnd() const
bool writeListBegin(int tag, size_t len) const
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
The main, catch-all namespace for YARP.
#define YARP_VERSION_PATCH
#define YARP_VERSION_MAJOR
#define YARP_VERSION_MINOR