aboutsummaryrefslogtreecommitdiffstats
path: root/src/fig0_6.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/fig0_6.cpp')
-rw-r--r--src/fig0_6.cpp94
1 files changed, 42 insertions, 52 deletions
diff --git a/src/fig0_6.cpp b/src/fig0_6.cpp
index 921e36d..a906b17 100644
--- a/src/fig0_6.cpp
+++ b/src/fig0_6.cpp
@@ -1,6 +1,6 @@
/*
Copyright (C) 2014 CSP Innovazione nelle ICT s.c.a r.l. (http://www.csp.it/)
- Copyright (C) 2016 Matthias P. Braendli (http://www.opendigitalradio.org)
+ Copyright (C) 2017 Matthias P. Braendli (http://www.opendigitalradio.org)
Copyright (C) 2015 Data Path
This program is free software: you can redistribute it and/or modify
@@ -56,15 +56,13 @@ void fig0_6_cleardb()
// FIG 0/6 Service linking information
// ETSI EN 300 401 8.1.15
-bool fig0_6(fig0_common_t& fig0, const display_settings_t &disp)
+fig_result_t fig0_6(fig0_common_t& fig0, const display_settings_t &disp)
{
uint32_t j;
uint16_t LSN, key;
uint8_t i = 1, Number_of_Ids, IdLQ;
- char signal_link[256];
- char desc[256];
+ fig_result_t r;
bool Id_list_flag, LA, SH, ILS, Shd;
- bool complete = false;
uint8_t* f = fig0.f;
@@ -76,30 +74,30 @@ bool fig0_6(fig0_common_t& fig0, const display_settings_t &disp)
ILS = (f[i] >> 4) & 0x01;
LSN = ((f[i] & 0x0F) << 8) | f[i+1];
key = (fig0.oe() << 15) | (fig0.pd() << 14) | (SH << 13) | (ILS << 12) | LSN;
- complete |= fig0_6_is_complete(key);
- strcpy(signal_link, "");
+ r.complete |= fig0_6_is_complete(key);
+
+ r.msgs.push_back(strprintf("Id list flag=%d", Id_list_flag));
+ r.msgs.push_back(strprintf("LA=%d %s", LA, LA ? "active" : "inactive"));
+ r.msgs.push_back(strprintf("S/H=%d %s", SH, SH ? "Hard" : "Soft"));
+ r.msgs.push_back(strprintf("ILS=%d %s", ILS, ILS ? "international" : "national"));
+ r.msgs.push_back(strprintf("LSN=%d", LSN));
+ r.msgs.push_back(strprintf("database key=0x%04x", key));
+
// check activation / deactivation
if ((fig0_6_key_la.count(key) > 0) && (fig0_6_key_la[key] != LA)) {
if (LA == 0) {
- strcat(signal_link, " deactivated");
+ r.msgs.emplace_back("deactivated");
}
else {
- strcat(signal_link, " activated");
+ r.msgs.emplace_back("activated");
}
}
fig0_6_key_la[key] = LA;
i += 2;
if (Id_list_flag == 0) {
if (fig0.cn() == 0) { // Id_list_flag=0 && fig0.cn()=0: CEI Change Event Indication
- strcat(signal_link, " CEI");
+ r.msgs.emplace_back("CEI");
}
- sprintf(desc, "Id list flag=%d, LA=%d %s, S/H=%d %s, ILS=%d %s, LSN=%d, database key=0x%04x%s",
- Id_list_flag,
- LA, LA ? "active" : "inactive",
- SH, SH ? "Hard" : "Soft",
- ILS, ILS ? "international" : "national",
- LSN, key, signal_link);
- printbuf(desc, disp+1, NULL, 0);
}
else { // Id_list_flag == 1
if (i < fig0.figlen) {
@@ -107,43 +105,36 @@ bool fig0_6(fig0_common_t& fig0, const display_settings_t &disp)
if (fig0.pd() == 0) {
IdLQ = (f[i] >> 5) & 0x03;
Shd = (f[i] >> 4) & 0x01;
- sprintf(desc, "Id list flag=%d, LA=%d %s, S/H=%d %s, ILS=%d %s, LSN=%d, "
- "database key=0x%04x, IdLQ=%d, Shd=%d %s, Number of Ids=%d%s",
- Id_list_flag,
- LA, (LA)?"active":"inactive",
- SH, (SH)?"Hard":"Soft",
- ILS, (ILS)?"international":"national",
- LSN, key, IdLQ,
- Shd, (Shd)?"b11-8 in 4-F are different services":"single service",
- Number_of_Ids, signal_link);
- printbuf(desc, disp+1, NULL, 0);
+ r.msgs.push_back(strprintf("IdLQ=%d", IdLQ));
+ r.msgs.push_back(strprintf("Shd=%d %s", Shd, (Shd)?"b11-8 in 4-F are different services":"single service"));
+ r.msgs.push_back(strprintf("Number of Ids=%d%s", Number_of_Ids));
+
if (ILS == 0) {
// read Id list
for(j = 0; ((j < Number_of_Ids) && ((i+2+(j*2)) < fig0.figlen)); j++) {
// ETSI EN 300 401 8.1.15. Some changes were introducted in spec V2
if (((j == 0) && (fig0.oe() == 0) && (fig0.cn() == 0)) ||
(IdLQ == 0)) {
- sprintf(desc, "DAB SId 0x%X",
- ((f[i+1+(j*2)] << 8) | f[i+2+(j*2)]));
+ r.msgs.emplace_back(1, strprintf("DAB SId 0x%X",
+ ((f[i+1+(j*2)] << 8) | f[i+2+(j*2)])));
}
else if (IdLQ == 1) {
- sprintf(desc, "RDS PI 0x%X",
- ((f[i+1+(j*2)] << 8) | f[i+2+(j*2)]));
+ r.msgs.emplace_back(1, strprintf("RDS PI 0x%X",
+ ((f[i+1+(j*2)] << 8) | f[i+2+(j*2)])));
}
else if (IdLQ == 2) {
- sprintf(desc, "(AM-FM legacy) 0x%X",
- ((f[i+1+(j*2)] << 8) | f[i+2+(j*2)]));
+ r.msgs.emplace_back(1, strprintf("(AM-FM legacy) 0x%X",
+ ((f[i+1+(j*2)] << 8) | f[i+2+(j*2)])));
}
else { // IdLQ == 3
- sprintf(desc, "DRM-AMSS service 0x%X",
- ((f[i+1+(j*2)] << 8) | f[i+2+(j*2)]));
+ r.msgs.emplace_back(1, strprintf("DRM-AMSS service 0x%X",
+ ((f[i+1+(j*2)] << 8) | f[i+2+(j*2)])));
}
- printbuf(desc, disp+2, NULL, 0);
}
+
// check deadlink
if ((Number_of_Ids == 0) && (IdLQ == 1)) {
- sprintf(desc, "deadlink");
- printbuf(desc, disp+2, NULL, 0);
+ r.errors.push_back("deadlink");
}
i += (Number_of_Ids * 2) + 1;
}
@@ -152,37 +143,36 @@ bool fig0_6(fig0_common_t& fig0, const display_settings_t &disp)
for(j = 0; ((j < Number_of_Ids) && ((i+3+(j*3)) < fig0.figlen)); j++) {
if (((j == 0) && (fig0.oe() == 0) && (fig0.cn() == 0)) ||
(IdLQ == 0)) {
- sprintf(desc, "DAB SId ecc 0x%02X Id 0x%04X", f[i+1+(j*3)], ((f[i+2+(j*3)] << 8) | f[i+3+(j*3)]));
+ r.msgs.emplace_back(1, strprintf("DAB SId ecc 0x%02X Id 0x%04X",
+ f[i+1+(j*3)], ((f[i+2+(j*3)] << 8) | f[i+3+(j*3)])));
}
else if (IdLQ == 1) {
- sprintf(desc, "RDS PI ecc 0x%02X Id 0x%04X", f[i+1+(j*3)], ((f[i+2+(j*3)] << 8) | f[i+3+(j*3)]));
+ r.msgs.emplace_back(1, strprintf("RDS PI ecc 0x%02X Id 0x%04X",
+ f[i+1+(j*3)], ((f[i+2+(j*3)] << 8) | f[i+3+(j*3)])));
}
else if (IdLQ == 2) {
- sprintf(desc, "(AM-FM legacy) ecc 0x%02X Id 0x%04X", f[i+1+(j*3)], ((f[i+2+(j*3)] << 8) | f[i+3+(j*3)]));
+ r.msgs.emplace_back(1, strprintf("(AM-FM legacy) ecc 0x%02X Id 0x%04X",
+ f[i+1+(j*3)], ((f[i+2+(j*3)] << 8) | f[i+3+(j*3)])));
}
else { // IdLQ == 3
- sprintf(desc, "DRM/AMSS service ecc 0x%02X Id 0x%04X", f[i+1+(j*3)], ((f[i+2+(j*3)] << 8) | f[i+3+(j*3)]));
+ r.msgs.emplace_back(1, strprintf("DRM/AMSS service ecc 0x%02X Id 0x%04X",
+ f[i+1+(j*3)], ((f[i+2+(j*3)] << 8) | f[i+3+(j*3)])));
}
- printbuf(desc, disp+2, NULL, 0);
}
// check deadlink
if ((Number_of_Ids == 0) && (IdLQ == 1)) {
- sprintf(desc, "deadlink");
- printbuf(desc, disp+2, NULL, 0);
+ r.errors.push_back("deadlink");
}
i += (Number_of_Ids * 3) + 1;
}
}
else { // fig0.pd() == 1
- sprintf(desc, "Id list flag=%d, LA=%d %s, S/H=%d %s, ILS=%d %s, LSN=%d, database key=0x%04x, Number of Ids=%d%s",
- Id_list_flag, LA, (LA)?"active":"inactive", SH, (SH)?"Hard":"Soft", ILS, (ILS)?"international":"national", LSN, key, Number_of_Ids, signal_link);
- printbuf(desc, disp+1, NULL, 0);
+ r.msgs.push_back(strprintf("Number of Ids=%d%s", Number_of_Ids));
if (Number_of_Ids > 0) {
// read Id list
for(j = 0; ((j < Number_of_Ids) && ((i+4+(j*4)) < fig0.figlen)); j++) {
- sprintf(desc, "SId 0x%X",
- ((f[i+1+(j*4)] << 24) | (f[i+2+(j*4)] << 16) | (f[i+3+(j*4)] << 8) | f[i+4+(j*4)]));
- printbuf(desc, disp+2, NULL, 0);
+ r.msgs.emplace_back(1, strprintf("SId 0x%X",
+ ((f[i+1+(j*4)] << 24) | (f[i+2+(j*4)] << 16) | (f[i+3+(j*4)] << 8) | f[i+4+(j*4)])));
}
}
i += (Number_of_Ids * 4) + 1;
@@ -191,6 +181,6 @@ bool fig0_6(fig0_common_t& fig0, const display_settings_t &disp)
}
}
- return complete;
+ return r;
}