Using Python to Update Icecast Scanner Audio Feeds with a Raspberry Pi

Status
Not open for further replies.

H2orescue

Member
Joined
Feb 19, 2011
Messages
10
Any chance I could persuade you to get this working on the bcd536hp? Also, can you modify it to display the radio identifiers as well?
 

bbrasmussen

Member
Joined
Dec 14, 2007
Messages
140
Location
Woods Cross, UT
Sure. It would be a great functionality to add. I'm glad you suggested it. I might need your help to develop/test it since I don't have either of the new units. The first thing I'll have to find out is if UPMan has published the serial comm protocol on his website as he's done for the other models. Once I figure out what commands the new models use, then we can easily modify/create a version of the Python script to support them.

As for radio IDs, we should be able to add that to the display, as long as it's one of the items of data returned via the serial queries. The data is customizable by the user to modify order, length, etc of items displayed.
 

bbrasmussen

Member
Joined
Dec 14, 2007
Messages
140
Location
Woods Cross, UT
I just checked the Uniden wiki and can't see the serial protocol listed for the 536 yet. If anyone knows if/when and where this might be published, let me know. You could try the 996XT Python script and see if it works. From the 536 manual It looks like from the serial port uses 4800 baud, so you might start there. You'll also probably need a null modem also. I don't know if the USB connection will work with the Raspberry Pi. It looks like there's an .inf driver file needed, so probably that would preclude it's use with the RPi, unless someone can write a linux driver for it. So if the serial port can be used like in older models and we can get the comm protocol, then we should be able to make it work.
 

bbrasmussen

Member
Joined
Dec 14, 2007
Messages
140
Location
Woods Cross, UT
From looking around other threads it looks like the serial commands are the same as the 996XT in terms of getting the talkgroup info. If the serial/GPS jack really does provide serial data, then you should be able to use the existing 996XT script I already wrote along with a serial cable, null modem and USB to serial adapter and get the data into your raspberry pi.
 

H2orescue

Member
Joined
Feb 19, 2011
Messages
10
Do you know of any easy way to determine if the serial port is providing serial data with my windows pc? I am afraid if it does not work I won't have enough knowledge of the subject to determine if it is really not transmitting serial data or if I have done something else wrong. I am actually currently broadcasting on my 996xt, so maybe I will get the script running on that first to eliminate some possibility of other errors. My 536 will be headed back to Uniden soon for the recall, maybe it should just make a stop at your house on the way...
 

frazpo

Member
Joined
Jan 14, 2007
Messages
1,476
Location
SW Mo
Do you know of any easy way to determine if the serial port is providing serial data with my windows pc? I am afraid if it does not work I won't have enough knowledge of the subject to determine if it is really not transmitting serial data or if I have done something else wrong. I am actually currently broadcasting on my 996xt, so maybe I will get the script running on that first to eliminate some possibility of other errors. My 536 will be headed back to Uniden soon for the recall, maybe it should just make a stop at your house on the way...

If you are simply trying to confirm serial data to the computer from the scanner you can use hyperterminal in windows. I am using a 396xt so I can only assume the 436 is similar. Set the C-Ch output on scanner and <hold> on a trunked system. Set hyperterminal to 8-n-1 and the flow control xon - xoff. You should see data flashing and the system type in the terminal window.
 

celltech161

Member
Feed Provider
Joined
Mar 22, 2009
Messages
7
Location
Minneapolis, Ks
BC780XLT

Has anyone got this to work with the 780XLT? I got the MetaPy8.py script working well with it, but I'd like to have the full alpha tag functionality, and I never got the MetaPy.py script working with the 780.

It doesn't seem to like my .csv file either, as it has made no difference on what shows up on the player.

Thanks,
Justin
 

Mick83002

Member
Joined
Oct 17, 2012
Messages
9
Location
Jackson, Wyoming
My Own Web Page

Hello, and thank you for all of your work. Not sure I have a clear understanding about the internet side of this, for the end user. Can the information from a BCD 996XT be displayed on my own web page along with the audio? I don't really want to use it on a public site.

Mick - W7CAT
 

bbrasmussen

Member
Joined
Dec 14, 2007
Messages
140
Location
Woods Cross, UT
Sure. You can display the metadata on your own website if you wish. You would have to have your own Icecast2 server setup. The Python script takes the alpha tag info from the scanner and sends it to an Icecast2 server which sends the metadata to the listener along with the audio. If you have a personal feed/website it should work just fine. You just have to enter in the server info in the configuration area of the script and you're good to go.

I do this for my own personal feeds (that way I can listen across the house or with my phone when I'm not at home.) The audio player would also need to support showing metadata from the Icecast stream. There are lots of programs that do this such as Winamp and lots of apps for phones, etc.

Hope that helps. Let me know if I can help you get it working.
-Brandon
 

Mick83002

Member
Joined
Oct 17, 2012
Messages
9
Location
Jackson, Wyoming
Hello Brandon, thank you for the information and I'm sure I'll need some help getting it all set up. I have an older interface that I used for IRLP that will help with this. It will give me the power supply for the Pi and also an RS232 connection. What I am lacking and will need to find out what to get, is a USB wireless device for the Pi. This setup will be at a friend's house and wireless is my only way to get internet. He also is using WPA2 so not sure how much of a hassle that is going to be. Hopefully when it is all done I can use WinSCP to get into it when and if I need to, shouldn't need in much I hope.

Mick - W7CAT
 

Mick83002

Member
Joined
Oct 17, 2012
Messages
9
Location
Jackson, Wyoming
Just wondering about hooking up a BCD996XT to a computer. I have read where the neither side of the speaker should be grounded (seems like a poor design for a mobile radio). It seems to me like connecting a RS232 cable to a computer along with an audio cable from the speaker jack of the BCD996XT to the computer input jack, would be grounding the one side of the speaker. Is my thinking wrong here?
 

bbrasmussen

Member
Joined
Dec 14, 2007
Messages
140
Location
Woods Cross, UT
I think it's possible to have grounding issues when the serial is connected. I've had some audio bleed through in the past from multiple scanners connected to a single computer or a Raspberry Pi. If it's only one scanner I think you will be fine. You can always try a ground isolator in the audio chain if you're having issues.
 

JWFoxJr

Member
Premium Subscriber
Joined
Jul 13, 2009
Messages
3
Location
West Seneca, NY
Radio Shack Pro-2052

Brandon -

First off, thanks for the excellent work - I've been looking for something like this for a long time and just stumbled upon it. I took a look at your metaPy8.py script and think it would work with my Pro-2052. I'm going to fire up a virtual machine and see if I can read the port, but if I can't what information would you need to be able to make it work with the Pro-2052?

Joe
 

bbrasmussen

Member
Joined
Dec 14, 2007
Messages
140
Location
Woods Cross, UT
Hi Joe. Newer RS models won't work because they need RS's proprietary USB adapter which requires a driver that doesn't exist for Linux. But in looking at the owner's manual it looks like the 2052 just uses serial comms, so it should work.

It does use slightly different codes to query the scanner about frequency info. Not very hard to change the Python script to handle that. Unfortunately I don't have a 2052 to debug with. Particularly I'd need to see the response from the scanner to a query so we could parse the data correctly. I'd be happy to point you in the right direction to see if you could get it working. I'll have to see if I can get ahold of one.
Brandon
 

JWFoxJr

Member
Premium Subscriber
Joined
Jul 13, 2009
Messages
3
Location
West Seneca, NY
Hi Joe. Newer RS models won't work because they need RS's proprietary USB adapter which requires a driver that doesn't exist for Linux. But in looking at the owner's manual it looks like the 2052 just uses serial comms, so it should work.

It does use slightly different codes to query the scanner about frequency info. Not very hard to change the Python script to handle that. Unfortunately I don't have a 2052 to debug with. Particularly I'd need to see the response from the scanner to a query so we could parse the data correctly. I'd be happy to point you in the right direction to see if you could get it working. I'll have to see if I can get ahold of one.
Brandon

Brandon -

I've made some progress since my original post. I have reached out to another software creator that does metadata parsing for a Windows app and asked what he was sending to get the frequency data.

So if I do the following:

Code:
WI \r

I get the following back:

Code:
W101 F04540875

So with that information I've been able to parse the raw serial data using:
Code:
freq = serBuffer[7:10] + '.' + serBuffer[10:14]
print(freq)

I guess the biggest thing that I'd like to do is plug this into your parser code, Also I was curious as how you the calling of the CSV file with the channel names works. I know that you put the csvFile variable in the head of the script, but how does it know to look up the frequency there (using the metaPy8.py as my base). You'll have to forgive me, I'm a relatively new programmer.

Thanks.
Joe
 

bbrasmussen

Member
Joined
Dec 14, 2007
Messages
140
Location
Woods Cross, UT
Brandon -

I've made some progress since my original post. I have reached out to another software creator that does metadata parsing for a Windows app and asked what he was sending to get the frequency data.

So if I do the following:

Code:
WI \r

I get the following back:

Code:
W101 F04540875

So with that information I've been able to parse the raw serial data using:
Code:
freq = serBuffer[7:10] + '.' + serBuffer[10:14]
print(freq)

I guess the biggest thing that I'd like to do is plug this into your parser code, Also I was curious as how you the calling of the CSV file with the channel names works. I know that you put the csvFile variable in the head of the script, but how does it know to look up the frequency there (using the metaPy8.py as my base). You'll have to forgive me, I'm a relatively new programmer.

Thanks.
Joe

Sorry for the slow reply...Holidays have been busy.

So it's been a while since I've done much with the script. Last fall I worked on trying to unify it so it was just one script for all cases. I got part way done and then didn't get to finish.

To look up frequencies, I set it up on mine so that I had a .txt or .csv file that had two columns:
frequency, alpha tag
128.550, ZLC Grassy Mountain
162.550, NWS

The script gets the frequency from the scanner and then uses a dictionary to look up the frequency text that was loaded from the file.

I've made a couple of modifications to a version I did for a friend with an Uniden. I think it should work with your scanner. I also have an example file of a frequencies.txt that you can use to input your data pertinent to your setup. Save the frequencies .txt file to the same directory as your metaPy2052.py file. Try it and see if it works.

One of these days I need to clean up the script and make it just one file for all scanners. :) No worries on being a new programmer. I'm in the same boat, it's a hobby on the side for me.

http://www.k7bbr.net/files/metaPy2052.py
http://www.k7bbr.net/files/frequencies.txt
 
Status
Not open for further replies.
Top