kopia lustrzana https://github.com/pabr/leansdr
Porównaj commity
2 Commity
0aadfca874
...
e387882419
Autor | SHA1 | Data |
---|---|---|
pabr | e387882419 | |
pabr | facaffe9d6 |
|
@ -1,4 +1,5 @@
|
|||
HEAD
|
||||
* leandvb: Added --ts-udp.
|
||||
* leandvbtx: Added real-time mode (-fill).
|
||||
* leansdrserv: Network access to leansdr command pipelines.
|
||||
* leaniio{rx,tx}: PlutoSDR support via libiio.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// This file is part of LeanSDR Copyright (C) 2016-2018 <pabr@pabr.org>.
|
||||
// This file is part of LeanSDR Copyright (C) 2016-2022 <pabr@pabr.org>.
|
||||
// See the toplevel README for more information.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
@ -33,6 +33,7 @@
|
|||
#include "leansdr/rs.h"
|
||||
#include "leansdr/gui.h"
|
||||
#include "leansdr/filtergen.h"
|
||||
#include "leansdr/network.h"
|
||||
|
||||
#include "leansdr/hdlc.h"
|
||||
#include "leansdr/iess.h"
|
||||
|
@ -100,6 +101,7 @@ struct config {
|
|||
int fd_const; // FD for constellation and symbols, or -1
|
||||
int fd_spectrum; // FD for spectrum data, or -1
|
||||
bool json; // Use JSON syntax
|
||||
const char *udp_dst; // Output TS to this IP:PORT instead of stdout
|
||||
|
||||
config()
|
||||
: verbose(false),
|
||||
|
@ -156,7 +158,8 @@ struct config {
|
|||
Finfo(5),
|
||||
fd_const(-1),
|
||||
fd_spectrum(-1),
|
||||
json(false) {
|
||||
json(false),
|
||||
udp_dst(NULL) {
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -579,7 +582,10 @@ struct runtime_common {
|
|||
// Standard-specific code would go here,
|
||||
// outputting into p_tspackets and into the measurements channels.
|
||||
|
||||
new file_writer<tspacket>(sch, *p_tspackets, 1);
|
||||
if ( cfg.udp_dst )
|
||||
new udp_output<tspacket>(sch, *p_tspackets, cfg.udp_dst, 7);
|
||||
else
|
||||
new file_writer<tspacket>(sch, *p_tspackets, 1);
|
||||
|
||||
// BER ESTIMATION
|
||||
|
||||
|
@ -1389,6 +1395,7 @@ void usage(const char *name, FILE *f, int c, const char *info=NULL) {
|
|||
" --rrc-steps INT RRC interpolation factor\n"
|
||||
" --rrc-rej FLOAT RRC filter rejection (defaut: 10)\n"
|
||||
" --roll-off FLOAT RRC roll-off (default: 0.35)\n"
|
||||
" --ts-udp IP:PORT Send TS to UDP address\n"
|
||||
);
|
||||
fprintf
|
||||
(f,
|
||||
|
@ -1619,6 +1626,8 @@ int main(int argc, const char *argv[]) {
|
|||
cfg.fd_spectrum = atoi(argv[++i]);
|
||||
else if ( ! strcmp(argv[i], "--json") )
|
||||
cfg.json = true;
|
||||
else if ( ! strcmp(argv[i], "--ts-udp") && i+1<argc )
|
||||
cfg.udp_dst = argv[++i];
|
||||
else
|
||||
usage(argv[0], stderr, 1, argv[i]);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
// This file is part of LeanSDR Copyright (C) 2016-2022 <pabr@pabr.org>.
|
||||
// See the toplevel README for more information.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef LEANSDR_NETWORK_H
|
||||
#define LEANSDR_NETWORK_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
namespace leansdr {
|
||||
|
||||
// [udp_output] sends over UDP, one item per packet.
|
||||
|
||||
template<typename T>
|
||||
struct udp_output : runnable {
|
||||
udp_output(scheduler *sch, pipebuf<T> &_in, const char *udpaddr,
|
||||
int _batch_size)
|
||||
: runnable(sch, _in.name),
|
||||
in(_in),
|
||||
batch_size(_batch_size)
|
||||
{
|
||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if ( sock < 0 ) fatal("socket");
|
||||
struct sockaddr_in addr;
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = ntohs(0);
|
||||
addr.sin_addr.s_addr = INADDR_ANY;
|
||||
if ( bind(sock,(sockaddr*)&addr,sizeof(addr)) < 0 ) fatal("bind");
|
||||
addr.sin_family = AF_INET;
|
||||
{
|
||||
const char *sep = strchr(udpaddr, ':');
|
||||
if ( ! sep ) fail("Expected IP:PORT");
|
||||
char *ipaddr = strndup(udpaddr, sep-udpaddr);
|
||||
int res = inet_aton(ipaddr, &addr.sin_addr);
|
||||
free(ipaddr);
|
||||
if ( ! res ) fatal("inet_aton");
|
||||
int port = atoi(sep+1);
|
||||
addr.sin_port = ntohs(port);
|
||||
if ( sch->verbose )
|
||||
fprintf(stderr, "Sending UDP to %s:%d\n", ipaddr, port);
|
||||
}
|
||||
if ( connect(sock,(sockaddr*)&addr,sizeof(addr)) < 0 ) fatal("connect");
|
||||
}
|
||||
void run() {
|
||||
while ( in.readable() >= batch_size ) {
|
||||
// Return values for asynchronous protocols are not very useful.
|
||||
// Just ignore them.
|
||||
(void)send(sock, in.rd(), sizeof(T)*batch_size, 0);
|
||||
in.read(batch_size);
|
||||
}
|
||||
}
|
||||
~udp_output() {
|
||||
close(sock);
|
||||
}
|
||||
private:
|
||||
pipereader<T> in;
|
||||
int sock;
|
||||
int batch_size;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // LEANSDR_NETWORK_H
|
Ładowanie…
Reference in New Issue