diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2019-08-31 00:43:27 +0200 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2019-08-31 08:19:21 +0200 |
commit | 98abbe153b32f1687a949040dc5f58a6b01c3dd6 (patch) | |
tree | 305d4e16fc223337e048fc7ff8621343e1105bdf | |
parent | 041b22a4d7a11ead18b074b69dffcc840f7c18eb (diff) |
rtfwk: Add support to output annotation to allow for debuggingsylvain/live
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
-rw-r--r-- | src/gmr1_rx_live.c | 25 | ||||
-rw-r--r-- | src/rtfwk/common.c | 10 | ||||
-rw-r--r-- | src/rtfwk/common.h | 7 | ||||
-rw-r--r-- | src/rtfwk/sa_bcch_ccch.c | 27 | ||||
-rw-r--r-- | src/rtfwk/sa_tch3.c | 2 | ||||
-rw-r--r-- | src/rtfwk/sa_tch9.c | 2 |
6 files changed, 66 insertions, 7 deletions
diff --git a/src/gmr1_rx_live.c b/src/gmr1_rx_live.c index 808db89..f0f58a5 100644 --- a/src/gmr1_rx_live.c +++ b/src/gmr1_rx_live.c @@ -29,6 +29,7 @@ #include <osmocom/core/gsmtap_util.h> #include <osmocom/gmr1/sdr/fcch.h> +#include <osmocom/gmr1/sdr/metadata.h> #include "rtfwk/common.h" #include "rtfwk/sampbuf.h" @@ -96,6 +97,24 @@ int main(int argc, char *argv[]) as->chans[i].filename = d+1; } + /* Create meta data */ + for (i=0; i<as->n_chans; i++) + { + char *d; + int l; + + d = strrchr(as->chans[i].filename, '.'); + l = d ? (d - as->chans[i].filename) : strlen(as->chans[i].filename); + + d = malloc(l + 6); + memcpy(&d[0], as->chans[i].filename, l); + memcpy(&d[l], ".meta", 6); + + as->chans[i].md = gmr1_md_open(d, as->chans[i].filename, as->sps * GMR1_SYM_RATE); + + free(d); + } + /* Create all the sources */ for (i=0; i<as->n_chans; i++) { struct sample_actor *sa; @@ -165,6 +184,12 @@ int main(int argc, char *argv[]) /* Done ! */ rv = 0; + /* Flush metadata */ + for (i=0; i<as->n_chans; i++) + { + gmr1_md_close(as->chans[i].md); + } + /* Clean up */ err: sbuf_free(as->buf); diff --git a/src/rtfwk/common.c b/src/rtfwk/common.c index 0108025..a19b649 100644 --- a/src/rtfwk/common.c +++ b/src/rtfwk/common.c @@ -24,6 +24,7 @@ #include <osmocom/dsp/cxvec_math.h> #include <osmocom/gmr1/sdr/defs.h> +#include <osmocom/gmr1/sdr/metadata.h> #include <osmocom/gmr1/sdr/pi4cxpsk.h> #include "common.h" @@ -45,7 +46,8 @@ win_map(struct osmo_cxvec *win, int burst_map(struct osmo_cxvec *burst, float complex *data, int data_len, int base_align, int sps, - struct gmr1_pi4cxpsk_burst *burst_type, int tn, int win) + struct gmr1_pi4cxpsk_burst *burst_type, int tn, int win, + struct gmr1_md_annotation *mda) { int begin, len; int etoa; @@ -59,6 +61,12 @@ burst_map(struct osmo_cxvec *burst, osmo_cxvec_init_from_data(burst, &data[begin], len); + if (mda) { + gmr1_mda_add_field(mda, "core:sample_count", "%d", burst_type->len * sps); + gmr1_mda_add_field(mda, "core:freq_center", "%f", 31.25e3f); + gmr1_mda_add_field(mda, "core:freq_span", "%f", 31.25e3f); + } + return etoa; } diff --git a/src/rtfwk/common.h b/src/rtfwk/common.h index ec123c2..7006e49 100644 --- a/src/rtfwk/common.h +++ b/src/rtfwk/common.h @@ -33,6 +33,7 @@ struct gsmtap_inst; struct gmr1_pi4cxpsk_burst; +struct gmr1_md_annotation; struct app_state @@ -44,7 +45,7 @@ struct app_state int n_chans; int sps; - /* GSMTap */ + /* GSMTap and metadata */ struct gsmtap_inst *gti; /* Status */ @@ -54,6 +55,7 @@ struct app_state struct { int arfcn; char *filename; + struct gmr1_metadata *md; } chans[0]; }; @@ -66,7 +68,8 @@ win_map(struct osmo_cxvec *win, int burst_map(struct osmo_cxvec *burst, float complex *data, int data_len, int base_align, int sps, - struct gmr1_pi4cxpsk_burst *burst_type, int tn, int win); + struct gmr1_pi4cxpsk_burst *burst_type, int tn, int win, + struct gmr1_md_annotation *mda); float burst_energy(struct osmo_cxvec *burst); diff --git a/src/rtfwk/sa_bcch_ccch.c b/src/rtfwk/sa_bcch_ccch.c index a5ad95c..d1288c8 100644 --- a/src/rtfwk/sa_bcch_ccch.c +++ b/src/rtfwk/sa_bcch_ccch.c @@ -32,6 +32,7 @@ #include <osmocom/gmr1/l1/ccch.h> #include <osmocom/gmr1/sdr/defs.h> #include <osmocom/gmr1/sdr/pi4cxpsk.h> +#include <osmocom/gmr1/sdr/metadata.h> #include <osmocom/gmr1/sdr/nb.h> #include "common.h" @@ -138,6 +139,8 @@ _rx_bcch(struct sample_actor *sa, { struct bcch_sink_priv *priv = sa->priv; struct osmo_cxvec _burst, *burst = &_burst; + struct gmr1_metadata *md; + struct gmr1_md_annotation *mda; sbit_t ebits[424]; uint8_t l2[24]; float freq_err, toa; @@ -148,12 +151,16 @@ _rx_bcch(struct sample_actor *sa, sps = priv->as->sps; base_align = sps * BCCH_MARGIN; + /* Annotation */ + md = priv->as->chans[priv->chan_id].md; + mda = gmr1_md_get_annotation(md); + /* Debug */ fprintf(stderr, "[.] BCCH\n"); /* Demodulate burst */ e_toa = burst_map(burst, data, data_len, base_align, sps, - &gmr1_bcch_burst, priv->sa_bcch_stn, 20 * sps); + &gmr1_bcch_burst, priv->sa_bcch_stn, 20 * sps, mda); if (e_toa < 0) return e_toa; @@ -201,6 +208,11 @@ _rx_bcch(struct sample_actor *sa, priv->as->chans[priv->chan_id].arfcn, priv->fn, priv->sa_bcch_stn, l2, 24)); + /* Annotations */ + gmr1_mda_add_field(mda, "core:title", "\"BCCH\""); + gmr1_mda_add_field(mda, "core:comment", "\"crc=%d, conv=%d, align_err=%d\"", crc, conv, priv->align_err); + gmr1_md_put_annotation(md, mda, sa->time + base_align + (sps * priv->sa_bcch_stn * 39) + e_toa); + return 0; } @@ -224,6 +236,8 @@ _rx_ccch(struct sample_actor *sa, { struct bcch_sink_priv *priv = sa->priv; struct osmo_cxvec _burst, *burst = &_burst; + struct gmr1_metadata *md; + struct gmr1_md_annotation *mda; sbit_t ebits[432]; uint8_t l2[24]; int sps, base_align; @@ -233,9 +247,13 @@ _rx_ccch(struct sample_actor *sa, sps = priv->as->sps; base_align = sps * BCCH_MARGIN; + /* Annotation */ + md = priv->as->chans[priv->chan_id].md; + mda = gmr1_md_get_annotation(md); + /* Map potential burst */ e_toa = burst_map(burst, data, data_len, base_align, sps, - &gmr1_dc6_burst, priv->sa_bcch_stn, 10 * sps); + &gmr1_dc6_burst, priv->sa_bcch_stn, 10 * sps, mda); if (e_toa < 0) return e_toa; @@ -320,6 +338,11 @@ nofollow: priv->as->chans[priv->chan_id].arfcn, priv->fn, priv->sa_bcch_stn, l2, 24)); + /* Annotations */ + gmr1_mda_add_field(mda, "core:title", "\"CCCH\""); + gmr1_mda_add_field(mda, "core:comment", "\"crc=%d, conv=%d, align_err=%d\"", crc, conv, priv->align_err); + gmr1_md_put_annotation(md, mda, sa->time + base_align + (sps * priv->sa_bcch_stn * 39) + e_toa); + return 0; } diff --git a/src/rtfwk/sa_tch3.c b/src/rtfwk/sa_tch3.c index 46af46a..f9c656f 100644 --- a/src/rtfwk/sa_tch3.c +++ b/src/rtfwk/sa_tch3.c @@ -390,7 +390,7 @@ tch3_sink_work(struct sample_actor *sa, /* Map potential burst (use FACCH3 as reference) */ e_toa = burst_map(burst, data, data_len, base_align, sps, - &gmr1_nt3_facch_burst, priv->tn, sps + sps/2); + &gmr1_nt3_facch_burst, priv->tn, sps + sps/2, NULL); if (e_toa < 0) return e_toa; diff --git a/src/rtfwk/sa_tch9.c b/src/rtfwk/sa_tch9.c index 4aee850..c225c45 100644 --- a/src/rtfwk/sa_tch9.c +++ b/src/rtfwk/sa_tch9.c @@ -156,7 +156,7 @@ tch9_sink_work(struct sample_actor *sa, /* Map potential burst */ e_toa = burst_map(burst, data, data_len, base_align, sps, - &gmr1_nt9_burst, priv->tn, sps + (sps/2)); + &gmr1_nt9_burst, priv->tn, sps + (sps/2), NULL); if (e_toa < 0) return e_toa; |