Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input from TEF6686 tuner #89

Closed
andimik opened this issue May 15, 2023 · 9 comments
Closed

Input from TEF6686 tuner #89

andimik opened this issue May 15, 2023 · 9 comments

Comments

@andimik
Copy link
Contributor

andimik commented May 15, 2023

Several radio freaks have recently bought a tuner with TEF6686 chip inside which can be connected to USB. See https://www.pe5pvb.nl/tef6686/

Its output (ttyUSB0) is in the following format:

PA540
R0549000000000F
Ss66.5,2,35

the line starting with P contains the PI-Code (here A540)
the line starting with R consists of RDS blocks B (rdsB), C (rdsC) and D (rdsD) and a RDS error (rdsErr) information
the line starting with S shows the signal strength.

Do you think it's possible to implement this format in redsea? I tried with awk, but it seems to be too tricky for me.

For example the following log
a201_ttyUSB.txt
was filtered by RDS error = 0 (maybe other values are ok as well)
a201.spy.txt

grafik

Specification of the chip:
https://github.com/makserge/tef6686_radio/blob/master/User_Manual_TEF6686.pdf

This is the source code which creates the format:

https://github.com/NoobishSVK/TEF6686-remastered/blob/330e4d591e0b09f664e36671db0b36627dc361f8/TEF6686_remastered.ino#L2251

@windytan
Copy link
Owner

I took a look at it. The serial data looks quite odd - seems like the same group is always repeated four times, each with a different value of rdsErr. It would produce this:

A201 2010 4E91 ----
A201 2010 4E91 6368
A201 ---- ---- ----
A201 8003 ---- ----
A201 8003 C323 9AB3
A201 ---- ---- ----
A201 0018 ---- ----
A201 0018 F935 ----
A201 0018 F935 ----
A201 0018 F935 2020
...

But maybe it could work if only the ones with rdsErr=0 are accepted...

@andimik
Copy link
Contributor Author

andimik commented May 17, 2023

Let me first try to modify the firmware for the device. So put this on hold for the moment.

I'm aware that the same group is repeated several times.

@windytan
Copy link
Owner

Sure. It's practically done though, just missing some test cases :)

@andimik
Copy link
Contributor Author

andimik commented May 31, 2023

The firmware has been modified and the above mentioned bug was fixed. The following log from /dev/ttyUSB0 should be now ok.

a502_serial.txt
a213_serial.txt
a203_serial.txt
a201_serial.txt

The line with leading R and the following hex code is the correct one, of course. I already have reported that because the S line should not have the leading R, guess it will be fixed soon.

andimik referenced this issue in PE5PVB/TEF6686_ESP32-Archive Jun 1, 2023
@andimik
Copy link
Contributor Author

andimik commented Jun 3, 2023

R line has been fixed. Should now look like this:

a502_ttyusb0.txt
a203_ttyusb0.txt
a201_ttyusb0.txt

I have tried with sed, but I have no idea how to extract the PI-Code from the P line (which is another line) so I add it manually ...

$ cat ./a203_ttyusb0.txt | sed -e '/.?/d' -e '/^S/d' -e  's/R//g' -e 's/..$//' -e '/^P/d' -e 's/^//' -e 's/^/a203/' | redsea -Eh | head -10
{"pi":"0xA203","group":"0A","bler":0,"di":{"compressed":false},"is_music":true,"prog_type":"Pop music","ta":true,"tp":true}
{"pi":"0xA203","group":"0A","bler":0,"di":{"artificial_head":false},"is_music":true,"prog_type":"Pop music","ta":true,"tp":true}
{"pi":"0xA203","group":"14A","bler":0,"other_network":{"pi":"0xA902","prog_type":"No PTY","ta":true,"tp":false},"prog_type":"Pop music","tp":true}
{"pi":"0xA203","group":"0A","bler":0,"di":{"stereo":true},"is_music":true,"prog_type":"Pop music","ta":true,"tp":true}
{"pi":"0xA203","group":"2A","bler":0,"prog_type":"Pop music","tp":true}
{"pi":"0xA203","group":"8A","bler":0,"prog_type":"Pop music","tp":true}
{"pi":"0xA203","group":"0A","bler":0,"di":{"dynamic_pty":false},"is_music":true,"prog_type":"Pop music","ta":true,"tp":true}
{"pi":"0xA203","group":"8A","bler":0,"prog_type":"Pop music","tp":true}
{"pi":"0xA203","group":"0A","bler":0,"di":{"compressed":false},"is_music":true,"prog_type":"Pop music","ta":true,"tp":true}
{"pi":"0xA203","group":"8A","bler":0,"prog_type":"Pop music","tp":true}

$ cat ./a203_ttyusb0.txt | sed -e '/.?/d' -e '/^R/d' -e '/^S/d' -e  's/P//g'
a203
a203
a203
a203
a203
a203
a203
a203
a203
$ cat ./a203_ttyusb0.txt | sed -e '/.?/d' -e '/^S/d' -e  's/R//g' -e 's/..$//' -e '/^P/d' -e 's/^//' -e 's/^/a203/' | head -10
a203055911784f45
a203055a69602033
a203e54d0001a902
a203055f0e782020
a203255f20202020
a2038542c3239ab3
a203055815782020
a20385406021a201
a20305596c784f45
a2038542c3239ab3

