aboutsummaryrefslogtreecommitdiffstats
path: root/src/fig0_19.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/fig0_19.cpp')
-rw-r--r--src/fig0_19.cpp34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/fig0_19.cpp b/src/fig0_19.cpp
index 272f230..5fef324 100644
--- a/src/fig0_19.cpp
+++ b/src/fig0_19.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
@@ -48,58 +48,52 @@ bool fig0_19_is_complete(int clusters_id)
// FIG 0/19 Announcement switching
// ETSI EN 300 401 8.1.6.2
-bool fig0_19(fig0_common_t& fig0, const display_settings_t &disp)
+fig_result_t fig0_19(fig0_common_t& fig0, const display_settings_t &disp)
{
uint16_t Asw_flags;
uint8_t i = 1, j, Cluster_Id, SubChId, Rfa, RegionId_LP;
- char tmpbuf[256];
- char desc[256];
+ fig_result_t r;
bool New_flag, Region_flag;
uint8_t* f = fig0.f;
- const int figtype = 0;
- bool complete = false;
while (i < (fig0.figlen - 3)) {
// iterate over announcement switching
// Cluster Id, Asw flags, New flag, Region flag,
// SubChId, Rfa, Region Id Lower Part
Cluster_Id = f[i];
- complete |= fig0_19_is_complete(Cluster_Id);
+ r.complete |= fig0_19_is_complete(Cluster_Id);
Asw_flags = ((uint16_t)f[i+1] << 8) | (uint16_t)f[i+2];
New_flag = (f[i+3] >> 7);
Region_flag = (f[i+3] >> 6) & 0x1;
SubChId = (f[i+3] & 0x3F);
- sprintf(desc, "Cluster Id=0x%02x, Asw flags=0x%04x, New flag=%d %s, Region flag=%d last byte %s, SubChId=%d",
- Cluster_Id, Asw_flags, New_flag, (New_flag)?"new":"repeat", Region_flag, (Region_flag)?"present":"absent", SubChId);
+ r.msgs.push_back(strprintf("Cluster Id=0x%02x", Cluster_Id));
+ r.msgs.push_back(strprintf("Asw flags=0x%04x", Asw_flags));
+ r.msgs.push_back(strprintf("New flag=%d %s", New_flag, (New_flag)?"new":"repeat"));
+ r.msgs.push_back(strprintf("Region flag=%d last byte %s", Region_flag, (Region_flag)?"present":"absent"));
+ r.msgs.push_back(strprintf("SubChId=%d", SubChId));
if (Region_flag) {
if (i < (fig0.figlen - 4)) {
// read region lower part
Rfa = (f[i+4] >> 6);
RegionId_LP = (f[i+4] & 0x3F);
if (Rfa != 0) {
- sprintf(tmpbuf, ", Rfa=%d invalid value", Rfa);
- strcat(desc, tmpbuf);
+ r.errors.push_back(strprintf("Rfa=%d invalid value", Rfa));
}
- sprintf(tmpbuf, ", Region Lower Part=0x%02x", RegionId_LP);
- strcat(desc, tmpbuf);
+ r.msgs.push_back(strprintf("Region Lower Part=0x%02x", RegionId_LP));
}
else {
- sprintf(tmpbuf, "missing Region Lower Part, fig length too short !");
- strcat(desc, tmpbuf);
- fprintf(stderr, "WARNING: FIG %d/%d length %d too short !\n", figtype, fig0.ext(), fig0.figlen);
+ r.errors.push_back("missing Region Lower Part, fig length too short !");
}
}
- printbuf(desc, disp+1, NULL, 0);
// decode announcement switching types
for(j = 0; j < 16; j++) {
if (Asw_flags & (1 << j)) {
- sprintf(desc, "Announcement switching=%s", get_announcement_type(j));
- printbuf(desc, disp+2, NULL, 0);
+ r.msgs.emplace_back(1, strprintf("Announcement switching=%s", get_announcement_type(j)));
}
}
i += (4 + Region_flag);
}
- return complete;
+ return r;
}