Пример #1
0
    /**
     *
     * Give a reply to a previously read message.
     *
     */
YARP_DEFINE(int) yarpPortReply(yarpPortPtr port,
                               yarpPortablePtr msg) {
    YARP_OK(port);
    Portable *amsg = MAKE_PORTABLE(msg);
    YARP_OK0(amsg);
    return YARP_PORT(port).reply(*amsg)?0:-1;
}
Пример #2
0
    /**
     *
     * Read text from a connection.
     *
     */
YARP_DEFINE(int) yarpReaderExpectText(yarpReaderPtr reader, 
                                      yarpStringPtr str,
                                      char terminal) {
    YARP_OK(reader);
    YARP_STRING(str) = YARP_READER(reader).expectText(terminal);
    return YARP_READER(reader).isError()?-1:0;
}
Пример #3
0
    /**
     *
     * Set the port name of a contact.
     *
     */
YARP_DEFINE(int) yarpContactSetName(yarpContactPtr contact,
                                    const char *name) {
    YARP_OK(contact);
    // contact class is very awkward
    YARP_CONTACT(contact) = Contact::byName(name);
    return 0;
}
Пример #4
0
    /**
     *
     * Read a floating point number from a connection.
     *
     */
YARP_DEFINE(int) yarpReaderExpectDouble(yarpReaderPtr reader, double *data) {
    YARP_OK(reader);
    double x = YARP_READER(reader).expectDouble();
    if (data!=NULL) {
        *data = x;
    }
    return YARP_READER(reader).isError()?-1:0;
}
Пример #5
0
    /**
     *
     * Read an integer from a connection.
     *
     */
YARP_DEFINE(int) yarpReaderExpectInt(yarpReaderPtr reader, int *data) {
    YARP_OK(reader);
    int x = YARP_READER(reader).expectInt();
    if (data!=NULL) {
        *data = x;
    }
    return YARP_READER(reader).isError()?-1:0;
}
Пример #6
0
    /**
     *
     * Write a message to a port.  The write handler of the msg structure
     * will be called.
     *
     */
YARP_DEFINE(int) yarpPortWrite(yarpPortPtr port,
                               yarpPortablePtr msg) {
    YARP_OK(port);
    Portable *amsg = MAKE_PORTABLE(msg);
    YARP_OK0(amsg);
    int result = YARP_PORT(port).write(*amsg)?0:-1;
    return result;
}
Пример #7
0
    /**
     *
     * Write a message to a port, then wait for a reply.
     *
     */
YARP_DEFINE(int) yarpPortWriteWithReply(yarpPortPtr port,
                                        yarpPortablePtr msg,
                                        yarpPortablePtr reply) {
    YARP_OK(port);
    Portable *amsg = MAKE_PORTABLE(msg);
    YARP_OK0(amsg);
    Portable *areply = MAKE_PORTABLE(reply);
    YARP_OK0(areply);
    return YARP_PORT(port).write(*amsg,*areply)?0:-1;
}
Пример #8
0
    /**
     *
     * Write an integer to a connection.
     *
     */
YARP_DEFINE(int) yarpWriterAppendInt(yarpWriterPtr writer, int data) {
    YARP_OK(writer);
    YARP_WRITER(writer).appendInt(data);
    return YARP_WRITER(writer).isError()?-1:0;
}
Пример #9
0
    /**
     *
     * Check if connection is text-mode
     *
     */
YARP_DEFINE(int) yarpReaderIsTextMode(yarpReaderPtr reader) {
    YARP_OK(reader);
    return YARP_READER(reader).isTextMode();
}
Пример #10
0
    /**
     *
     * Read a block of data from a connection.
     *
     */
YARP_DEFINE(int) yarpReaderExpectBlock(yarpReaderPtr reader, 
                                       const char *data,
                                       int len) {
    YARP_OK(reader);
    return !YARP_READER(reader).expectBlock(data,len);
}
Пример #11
0
    /**
     *
     * Close a port.
     *
     */
YARP_DEFINE(int) yarpPortClose(yarpPortPtr port) {
    YARP_OK(port);
    YARP_PORT(port).close();
    return 0;
}
Пример #12
0
    /**
     *
     * Open a port, using advanced contact information.
     *
     */
YARP_DEFINE(int) yarpPortOpenEx(yarpPortPtr port, yarpContactPtr contact) {
    YARP_OK(port);
    YARP_OK(contact);
    bool ok = YARP_PORT(port).open(YARP_CONTACT(contact));
    return ok?0:-1;
}
Пример #13
0
    /**
     *
     * Open a port, assigning it a name.
     *
     */
YARP_DEFINE(int) yarpPortOpen(yarpPortPtr port, const char *name) {
    YARP_OK(port);
    bool ok = YARP_PORT(port).open(name);
    return ok?0:-1;
}
Пример #14
0
    /**
     *
     * Configure a port to write messages in the background, so calls to
     * write messages may return immediately.
     *
     */
YARP_DEFINE(int) yarpPortEnableBackgroundWrite(yarpPortPtr port,
                                               int writeInBackgroundFlag) {
    YARP_OK(port);
    YARP_PORT(port).enableBackgroundWrite(writeInBackgroundFlag);
    return 0;
}