@windytan
Copy link
Owner

windytan commented Jun 4, 2023

Can you check out the tef6686 branch and see if it works all right?

@windytan
Copy link
Owner

windytan commented Jun 4, 2023

It's a new command-line option for input types: redsea -i tef

@andimik
Copy link
Contributor Author

andimik commented Jun 4, 2023

Great! Confirmed, this works!

$ cat /dev/ttyUSB0 | ./redsea -E -i tef
{"pi":"0xA203","group":"14A","bler":0,"other_network":{"pi":"0xA502","kilohertz":95500,"tp":false},"prog_type":"Pop music","tp":true}
{"pi":"0xA203","group":"0A","bler":0,"di":{"artificial_head":false},"is_music":true,"prog_type":"Pop music","ta":false,"tp":true}
{"pi":"0xA203","group":"8A","bler":0,"prog_type":"Pop music","tp":true}
{"pi":"0xA203","group":"0A","bler":0,"di":{"stereo":true},"is_music":true,"prog_type":"Pop music","ta":false,"tp":true}
{"pi":"0xA203","group":"14A","bler":0,"other_network":{"pi":"0xA502","prog_type":"No PTY","ta":true,"tp":false},"prog_type":"Pop music","tp":true}
{"pi":"0xA203","group":"0A","bler":0,"di":{"dynamic_pty":false},"is_music":true,"prog_type":"Pop music","ta":false,"tp":true}
{"pi":"0xA203","group":"2A","bler":0,"prog_type":"Pop music","tp":true}
{"pi":"0xA203","group":"8A","bler":0,"prog_type":"Pop music","tp":true}
{"pi":"0xA203","group":"0A","alt_kilohertz":[88600,88800,90400,102500,103300],"bler":0,"di":{"compressed":false},"is_music":true,"prog_type":"Pop music","ta":false,"tp":true}
{"pi":"0xA203","group":"2A","bler":0,"prog_type":"Pop music","tp":true}
{"pi":"0xA203","group":"14A","bler":0,"other_network":{"pi":"0xA213","tp":false},"prog_type":"Pop music","tp":true}
{"pi":"0xA203","group":"3A","bler":0,"open_data_app":{"app_name":"RDS-TMC: ALERT-C","oda_group":"8A"},"prog_type":"Pop music","tmc":{"system_info":{"is_encrypted":false,"is_on_alt_freqs":true,"location_table":1,"scope":["national"]}},"tp":true}
{"pi":"0xA203","group":"8A","bler":0,"prog_type":"Pop music","tp":true}
{"pi":"0xA203","group":"0A","bler":0,"di":{"artificial_head":false},"is_music":true,"prog_type":"Pop music","ta":false,"tp":true}
{"pi":"0xA203","group":"2A","bler":0,"prog_type":"Pop music","tp":true}
{"pi":"0xA203","group":"14A","bler":0,"other_network":{"pi":"0xA213","tp":false},"prog_type":"Pop music","tp":true}

@andimik andimik closed this as completed Jun 4, 2023
windytan added a commit that referenced this issue Jun 5, 2023
The TEF6686 tuner outputs RDS groups as ASCII via serial USB.
Redsea can decode this with the option `-i tef`.

To allow for future input formats the option `-i` was added:
`redsea -i {bits,hex,mpx,tef}`

The old input format switches will continue working.
@andimik
Copy link
Contributor Author

andimik commented Feb 5, 2024

The output format has slightly changed in recent firmware version for several reasons. The only difference is, that in the "R"-Line now also the PI-Code is inserted.

Please note, that the old firmware might be still used widely.

$ cat /dev/ttyUSB0 
PA540
RA540054A52A84E5410
6

PA540
RA540255672204E6F10
40
RA540255672204E6F10
6

PA540
RA540054FED92454E00
PA540
RA540054892A8414E00
236

antenne.txt

$ cat /tmp/antenne.txt | grep R | sed -e 's/R//g'
A5402553202D205400
A5402553202D205400
A540054F5288454E01
A5400548ED524B4100
A5400548ED524B4100
A54025546F6C642000
A54005495256455200
A54005495256455200
A540054A52884E5400
A540054A52884E5400
A5402555596F752000
$ cat /tmp/antenne.txt | grep R | sed -e 's/R//g' | redsea -i hex -E
{"pi":"0xA540","group":"2A","bler":0,"prog_type":"Pop music","tp":true}
{"pi":"0xA540","group":"2A","bler":0,"prog_type":"Pop music","tp":true}
{"pi":"0xA540","group":"0A","bler":0,"di":{"stereo":true},"is_music":true,"prog_type":"Pop music","ta":false,"tp":true}
{"pi":"0xA540","group":"0A","bler":0,"di":{"dynamic_pty":false},"is_music":true,"prog_type":"Pop music","ta":false,"tp":true}
{"pi":"0xA540","group":"0A","bler":0,"di":{"dynamic_pty":false},"is_music":true,"prog_type":"Pop music","ta":false,"tp":true}
{"pi":"0xA540","group":"2A","bler":0,"prog_type":"Pop music","tp":true}

So let me propose to add the new format, too, but keep compatibility to the old one (by checking the length of the "R"-Line).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants