metaPy.py stopped working on raspberry pi

Status
Not open for further replies.

faff29

Member
Feed Provider
Joined
Jul 30, 2008
Messages
51
Location
Eastlake, OH
A few days ago I had to reboot my scanner from scratch. One I did that my meta data (Alpha Tagging) stopped working. I went to my backup sd card and still no luck. The audio is streaming through but no metadata. I decided to rebuild the entire raspberry pi and try again. I got through all the directions and again not working. When I type "python metaPy.py this is what I get:
[3] 1003
if I do it again the second number changes.

Anyone know why this is happening or how to change it?

Thank you!
 

faff29

Member
Feed Provider
Joined
Jul 30, 2008
Messages
51
Location
Eastlake, OH
check to see if your port or baud rate settings changed
I worked on this for a while again tonight and verified all he settings look as they should. Below is my metaPy.py script
#Copyright (C)2013, Brandon Rasmussen, K7BBR



import serial

import time

import requests



'''-----------------USER CONFIGURATION-----------------'''

port = "/dev/ttyUSB0" #enter scanner USB/serial port in quotes here

baudrate = 115200 #enter scanner baudrate here

icecastUser = "source" #enter icecast username in quotes here

icecastPass = "password" #enter icecast password in quotes here

icecastServerAddress = "audio9.broadcastify.com:80" #enter icecast server IP Address (and port if necessary) here

icecastMountpoint = "mountpoint" #enter icecast mountpoint in quotes here - don't add leading '/'

'''-----------------END USER CONFIGURATION---------------'''

'''----------UNNECESSARY TO MODIFY SCRIPT BELOW----------'''



urlBase = "http://" + icecastServerAddress + "/admin/metadata?mount=/" + icecastMountpoint + "&mode=updinfo&song="

serTimeout = float(.005) # serial timeout here (.005 is probably sufficient)

test = "GLG" #'''test string to send to Uniden Scanner to get current status

#for BCT8 will be RF to get frequency, or LCD FRQ to read icon status

#for BC125AT use CIN'''

TGIDold = 0 #initialize TGID old test variable

metadata = ''



serialFromScanner = serial.Serial(port, baudrate, timeout=serTimeout) #initialize serial connection

serialFromScanner.flushInput() #flush serial input



def getData():

global serBuffer, nextChar

serBuffer = '' #clear the serBuffer

nextChar = '' #reset the nextChar marker

serialFromScanner.write(test +'\r\n') #send initial request to scanner



def receiveData():

if (serialFromScanner.inWaiting() > 0): #check to see if there's serial data waiting

global nextChar, serBuffer

while nextChar != '\r': #continue filling serBuffer until carriage return

nextChar = serialFromScanner.read(1) #read one character

serBuffer += nextChar
def parseData(pserBuffer):

parsed = pserBuffer.split(",")

stringtest = parsed[0]

global TGIDold, TGID, metadata

if stringtest == "GLG":

length = len(parsed)

if (length >= 10): #check list length so we don't get exception 10 for BCT15, 13 for BC886XT

TGID = parsed[1]

SYSNAME = parsed[5]

GROUP = parsed[6]

TG = parsed[7]

if (TGID.find('.') != -1): #check to see if a trunked or conventional system and get FREQuency

FREQ = TGID.lstrip('0') #remove leading 0 if present

if (FREQ[-1] == '0'):#remove trailing 0 if present

FREQ = FREQ[:-1]

else:

FREQ = 0

if (TGID != TGIDold) and (TGID != ''): #check if group change or scanner not receiving

if (FREQ == 0): #for a trunked system

metadata = ((SYSNAME) + " " + (TGID) + " " + (TG))

else: #for a conventional system

metadata = ((FREQ) + " " + (SYSNAME) + " " + (GROUP) + " " + (TG)) #User can delete/rearrange items to update

else:

metadata = ''



def updateData(pMetadata):

global TGID, TGIDold

if pMetadata != '':

print pMetadata

TGIDold = TGID

def parseData(pserBuffer):

parsed = pserBuffer.split(",")

stringtest = parsed[0]

global TGIDold, TGID, metadata

if stringtest == "GLG":

length = len(parsed
if (length >= 10): #check list length so we don't get exception 10 for BCT15, 13 for BC886XT

TGID = parsed[1]

SYSNAME = parsed[5]

GROUP = parsed[6]

TG = parsed[7]

if (TGID.find('.') != -1): #check to see if a trunked or conventional system and get FREQuency

FREQ = TGID.lstrip('0') #remove leading 0 if present

if (FREQ[-1] == '0'):#remove trailing 0 if present

FREQ = FREQ[:-1]

else:

FREQ = 0

if (TGID != TGIDold) and (TGID != ''): #check if group change or scanner not receiving

if (FREQ == 0): #for a trunked system

metadata = ((SYSNAME) + " " + (TGID) + " " + (TG))

else: #for a conventional system

metadata = ((FREQ) + " " + (SYSNAME) + " " + (GROUP) + " " + (TG)) #User can delete/rearrange items to update

else:

metadata = ''

def updateData(pMetadata):

global TGID, TGIDold

if pMetadata != '':

print pMetadata

TGIDold = TGID

metadataFormatted = metadata.replace(" ","+") #add "+" instead of " " for icecast2

requestToSend = (urlBase) +(metadataFormatted)

r = requests.get((requestToSend), auth=(icecastUser,icecastPass))

status = r.status_code

nowGMT = time.gmtime()

timestamp = time.asctime(nowGMT)

print (timestamp)



if status == 200:

print "Icecast Update OK"

else:

print "Icecast Update Error", status



while True: #infinite loop

getData()



receiveData()



parseData(serBuffer)



updateData(metadata)



time.sleep(.1) #pause
 

faff29

Member
Feed Provider
Joined
Jul 30, 2008
Messages
51
Location
Eastlake, OH
i never use the port number after the link...
"audio9.broadcastify.com:80" #enter icecast server IP Address (and port if necessary) here

how do you have it hooked up with the serial port on back?
I have the audio9.broadcastify.com:80. As for connection i have a null modem in the back of the scanner then connected to a usb cable to my raspberry pi.
I had it working for something like 1.5 years and it just stopped.
The audio feed is fine just not the alpha tagging.
 

faff29

Member
Feed Provider
Joined
Jul 30, 2008
Messages
51
Location
Eastlake, OH
i never use the port number after the link...
"audio9.broadcastify.com:80" #enter icecast server IP Address (and port if necessary) here

how do you have it hooked up with the serial port on back?
I removed the :80 and still get the same thing. I have tried changing the port from ttyUSB0 to dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0 and that did not work either.
 

mccleway

Member
Joined
Jun 10, 2009
Messages
75
Since metaPy is just a script, have you tried deleting it, and then re-downloading it? I just set it up on my Pi about 2 weeks ago & it works fine.

May also want to do a:

sudo apt-get update && sudo apt-get upgrade

Just in case there any python or dependency issues messing things up.
 
Status
Not open for further replies.
Top