Allow non-blocking stdin for leandvbtx real-time mode.

master
pabr 2018-03-27 12:29:37 +02:00
rodzic 2e8fe2cb18
commit fe8771b8ec
3 zmienionych plików z 31 dodań i 0 usunięć

Wyświetl plik

@ -1,4 +1,8 @@
HEAD
* leandvbtx: Added real-time mode (-fill).
* leansdrserv: Network access to leansdr command pipelines.
* leaniio{rx,tx}: PlutoSDR support via libiio.
* leanmlmrx: Multi-channel FM demodulator.
* leandvb: Spectrum output, JSON syntax.
* leandvb, leandvbtx: DVB-S with non-standard constellations (with --viterbi).
* leandvb: Support all DVB-S code rates with --viterbi.

Wyświetl plik

@ -50,12 +50,14 @@ struct config {
float rolloff;
float rrc_rej;
enum { OUTPUT_F32, OUTPUT_S16 } output_format;
bool fill;
bool verbose, debug;
config()
: constellation(cstln_lut<256>::QPSK), fec(FEC12),
amp(1.0), agc(false),
interp(2), decim(1), rolloff(0.35), rrc_rej(10),
output_format(OUTPUT_F32),
fill(false),
verbose(false), debug(false)
{ }
};
@ -167,6 +169,14 @@ void run(config &cfg) {
fail("Output format not implemented");
}
if ( cfg.fill ) {
if ( cfg.verbose ) fprintf(stderr, "Realtime mode\n");
tspacket blank;
memset(blank.data, 0, 188);
blank.data[0] = 0x47;
r_stdin.set_realtime(blank);
}
sch.run();
sch.shutdown();
if ( sch.verbose ) sch.dump();
@ -192,6 +202,7 @@ void usage(const char *name, FILE *f, int c, const char *info=NULL) {
" --agc Better regulation of output power\n"
" --f32 Output 32-bit floats, range +-1.0 (default)\n"
" --s16 Output 16-bit ints\n"
" --fill Insert blank packets\n"
" -v Output debugging info at startup and exit\n"
" -d Output debugging info during operation\n"
" --version Display version and exit\n"
@ -272,6 +283,8 @@ int main(int argc, char *argv[]) {
cfg.output_format = config::OUTPUT_F32;
else if ( ! strcmp(argv[i], "--s16") )
cfg.output_format = config::OUTPUT_S16;
else if ( ! strcmp(argv[i], "--fill") )
cfg.fill = true;
else
usage(argv[0], stderr, 1, argv[i]);
}

Wyświetl plik

@ -3,6 +3,8 @@
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include "leansdr/math.h"
@ -20,6 +22,7 @@ struct file_reader : runnable {
file_reader(scheduler *sch, int _fdin, pipebuf<T> &_out)
: runnable(sch, _out.name),
loop(false),
filler(NULL),
fdin(_fdin), out(_out)
{
}
@ -29,6 +32,11 @@ struct file_reader : runnable {
again:
ssize_t nr = read(fdin, out.wr(), size);
if ( nr<0 && errno==EWOULDBLOCK && filler ) {
if ( sch->debug ) fprintf(stderr, "U");
out.write(*filler);
return;
}
if ( nr < 0 ) fatal("read");
if ( ! nr ) {
if ( ! loop ) return;
@ -52,7 +60,13 @@ struct file_reader : runnable {
out.written(nr / sizeof(T));
}
bool loop;
void set_realtime(T &_filler) {
int flags = fcntl(fdin, F_GETFL);
if ( fcntl(fdin, F_SETFL, flags|O_NONBLOCK) ) fatal("fcntl");
filler = new T(_filler);
}
private:
T *filler;
int fdin;
pipewriter<T> out;
};