40 name(owner.getName()),
48 localReader =
creator->create();
55 if (localReader !=
nullptr) {
57 localReader =
nullptr;
119 officialRoute = route;
135 info.incoming =
true;
142 if (
info.sourceName !=
"admin" &&
info.sourceName !=
"null") {
167 auto*
id =
reinterpret_cast<void*
>(
this);
180 if (
br.getReference() !=
nullptr) {
182 if (localReader !=
nullptr) {
183 bool ok = localReader->
read(
br);
184 if (!
br.isActive()) {
193 if (!
br.isActive()) {
209 if (!
br.isActive()) {
231 if (
br.isTextMode()) {
239 "Port command (%s): %s should add connection: %s",
248 "Port command (%s): %s should remove output: %s",
257 "Port command (%s): %s should remove input: %s",
273 if (
env.length() > 2) {
275 std::string
env2 =
env.substr(2,
env.length());
279 if (localReader !=
nullptr) {
281 if (!
br.isActive()) {
290 if (
modifier.inputModifier !=
nullptr) {
291 if (
modifier.inputModifier->acceptIncomingData(*
cr)) {
292 cr = &(
modifier.inputModifier->modifyIncomingData(*
cr));
297 skipIncomingData(*
cr);
304 skipIncomingData(
br);
306 if (!
br.isActive()) {
341 printf(
"Interrupt requested\n");
351 bw.appendLine(
"This is a YARP port. Here are the commands it responds to:");
352 bw.appendLine(
"* Gives a description of this port");
353 bw.appendLine(
"d Signals the beginning of input for the port's owner");
354 bw.appendLine(R
"(do The same as "d" except replies should be suppressed ("data-only"))");
355 bw.appendLine("q Disconnects");
357 bw.appendLine(
"i Interrupt parent process (unix only)");
359 bw.appendLine(
"r Reverse connection type to be a reader");
360 bw.appendLine(
"/port Requests to send output to /port");
361 bw.appendLine(
"!/port Requests to stop sending output to /port");
362 bw.appendLine(
"~/port Requests to stop receiving input from /port");
363 bw.appendLine(
"a Signals the beginning of an administrative message");
364 bw.appendLine(
"? Gives this help");
371 bw.appendLine(
"Port command not understood.");
372 bw.appendLine(
"Type d to send data to the port's owner.");
373 bw.appendLine(
"Type ? for help.");
399 std::string msg = std::string(
"Removing input from ") + route.
getFromName() +
" to " + route.
getToName();
416 info.incoming =
true;
417 info.created =
false;
423 if (
info.sourceName !=
"admin") {
428 if (localReader !=
nullptr) {
430 localReader =
nullptr;
495void PortCoreInputUnit::closeMain()
522 return officialRoute;
528 size_t pending = reader.
getSize();
530 while (pending > 0) {
532 size_t next = (pending <
sizeof(buf)) ? pending :
sizeof(buf);
554void 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.
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 removeOutput(const std::string &dest, void *id, yarp::os::OutputStream *os)
Remove an output connection.
void reportUnit(PortCoreUnit *unit, bool active)
Called by a connection handler with active=true just after it is fully configured,...
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.
void removeInput(const std::string &src, void *id, yarp::os::OutputStream *os)
Remove an input connection.
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.
int getpid()
Portable wrapper for the getppid() function.