Login |  Register



Welcome
Welcome to engineeringdiy

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today!


Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Preset Radio Stations
PostPosted: Fri Jun 05, 2015 2:00 pm 
Joined: Fri Jun 05, 2015 5:07 am
Posts: 2
I can't seem to get this script working correctly. I'm fairly new to python so bear with me here. Here is what I get for errors....

[email protected] /opt/carpc/startup $ sudo ./tune1.sh
./tune1.sh: 1: ./tune1.sh: import: not found
./tune1.sh: 2: ./tune1.sh: import: not found
./tune1.sh: 3: ./tune1.sh: import: not found
./tune1.sh: 5: ./tune1.sh: UPD_IP: not found
./tune1.sh: 6: ./tune1.sh: UPD_PORT: not found
./tune1.sh: 10: ./tune1.sh: Syntax error: "(" unexpected

I ran it in a ssh terminal to see why it wasn't resetting the station to preset #1. Any ideas?


Report this post
Profile  Offline
 
 Post subject: Re: Preset Radio Stations
PostPosted: Wed Jun 24, 2015 1:27 am 
Joined: Fri Feb 06, 2015 9:27 pm
Posts: 93
The file needs a Shebang at the start of the file, so it looks like this:
Code:
#!/usr/bin/env python
# the rest is just garbage to show what it could look like, since I don't know what the file looks like...
import stuff
import moar_stuff

do_some_stuff();


hope that helps :)


Report this post
Profile  Offline
 
 Post subject: Re: Preset Radio Stations
PostPosted: Thu Jun 25, 2015 6:31 pm 
Joined: Fri Jun 05, 2015 5:07 am
Posts: 2
Thanks, I will try that tonight and post my results.
-Chris


Report this post
Profile  Offline
 
 Post subject: Re: Preset Radio Stations
PostPosted: Tue Feb 23, 2016 10:04 am 
Joined: Sat Oct 03, 2015 12:34 pm
Posts: 66
it doesn't work.... :(


Report this post
Profile  Offline
 
 Post subject: Re: Preset Radio Stations
PostPosted: Fri May 20, 2016 9:40 pm 
Joined: Fri May 20, 2016 9:36 pm
Posts: 14
Hi,

it works for me. But i had to ad a sleep command;
sleep 5
in the StartCarPC_stage2 file before running the script

Floris


Report this post
Profile  Offline
 
 Post subject: Re: Preset Radio Stations
PostPosted: Sun Jul 03, 2016 12:08 pm 
Joined: Sat Oct 03, 2015 12:34 pm
Posts: 66
Thanks! It works with sleep 5 ;)


Report this post
Profile  Offline
 
 Post subject: Re: Preset Radio Stations
PostPosted: Wed Jul 27, 2016 6:57 pm 
Joined: Tue Mar 03, 2015 8:35 pm
Posts: 30
Could someone post their command to launch the python script and the format of the sleep 5. Thanks


Report this post
Profile  Offline
 
 Post subject: Re: Preset Radio Stations
PostPosted: Wed Jul 27, 2016 7:51 pm 
Joined: Fri May 22, 2015 8:46 pm
Posts: 330
Alternative(i think it is better and also customizable):

addon-radiofm-2-x-nextgen-t656.html


Report this post
Profile  Offline
 
 Post subject: Re: Preset Radio Stations
PostPosted: Wed Dec 21, 2016 6:56 pm 
Joined: Sat Nov 12, 2016 6:03 pm
Posts: 10
godzra wrote:
I created a python script that reads the preset stations list and tunes it to the first one just after start up. I created a file using the following code and then put a command to run it in the StartCarPC_stage2 file just after the gpio_description launches.

-------------------------------

import socket
import threading
import time


UDP_IP = "127.0.0.1"
UDP_PORT = 5005

# Path to stations preset file
file = open('/home/pi/.kodi/addons/plugin.program.radioFM/resources/stations','r')
# Read the stations file into string and close it
data = file.readlines()
file.close()
# Take first line from station list and split it up by spaces
item = data[0]
requestedFrequency = item.split(' ')
# Use the first value of the split string for first station to tune radio to

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto("radio_tune_" + requestedFrequency[0] + "\0", (UDP_IP, UDP_PORT))


sock.close()


I have tried to implement this without success. There is no file 'stations' at the indicated location on my system but I have saved some stations in my FM radio. So far I have not been able to determine where these are stored. Anyone run into this? I created a simple text file with a frequency in it (98.1) at the selcted location but still did not work.


Report this post
Profile  Offline
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2


Who is online

Users browsing this forum: No registered users and 0 guests

Panel

Top You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Search for:
Jump to:  


suspicion-preferred