YARP
Yet Another Robot Platform
os/view_count.cpp

View countdown messages coming from a port (paired with os/make_count.cpp example).

/*
* Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
* Copyright (C) 2006-2010 RobotCub Consortium
* All rights reserved.
*
* This software may be modified and distributed under the terms of the
* BSD-3-Clause license. See the accompanying LICENSE file for details.
*/
#include <yarp/os/all.h>
#include <stdio.h>
using namespace yarp::os;
int main(int argc, char *argv[]) {
if (argc!=2) return 1;
in.open(argv[1]);
int count = 1;
while (count>0) {
Bottle *msg = in.read();
count = msg->get(1).asInt32();
printf("at %d\n", count);
}
return 0;
}
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:72
all.h
yarp::os::BufferedPort::read
T * read(bool shouldWait=true) override
Read an available object from the port.
Definition: BufferedPort-inl.h:154
main
int main(int argc, char *argv[])
Definition: yarpros.cpp:259
yarp::os::BufferedPort
A mini-server for performing network communication in the background.
Definition: BufferedPort.h:63
yarp::os::Bottle::get
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:249
yarp::os::BufferedPort::open
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition: BufferedPort-inl.h:41
yarp::os::Value::asInt32
virtual std::int32_t asInt32() const
Get 32-bit integer value.
Definition: Value.cpp:207
yarp::os
Definition: AbstractCarrier.h:17
yarp::os::Network
Definition: Network.h:781
yarp
Definition: numeric.h:47