-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2434 from randaz81/yarp_repeat
yarp repeat
- Loading branch information
Showing
5 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
yarp_repeat {#master} | ||
------------------------- | ||
|
||
## Important Changes | ||
|
||
### Yarp companion | ||
|
||
#### added command `yarp repeat` | ||
* `yarp repeat` repeats in an output port all data received in an input port. The command is useful to control stream flows on a wifi/mobile connection. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/libYARP_companion/src/yarp/companion/impl/Companion.cmdRepeat.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT) | ||
* 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/companion/impl/Companion.h> | ||
|
||
#include <yarp/os/Bottle.h> | ||
#include <yarp/os/BufferedPort.h> | ||
#include <yarp/os/Network.h> | ||
#include <yarp/os/Property.h> | ||
|
||
using yarp::companion::impl::Companion; | ||
using yarp::os::Bottle; | ||
using yarp::os::BufferedPort; | ||
using yarp::os::NetworkBase; | ||
using yarp::os::Property; | ||
|
||
int Companion::cmdRepeat(int argc, char *argv[]) | ||
{ | ||
BufferedPort<Bottle> port; | ||
|
||
Property options; | ||
options.fromCommand(argc, argv, false); | ||
if (argc==0 || options.check("help")) | ||
{ | ||
yCInfo(COMPANION, "This is yarp repeat. Syntax:"); | ||
yCInfo(COMPANION, " yarp repeat /port"); | ||
yCInfo(COMPANION, "/port is both the input port and the output port which repeats data"); | ||
return 1; | ||
} | ||
|
||
if (argc==1) | ||
{ | ||
if (!port.open(argv[0])) | ||
{ | ||
yCError(COMPANION, "Failed to open port: %s", argv[0]); | ||
return 1; | ||
} | ||
} | ||
else | ||
{ | ||
yCError(COMPANION, "Invalid command syntax"); | ||
return 1; | ||
} | ||
|
||
while (true) | ||
{ | ||
Bottle *bot = port.read(); | ||
if (!bot) continue; | ||
if (port.getOutputCount()>0) | ||
{ | ||
port.prepare() = *bot; | ||
port.write(); | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters