Skip to content

Commit

Permalink
minor features: 15B DI codes, Broadcaster SLC bits
Browse files Browse the repository at this point in the history
  • Loading branch information
windytan committed Aug 11, 2024
1 parent dcec5c5 commit 4faebc3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

## HEAD

* New features:
* Decode 'broadcaster use' data in Slow labeling codes (variant 6)
* Decode 'decoder identification' bits in Group 15B
* Bug fixes:
* Fix the CSVReader (used in the TMC decoder) ignoring the last line of any file
* Remove extra trailing space in transparent data channels hexdump
* Build system fixes:
* macOS: ask Homebrew about liquid-dsp location instead of hardcoding it
* Set default installation prefix to /usr/local (all platforms)
Expand Down
25 changes: 18 additions & 7 deletions src/groups.cc
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,14 @@ void Station::decodeType1(const Group& group) {
}
break;

case 3: json_["language"] = getLanguageString(getUint8(group.get(BLOCK3), 0)); break;
case 3:
json_["language"] = getLanguageString(getUint8(group.get(BLOCK3), 0));
break;

// SLC variants 4, 5 are not assigned

case 6:
json_["slc_broadcaster_bits"] = "0x" + getHexString<3>(getBits<11>(group.get(BLOCK3), 0));

case 7: json_["ews"] = getBits<12>(group.get(BLOCK3), 0); break;

Expand Down Expand Up @@ -736,11 +743,12 @@ void Station::decodeType5(const Group& group) {
if (full_tdc_.isComplete()) {
json_["transparent_data"]["full_text"] = full_tdc_.str();

std::string full_raw;
std::vector<std::string> full_raw;
full_raw.reserve(full_tdc_.getData().size());
for (const auto b : full_tdc_.getData()) {
full_raw += getHexString<2>(b) + " ";
full_raw.push_back(getHexString<2>(b));
}
json_["transparent_data"]["full_raw"] = full_raw;
json_["transparent_data"]["full_raw"] = join(full_raw, " ");
}

json_["transparent_data"]["as_text"] = decoded_text.str();
Expand Down Expand Up @@ -924,10 +932,13 @@ void Station::decodeType15A(const Group& group) {

/* Group 15B: Fast basic tuning and switching information */
void Station::decodeType15B(const Group& group) {
const auto block_num = group.has(BLOCK2) ? BLOCK2 : BLOCK4;
const auto block_num = group.has(BLOCK2) ? BLOCK2 : BLOCK4;
const uint16_t segment_address = getBits<2>(group.get(BLOCK2), 0);
const bool is_di = getBool(group.get(BLOCK2), 2);

json_["ta"] = getBool(group.get(block_num), 4);
json_["is_music"] = getBool(group.get(block_num), 3);
json_["di"][getDICodeString(segment_address)] = is_di;
json_["ta"] = getBool(group.get(block_num), 4);
json_["is_music"] = getBool(group.get(block_num), 3);
}

/* Open Data Application */
Expand Down
4 changes: 2 additions & 2 deletions src/tmc/csv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ std::vector<std::vector<std::string>> readCSV(const std::string& filename, char
if (!in.is_open())
return lines;

for (std::string line; std::getline(in, line); in.good()) {
for (std::string line; std::getline(in, line);) {
line.erase(std::remove(line.begin(), line.end(), '\r'), line.end());
line.erase(std::remove(line.begin(), line.end(), '\n'), line.end());

Expand All @@ -43,7 +43,7 @@ CSVTable readCSVWithTitles(const std::string& filename, char delimiter) {

std::ifstream in(filename);
if (in.is_open()) {
for (std::string line; std::getline(in, line); in.good()) {
for (std::string line; std::getline(in, line);) {
lines.push_back(line);
}

Expand Down
3 changes: 3 additions & 0 deletions src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ std::string getTimePointString(const std::chrono::time_point<std::chrono::system
}

std::string join(const std::vector<std::string>& strings, const std::string& d) {
if (strings.empty())
return "";

std::string result;
for (size_t i = 0; i < strings.size(); i++) {
result += strings[i];
Expand Down

0 comments on commit 4faebc3

Please sign in to comment.