38 name(owner.getName()),
46 localReader =
creator->create();
53 if (localReader !=
nullptr) {
55 localReader =
nullptr;
117 officialRoute = route;
133 info.incoming =
true;
140 if (
info.sourceName !=
"admin" &&
info.sourceName !=
"null") {
165 auto*
id =
reinterpret_cast<void*
>(
this);
178 if (
br.getReference() !=
nullptr) {
180 if (localReader !=
nullptr) {
181 bool ok = localReader->
read(
br);
182 if (!
br.isActive()) {
191 if (!
br.isActive()) {
207 if (!
br.isActive()) {
229 if (
br.isTextMode()) {
237 "Port command (%s): %s should add connection: %s",
246 "Port command (%s): %s should remove output: %s",
255 "Port command (%s): %s should remove input: %s",
270 std::string env = cmd.
getText();
271 if (env.length() > 2) {
273 std::string
env2 = env.substr(2, env.length());
277 if (localReader !=
nullptr) {
279 if (!
br.isActive()) {
288 if (
modifier.inputModifier !=
nullptr) {
289 if (
modifier.inputModifier->acceptIncomingData(*
cr)) {
290 cr = &(
modifier.inputModifier->modifyIncomingData(*
cr));
295 skipIncomingData(*
cr);
302 skipIncomingData(
br);
304 if (!
br.isActive()) {
341 bw.appendLine(
"This is a YARP port. Here are the commands it responds to:");
342 bw.appendLine(
"* Gives a description of this port");
343 bw.appendLine(
"d Signals the beginning of input for the port's owner");
344 bw.appendLine(R
"(do The same as "d" except replies should be suppressed ("data-only"))");
345 bw.appendLine("q Disconnects");
346 bw.appendLine(
"r Reverse connection type to be a reader");
347 bw.appendLine(
"/port Requests to send output to /port");
348 bw.appendLine(
"!/port Requests to stop sending output to /port");
349 bw.appendLine(
"~/port Requests to stop receiving input from /port");
350 bw.appendLine(
"a Signals the beginning of an administrative message");
351 bw.appendLine(
"? Gives this help");
358 bw.appendLine(
"Port command not understood.");
359 bw.appendLine(
"Type d to send data to the port's owner.");
360 bw.appendLine(
"Type ? for help.");
403 info.incoming =
true;
404 info.created =
false;
410 if (
info.sourceName !=
"admin") {
415 if (localReader !=
nullptr) {
417 localReader =
nullptr;
482void PortCoreInputUnit::closeMain()
509 return officialRoute;
541void PortCoreInputUnit::envelopeReadCallback(
void* data,
const Bytes& envelope)
A mini-server for performing network communication in the background.
bool setEnvelope(PortWriter &envelope) override
Set an envelope (e.g., a timestamp) to the next message which will be sent.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
A simple abstraction for a block of bytes.
An interface for reading from a network connection.
virtual size_t getSize() const =0
Checks how much data is available.
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
Simple abstraction for a YARP port name.
bool isRooted() const
Check if port name begins with "/".
The output side of an active connection between two ports.
virtual const Route & getRoute() const =0
virtual void rename(const Route &route)=0
Relabel the route after the fact (e.g.
Simple specification of the minimum functions needed from output streams.
Information about a port connection or event.
std::string message
A human-readable description of contents.
@ PORTINFO_CONNECTION
Information about an incoming or outgoing connection.
virtual bool read(ConnectionReader &reader)=0
Read this object from a network connection.
A class for storing options and configuration information.
Information about a connection between two ports.
const std::string & getToName() const
Get the destination of the route.
const std::string & getCarrierName() const
Get the carrier type of the route.
std::string toString() const
Render a text form of the route, "source->carrier->dest".
const std::string & getFromName() const
Get the source of the route.
void swapNames()
Swap from and to names.
void wait()
Decrement the counter, even if we must wait to do that.
void post()
Increment the counter.
A helper for creating cached object descriptions.
Simple Readable and Writable object representing a command to a YARP port.
bool read(yarp::os::ConnectionReader &reader) override
Read this object from a network connection.
This manages a single threaded resource related to a single input or output connection.
void setMode()
Check the carrier used for the connection, and see if it has a "log" modifier.
void setDoomed()
Request that this connection be shut down as soon as possible.
bool readBlock(ConnectionReader &reader, void *id, yarp::os::OutputStream *os)
Read a block of regular payload data.
yarp::os::PortReaderCreator * getReadCreator()
Get the creator of callbacks.
bool removeInput(const std::string &src, void *id, yarp::os::OutputStream *os)
Remove an input connection.
void setEnvelope(const std::string &envelope)
Set some envelope information to pass along with a message without actually being part of the message...
bool removeIO(const Route &route, bool synch=false)
Remove any connection matching the supplied route.
void report(const yarp::os::PortInfo &info)
Handle a port event (connection, disconnection, etc) Generate a description of the connections associ...
void reportUnit(PortCoreUnit *unit, bool active)
Called by a connection handler with active=true just after it is fully configured,...
bool removeOutput(const std::string &dest, void *id, yarp::os::OutputStream *os)
Remove an output connection.
void describe(void *id, yarp::os::OutputStream *os)
Produce a text description of the port and its connections.
bool adminBlock(ConnectionReader &reader, void *id)
Read a block of administrative data.
yarp::os::impl::PortDataModifier & getPortModifier()
bool addOutput(const std::string &dest, void *id, yarp::os::OutputStream *os, bool onlyIfNeeded=false)
Add an output connection to this port.
This is the heart of a yarp port.
int join(double seconds=-1)
#define yCIAssert(component, id, x)
#define yCIInfo(component, id,...)
#define yCITrace(component, id,...)
#define yCIDebug(component, id,...)
#define YARP_OS_LOG_COMPONENT(name, name_string)
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.