sender.cpp

来自「一个语言识别引擎」· C++ 代码 · 共 31 行

CPP
31
字号
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-

/*
 * Copyright (C) 2006 Paul Fitzpatrick
 * CopyPolicy: Released under the terms of the GNU GPL v2.0.
 *
 */

// source for sender.cpp
#include <yarp/os/Port.h>
#include <yarp/os/Bottle.h>
#include <yarp/os/Time.h>
#include <stdio.h>

using namespace yarp::os;

int main() {
    Bottle bot1; 
    bot1.addString("testing"); // a simple message
    Port output;
    output.open("/out");
    for (int i=0; i<100; i++) {
        output.write(bot1);
        printf("Sent message: %s\n", bot1.toString().c_str());
        bot1.addInt(i); // change the message for next time
        Time::delay(1);
    }
    output.close();
    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?