--fd-info: Report number of packets since lock

pull/4/head
pabr 2017-01-29 02:11:06 +01:00
rodzic 7de4cb16db
commit e94756423d
2 zmienionych plików z 31 dodań i 4 usunięć

Wyświetl plik

@ -54,6 +54,7 @@ struct config {
float duration; // Horizontal span of timeline GUI (s)
bool linger; // Keep GUI running after EOF
int fd_info; // FD for status information in text format, or -1
float Finfo; // Desired refresh rate on fd_info (Hz)
int fd_const; // FD for constellation and symbols, or -1
config()
@ -89,10 +90,16 @@ struct config {
duration(60),
linger(false),
fd_info(-1),
Finfo(2),
fd_const(-1) {
}
};
int decimation(float Fin, float Fout) {
int d = Fin / Fout;
return max(d, 1);
}
int run(config &cfg) {
int w_timeline = 512, h_timeline = 256;
@ -415,7 +422,9 @@ int run(config &cfg) {
pipebuf<u8> p_mpegbytes(&sch, "mpegbytes", BUF_MPEGBYTES);
pipebuf<int> p_lock(&sch, "lock", BUF_SLOW);
mpeg_sync<u8,0> r_sync(&sch, p_bytes, p_mpegbytes, r_deconv, &p_lock);
pipebuf<u32> p_locktime(&sch, "locktime", BUF_PACKETS);
mpeg_sync<u8,0> r_sync(&sch, p_bytes, p_mpegbytes, r_deconv,
&p_lock, &p_locktime);
r_sync.fastlock = cfg.fastlock;
// DEINTERLEAVING
@ -457,6 +466,8 @@ int run(config &cfg) {
new file_printer<f32>(&sch, "SS %f\n", p_ss, cfg.fd_info);
new file_printer<f32>(&sch, "MER %.1f\n", p_mer, cfg.fd_info);
new file_printer<int>(&sch, "LOCK %d\n", p_lock, cfg.fd_info);
new file_printer<u32>(&sch, "LOCKTIME %lu\n", p_locktime, cfg.fd_info,
decimation(cfg.Fm/8/204, cfg.Finfo)); // TBD CR
new file_printer<f32>(&sch, "CNR %.1f\n", p_cnr, cfg.fd_info);
new file_printer<float>(&sch, "VBER %.6f\n", p_vber, cfg.fd_info);
// Output constants immediately
@ -676,7 +687,9 @@ int run_highspeed(config &cfg) {
pipebuf<u8> p_mpegbytes(&sch, "mpegbytes", BUF_MPEGBYTES);
pipebuf<int> p_lock(&sch, "lock", BUF_SLOW);
mpeg_sync<u8,0> r_sync(&sch, p_bytes, p_mpegbytes, NULL, &p_lock);
pipebuf<u32> p_locktime(&sch, "locktime", BUF_PACKETS);
mpeg_sync<u8,0> r_sync(&sch, p_bytes, p_mpegbytes, NULL,
&p_lock, &p_locktime);
r_sync.fastlock = true;
r_sync.resync_period = cfg.fastlock ? 1 : 32;
@ -717,6 +730,8 @@ int run_highspeed(config &cfg) {
new file_printer<f32>(&sch, "FREQ %.0f\n", p_freq, cfg.fd_info);
r_printfreq->scale = cfg.Fs;
new file_printer<int>(&sch, "LOCK %d\n", p_lock, cfg.fd_info);
new file_printer<u32>(&sch, "LOCKTIME %lu\n", p_locktime, cfg.fd_info,
decimation(cfg.Fm/8/204, cfg.Finfo)); // TBD CR
new file_printer<float>(&sch, "VBER %.6f\n", p_vber, cfg.fd_info);
// Output constants immediately
FILE *f = fdopen(cfg.fd_info, "w");

Wyświetl plik

@ -630,7 +630,8 @@ namespace leansdr {
pipebuf<Tbyte> &_in,
pipebuf<Tbyte> &_out,
deconvol_sync<Tbyte,0> *_deconv,
pipebuf<int> *_state_out=NULL)
pipebuf<int> *_state_out=NULL,
pipebuf<unsigned long> *_locktime_out=NULL)
: runnable(sch, "sync_detect"),
scan_syncs(8), want_syncs(4),
lock_timeout(4),
@ -644,6 +645,8 @@ namespace leansdr {
next_sync_count(0),
report_state(true) {
state_out = _state_out ? new pipewriter<int>(*_state_out) : NULL;
locktime_out =
_locktime_out ? new pipewriter<unsigned long>(*_locktime_out) : NULL;
}
void run() {
@ -738,6 +741,7 @@ namespace leansdr {
in.read(i); // Skip to first start code
synchronized = true;
lock_timeleft = lock_timeout;
locktime = 0;
if ( state_out ) {
*state_out->wr() = 1;
state_out->written(1);
@ -751,7 +755,8 @@ namespace leansdr {
void run_decoding() {
while ( in.readable() >= SIZE_RSPACKET+1 && // +1 for bit shifting
out.writable() >= SIZE_RSPACKET &&
( !state_out || state_out->writable()>=1 ) ) {
( !state_out || state_out->writable()>=1 ) &&
( !locktime_out || locktime_out->writable()>=1 ) ) {
Tbyte *pin = in.rd(), *pend = pin+SIZE_RSPACKET;
Tbyte *pout = out.wr();
unsigned short w = *pin++;
@ -762,6 +767,11 @@ namespace leansdr {
in.read(SIZE_RSPACKET);
Tbyte syncbyte = *out.wr();
out.written(SIZE_RSPACKET);
++locktime;
if ( locktime_out ) {
*locktime_out->wr() = locktime;
locktime_out->written(1);
}
// Reset timer if sync byte is correct
Tbyte expected = phase8 ? MPEG_SYNC : MPEG_SYNC_INV;
if ( syncbyte == expected ) lock_timeleft = lock_timeout;
@ -791,7 +801,9 @@ namespace leansdr {
int next_sync_count;
int phase8; // Position in 8-packet cycle, -1 if not synchronized
unsigned long lock_timeleft;
unsigned long locktime;
pipewriter<int> *state_out;
pipewriter<unsigned long> *locktime_out;
bool report_state;
};