rtl_tcp: change device argument syntax to host[:port]

without any arguments the code will try to connect to localhost:1234
This commit is contained in:
Dimitri Stolnikov 2012-05-13 19:49:07 +02:00
parent 20d4ef7e4a
commit 8e82b44bff
2 changed files with 11 additions and 5 deletions

View File

@ -115,7 +115,7 @@ of devices. If left blank, the first device found will be used.
Examples (some arguments may be optional):
fcd=0
rtl=0,rtl_xtal=28.80001e6,tuner_xtal=26e6,buffers=64 ...
rtl_tcp=host=127.0.0.1,port=1234,psize=16384
rtl_tcp=127.0.0.1:1234,psize=16384
uhd=0|name,mcr=52e6,nchan=2,subdev='\\\\'B:0 A:0'\\\\' ...
osmosdr=0|name,mcr=64e6,nchan=5,port=/dev/ttyUSB0 ...
file=/path/to/file.ext,freq=428e6,rate=1e6,repeat=true,throttle=true ...

View File

@ -23,6 +23,7 @@
#include <sstream>
#include <boost/assign.hpp>
#include <boost/algorithm/string.hpp>
#include <gr_io_signature.h>
#include <gr_deinterleave.h>
@ -56,11 +57,16 @@ rtl_tcp_source_c::rtl_tcp_source_c(const std::string &args) :
dict_t dict = params_to_dict(args);
if (dict.count("host"))
host = dict["host"];
if (dict.count("rtl_tcp")) {
std::vector< std::string > tokens;
boost::algorithm::split( tokens, dict["rtl_tcp"], boost::is_any_of(":") );
if (dict.count("port"))
port = boost::lexical_cast< unsigned short >( dict["port"] );
if ( tokens[0].length() && (tokens.size() == 1 || tokens.size() == 2 ) )
host = tokens[0];
if ( tokens.size() == 2 ) // port given
port = boost::lexical_cast< unsigned short >( tokens[1] );
}
if (dict.count("psize"))
payload_size = boost::lexical_cast< int >( dict["psize"] );