|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
33 return twiddlerReader.read(b);
36 if (phase==-1)
return -1;
40 if (scan.length()>0) {
42 remaining = scan.length();
45 remaining = header.blobLen;
53 if (expectTwiddle&&initiative) {
58 Bytes twiddle_buf(twiddle,1);
59 delegate->getInputStream().readFull(twiddle_buf);
63 Bytes mlen_buf(mlen,4);
64 int res = delegate->getInputStream().readFull(mlen_buf);
77 int res = delegate->getInputStream().readFull(scan.bytes());
84 int len_scan = scan.length();
97 if (scan.length()>0) {
99 remaining = scan.length();
102 remaining = header.blobLen;
106 remaining = header.blobLen;
110 cursor = (
char*) &header;
111 remaining =
sizeof(header);
116 if (cursor!=
nullptr) {
117 int allow = remaining;
118 if ((
int)b.
length()<allow) {
121 memcpy(b.
get(),cursor,allow);
127 int result = delegate->getInputStream().read(b);
142 if (!setInitiative) {
144 setInitiative =
true;
147 delegate->getOutputStream().write(b);
152 string code = rosToKind(kind);
154 configureTwiddler(twiddler,code.c_str(),kind,sender,reply);
163 std::map<std::string, std::string> kinds;
164 kinds[
"std_msgs/String"] =
"vector string 1 *";
165 kinds[
"std_msgs/Int32"] =
"vector int32 1 *";
166 kinds[
"std_msgs/Float64"] =
"vector float64 1 *";
170 kinds[
"sensor_msgs/Image"] =
"list 4 skip uint32 * skip uint32 * skip uint32 * skip string * >height uint32 * >width uint32 * >encoding string * skip int8 * >step int32 * compute image_params <=[mat] vocab * <translated_encoding vocab * item_vector int32 5 <depth item * <img_size item * <quantum item * <width item * <height item * blob *";
172 kinds[
"test_roscpp/TestStringString"] =
"vector string 1 * --- vector string 1 *";
178 if (std::string(rosname)==
"")
return {};
179 std::map<std::string, std::string> kinds = rosToKind();
181 if (kinds.find(rosname)!=kinds.end()) {
182 return kinds[rosname];
188 cmd.
addString(std::string(
"twiddle ") + rosname);
190 port.
write(cmd,resp);
193 if (txt!=
"?")
return txt;
196 if (std::string(rosname)!=
"") {
207 sender?
"sender":
"receiver",
208 reply?
"reply":
"main");
209 std::string str(txt);
211 size_t idx = str.find(
"---");
212 if (idx!=std::string::npos) {
213 str = str.substr(idx+3,str.length());
216 str = std::string(
"skip int32 * ") + str;
218 str = std::string(
"skip int8 * ") + str;
220 return twiddler.
configure(str.c_str(),prompt);
void close() override
Stop port activity.
A simple collection of objects that can be described and transmitted in a portable way.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
static std::map< std::string, std::string > rosToKind()
void updateKind(const char *kind, bool sender, bool reply)
static bool configureTwiddler(yarp::wire_rep_utils::WireTwiddler &twiddler, const char *txt, const char *prompt, bool sender, bool reply)
bool addOutput(const std::string &name) override
Add an output connection to the specified port.
A mini-server for network communication.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
virtual std::string asString() const
Get string value.
static char * checkBottle(char *cursor, int &remaining, int ct, int list_tag)
bool configure(const char *txt, const char *prompt)
void write(const yarp::os::Bytes &b) override
Write a block of bytes to the stream.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
A simple abstraction for a block of bytes.
#define yCError(component,...)
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
An interface to the operating system, including Port based communication.
bool openFake(const std::string &name)
Start port without making it accessible from the network.
#define yCTrace(component,...)
static int netInt(const yarp::os::Bytes &code)
const yarp::os::LogComponent & TCPROSCARRIER()