bastibl / gr-rds

FM RDS/TMC Transceiver
http://en.wikipedia.org/wiki/Radio_Data_System
GNU General Public License v3.0
225 stars 73 forks source link

Parser improvements #86

Closed argilo closed 1 week ago

argilo commented 2 weeks ago

Here I have made some improvements to the RDS Parser block, which should make the output nicer to work with:

  1. Reset the parser if a new PI code is seen. This prevents data from different stations from being mixed together.
  2. Only report the Program Service name after it has fully loaded. At present, gr-rds reports partially-received PS data with ".." replacing the missing pieces, and shows a mixture of old & new PS data during changes. This behaviour is particularly problematic in North America, where the RDS standard allows PS data to be updated dynamically (and most broadcasters do this).
  3. Only report radiotext after it has fully loaded, and return only the valid portion of the buffer. At present, gr-rds returns the entire radiotext buffer every time it is touched. The buffer includes the string terminator (carriage return) as well as subsequent filler data (typically null bytes) which corrupts the display in the RDS Panel block. The current behaviour also has the effect of clearing the radiotext immediately when a new radiotext message begins, and this can make it very difficult to read radiotext messages that change frequently.
  4. Clear the alternate frequency string before processing each type 0 group. At present, gr-rds stores this in a static variable which is never cleared. This causes alternate frequencies from one station to appear when receiving other stations that do not specify alternate frequencies.

Update: I replaced part 4 with a more complete implementation of alternate frequency parsing. At present, gr-rds processes fragments of the alternate frequency list one at a time, which causes the RDS panel to rapidly cycle between alternate frequencies whenever a station defines more than one. In addition, it does not handle "AF method B", which allows the broadcaster to distinguish between frequencies that are the same program vs. those that are regional variants. (This method is used by our national broadcaster here in Canada.) I modified the code to collect fragments of the alternate frequency list until the entire list is available, parse it (using method A or B, as appropriate), and display it as a single list. Here's what it looks like:

Screenshot from 2024-11-02 22-48-49

argilo commented 2 weeks ago

I kept the changes in four separate commits, in case there are any that are problematic and need to be taken out or moved into a separate pull request.

argilo commented 2 weeks ago

Part of the motivation for parts 2 and 3 is to make retrieving PS & radiotext through Gqrx's remote control interface more reliable: https://github.com/gqrx-sdr/gqrx/pull/1373

bastibl commented 1 week ago

Awesome, thank you!