ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Need some help!- project!- IMPORTANT!

Sun Apr 03, 2016 12:56 am

Hello, I am doing a very important school project using a raspberry pi. I am making an internet radio. I have the hardware all figured out but, the instructions I am using are very vague. The link to the instruction is below.

http://www.linuxuser.co.uk/tutorials/ra ... rnet-radio

If you will look, on step 7, I am having trouble.

I enter in this:

Code: Select all

chmod 755 radio
I hit enter. Nothing (visible) happens. I enter in the next thing:

Code: Select all

update-rc.d radio defaults
I get an error message.

Code: Select all

Warning: script 'radio' missing LSB tags and overrides
Warning: script 'K0Iradio' missing LSB tags and overrides
Will someone please help me with this?

Thank you all,

-ConradG13
People who say times instead of multiply shouldn't be around.

Heater
Posts: 13097
Joined: Tue Jul 17, 2012 3:02 pm

Re: Need some help!- project!- IMPORTANT!

Sun Apr 03, 2016 1:45 am

After may years of using Linux I have never seen such warning. However a quick google for "Warning: script 'radio' missing LSB tags and overrides" turns up many explanations, suggestions and solutions. Like:

http://help.directadmin.com/item.php?id=379
viewtopic.php?f=95&t=68263

And this is a good one:

http://crunchbang.org/forums/viewtopic.php?id=22017

Seems you need to add something to the radio and K0Iradio scripts like so:

Code: Select all

### BEGIN INIT INFO
# Provides: radio
# Required-Start:    $network $local_fs $syslog  dbus
# Required-Stop:     $network $local_fs $syslog 
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start radio
### END INIT INFO
Now, I may not have the details right so you had better read up on it in the Debian documentation here:

https://wiki.debian.org/LSBInitScripts

Thanks for asking. I learned something new :)


Edit: On the other hand if you are using Raspbian Jessie it has a new init system, "systemd", and there is an alternative and better way to get things started at boot. But let's leave that for now and see if we can get what you have working.
Last edited by Heater on Sun Apr 03, 2016 2:12 am, edited 1 time in total.

W. H. Heydt
Posts: 10762
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Need some help!- project!- IMPORTANT!

Sun Apr 03, 2016 1:56 am

ConradG13 wrote: I enter in this:

Code: Select all

chmod 755 radio
Many commands in unix and Linux work silently. That is, they do what they are supposed to, but don't give you any feedback. To see if this did what you wanted, you'd need to see before and after output from "ls -l" and look at the file permissions.

Heater
Posts: 13097
Joined: Tue Jul 17, 2012 3:02 pm

Re: Need some help!- project!- IMPORTANT!

Sun Apr 03, 2016 5:56 am

I noticed you have asked the same question again in a new thread.

Does that mean you did not read the responses we took the trouble to write here for you?

Does it mean you have tried something based on our suggestions, or something else, and it failed?

What have you tried and what new result did(s) you get?

drice
Posts: 19
Joined: Fri Dec 19, 2014 3:07 am

Re: Need some help!- project!- IMPORTANT!

Sun Apr 03, 2016 6:08 am

The instructions are for SysV init. Your Pi is likely using systemd. You will need to modify the scripts as necessary. This will require research and learning on your part. Surely this project is about more than simply plugging a speaker into the Pi and typing pre-built commands from a web site. This is your opportunity to demonstrate that you actually understand the system you are working with instead of just mindlessly following a tutorial.

Heater
Posts: 13097
Joined: Tue Jul 17, 2012 3:02 pm

Re: Need some help!- project!- IMPORTANT!

Sun Apr 03, 2016 8:49 am

To be fair to young ConradG13, getting programs started at boot up on a Linux system is not exactly trivial, it's pretty complex process, there are many ways to do it.

For example: the advice given by drice above is incorrect. Yes Raspbian Jessie uses systemd but that "update-rc.d..." thing still works on Jessie. I just tried it here to make sure. See below.

For another example: I have been using Linux exclusively since 1997 and have never seen the "missing LSB tags" error ConradG13 presents. I did not even know that init scripts had been LSB'ized. That is made compatible with the Linux Standard Base.

Suggesting that people do some research and learning is reasonable. But as we all know when one is starting out one does not even know were to begin or what to look for. A simple pointer (link now a days) in the right direction can help a lot.

Also a big problem is that googling around will often find you a lot of info that is wrong, has become wrong over time as systems change and it becomes out of date, or is wrong for your particular machines configuration.

What to do ?:

It turns out that the Linux Standard Base specification requires init scripts to have a special header that tells the update-rc.d command when it should start your program. For example it tells which other subsystems should be running before your program is started, networking, local file systems mounted etc, etc. This header also tells in which run levels the program should be started and stopped.


@ConradG13,

All you need to do is add something that looks like the following to the top of the radio script:

Code: Select all

# First you need the init information for the LSB standard SysV init scripts
### BEGIN INIT INFO
# Provides: myprog
# Required-Start:    $network $local_fs $syslog  dbus
# Required-Stop:     $network $local_fs $syslog 
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start myprog
### END INIT INFO

# Start your program here:
touch  /etc/init.d/myprog
In the above example you will need to change the program name "myprog", change the description line, and perhaps change the "Required..." lines. You won't need the "touch /etc/init.d/myprog" line, that was just me testing that it worked.

Do follow the link to the Debian information I linked to above to read about what is going on here.

ghans
Posts: 7871
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Need some help!- project!- IMPORTANT!

Sun Apr 03, 2016 8:53 am

Missing LSB tags generate a warning , not an error.
An error would bring the script to a halt , but a warning
could be ignored if you know what you're doing
and can be considered a simple nuisiance.


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Heater
Posts: 13097
Joined: Tue Jul 17, 2012 3:02 pm

Re: Need some help!- project!- IMPORTANT!

Sun Apr 03, 2016 9:44 am

ghans

I was wondering about that. Certainly the script is installed to run at start up with the init info missing and it may well happen to work.

On the other hand it might fail.

If one does not include the "Required-Start" one might find that the system tries to run your script before something it depends on is started. It will then fail.

It's all about starting things in the right order such that dependencies are satisfied.

I would suggest that today it is better to forget all that and use a systemd service configuration instead. But that is another story...

ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Re: Need some help!- project!- IMPORTANT!

Mon Apr 04, 2016 1:17 am

I have done much research and poking around and, from what I can tell, it is inconclusive. Heater, I made the suggested change with no result. I'll look it over again and see if I made a mistake. Thanks,

ConradG13
People who say times instead of multiply shouldn't be around.

ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Re: Need some help!- project!- IMPORTANT!

Mon Apr 04, 2016 2:12 am

What do you mean by, "change the required lines too..."?
People who say times instead of multiply shouldn't be around.

Heater
Posts: 13097
Joined: Tue Jul 17, 2012 3:02 pm

Re: Need some help!- project!- IMPORTANT!

Mon Apr 04, 2016 4:59 am

ConradG13,
What do you mean by, "change the required lines too..."?
What I said was 'change the "Required..." lines'. Note the quotes and ellipsis. If you look at my suggested modification to your radio script you will see there are two lines that start with "Required". As below:

Code: Select all

# Required-Start:    $network $local_fs $syslog  dbus
# Required-Stop:     $network $local_fs $syslog 
These lines specify the system services that must be running before your script is started. In this case neworking, all local file systems mounted, a system log and dbus.

All I was suggesting is that your radio script may have other dependencies. Probably it does not.

If you are still getting the warning: "Warning: script 'radio' missing LSB tags and overrides" when you run "update-rc.d radio defaults" then I'm almost sure you don't have what I suggested in the radio script.

Please post the entire and exact content of your /etc/init.d/radio file here. So that we can check it.

And the exact error/warning message you get when you use it.

ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Re: Need some help!- project!- IMPORTANT!

Sat Apr 16, 2016 10:49 pm

Well, I'm back. I've gotten to this trying to start it up.

Code: Select all

 /etc/init.d/radio
/etc/init.d/radio: line 1: GNU: command not found
numid=3,iface=MIXER,name='PCM Playback Route'
  ; type=INTEGER,access=rw------,values=1,min=0,max=2,step=0
  : values=1
  File "/home/pi/radio.py", line 2
    import time import sleep
                     ^
SyntaxError: invalid syntax
If any of you could help that'd be great
People who say times instead of multiply shouldn't be around.

User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: Need some help!- project!- IMPORTANT!

Sat Apr 16, 2016 11:11 pm

What's the contents of the initial script radio? In your py file you have a syntax error:
from time import sleep
There are 10 types of people: those who understand binary and those who don't.

ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Re: Need some help!- project!- IMPORTANT!

Sun Apr 17, 2016 12:56 am

[this is my init script

Code: Select all

  GNU nano 2.2.6                                                               $

#!/bin/bash
#/etc/init.d/radio

### BEGIN INIT INFO
# Provides: radio.py
# Required-Start:    $network $local_fs $syslog  dbus
# Required-Stop:     $network $local_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Radio
### END INIT INFO

# Start your program here:
modprobe snd_bcm2835
amixer cset numid=3 1
python /home/pi/radio.py
this is radio.py

Code: Select all

  GNU nano 2.2.6              File: radio.py                                    

#!/usr/bin env python
import time import sleep
import os
import RPi.GPIO as GPIO
# I found loads of BBC Radio streams from http://bbcstreams.com/
GPIO.setmode(GPIO.BCM)
GPIO.setup(23 , GPIO.IN)
GPIO.setup(24 , GPIO.IN)
while True:
    if GPIO.input(23)==1:
        os.system(‘sudo killall mplayer’)
        os.system(‘mplayer -playlist http://bbc.co.uk/radio/listen/live/r1.asx $
    if GPIO.input(24)==1:
        os.system(‘sudo killall mplayer’)
        os.system(‘mplayer -playlist http://bbc.co.uk/radio/listen/live/r6.asx $
    sleep(0.1);
GPIO.cleanup()

People who say times instead of multiply shouldn't be around.

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: Need some help!- project!- IMPORTANT!

Sun Apr 17, 2016 1:33 am

ConradG13 wrote: #!/usr/bin env python
import time import sleep
import os
import RPi.GPIO as GPIO
# I found loads of BBC Radio streams from http://bbcstreams.com/
GPIO.setmode(GPIO.BCM)
GPIO.setup(23 , GPIO.IN)
GPIO.setup(24 , GPIO.IN)
while True:
if GPIO.input(23)==1:
os.system(‘sudo killall mplayer’)
os.system(‘mplayer -playlist http://bbc.co.uk/radio/listen/live/r1.asx $
if GPIO.input(24)==1:
os.system(‘sudo killall mplayer’)
os.system(‘mplayer -playlist http://bbc.co.uk/radio/listen/live/r6.asx $
sleep(0.1);
GPIO.cleanup()
Does this work from the command line? I'm sceptical because when I put it into a file and I remove all the GPIO stuff that won't work on the system I'm doing this on because it is x86, and then I run it adding in some way to watch the while loop, I get a syntax error right at the first line, it won't even start. This suggests to me that you've not done anything past the part of your effort that blocked you, which from the thread looks like running a python program at system boot.

If there's anything you take away from this whole effort you've undertaken, it shouldn't just be to start things when you are assigned them or that sort of thing, or pay attention in class if that's a problem, or work out each assignment in order so you can build to the next, it should be not to let blockers stop you from going and doing things beyond them, around them, if you can. Approach a problem in pieces that you can deal with, be on both sides of a difficult area fixing things up to it and around it. Don't become fixated on starting a program you haven't even got running right yet. Don't become fixated on anything to the detriment of the whole. I don't believe that anyone you demo this to will care or even know the exact means you used to have it automatically start at boot. And it seems unlikely that a program that fails to even start running at the command line due to a syntax error is going to behave any better when started at boot.

ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Re: Need some help!- project!- IMPORTANT!

Sun Apr 17, 2016 1:50 am

By no means am I not paying attention in class. we get to do a project on a topic of our choosing. But, from what you are saying, the whole script does not work? I am confused.
People who say times instead of multiply shouldn't be around.

Heater
Posts: 13097
Joined: Tue Jul 17, 2012 3:02 pm

Re: Need some help!- project!- IMPORTANT!

Sun Apr 17, 2016 1:52 am

ConradG13,

In both your init script and your radio.pi, as shown above, you have the first line as:

Code: Select all

  GNU nano 2.2.6
And sure enough you show the error message:

Code: Select all

/etc/init.d/radio: line 1: GNU: command not found
I have no idea where you got those spurious lines from but clearly they should not be there.

I'm very sure the line:

Code: Select all

import time import sleep
Is not correct.
And sure enough you have the error message:

Code: Select all

  File "/home/pi/radio.py", line 2
    import time import sleep
                     ^
SyntaxError: invalid syntax
Which tells you exactly that.

ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Re: Need some help!- project!- IMPORTANT!

Sun Apr 17, 2016 1:57 am

Oh! ok. I know how those lines got there. the GNU one at least that makes more sense. Thank You!
People who say times instead of multiply shouldn't be around.

ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Re: Need some help!- project!- IMPORTANT!

Sun Apr 17, 2016 2:04 am

Ok, I got rid of that. Now, I receive this message.

Code: Select all

[email protected]:~ $ /etc/init.d/radio
numid=3,iface=MIXER,name='PCM Playback Route'
  ; type=INTEGER,access=rw------,values=1,min=0,max=2,step=0
  : values=1
  File "/home/pi/radio.py", line 10
SyntaxError: Non-ASCII character '\xe2' in file /home/pi/radio.py on line 10, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
and, the /home/pi/radio.py is below.

Code: Select all

  
#!/usr/bin env python
import os
import RPi.GPIO as GPIO
# I found loads of BBC Radio streams from http://bbcstreams.com/
GPIO.setmode(GPIO.BCM)
GPIO.setup(23 , GPIO.IN)
GPIO.setup(24 , GPIO.IN)
while True:
    if GPIO.input(23)==1:
[email protected]:~ $ /etc/init.d/radio
numid=3,iface=MIXER,name='PCM Playback Route'
  ; type=INTEGER,access=rw------,values=1,min=0,max=2,step=0
  : values=1
  File "/home/pi/radio.py", line 10
SyntaxError: Non-ASCII character '\xe2' in file /home/pi/radio.py on line 10, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
        os.system(‘sudo killall mplayer’)
        os.system(‘mplayer -playlist http://bbc.co.uk/radio/listen/live/r1.asx &’)
    if GPIO.input(24)==1:
        os.system(‘sudo killall mplayer’)
        os.system(‘mplayer -playlist http://bbc.co.uk/radio/listen/live/r6.asx &’)
    sleep(0.1);
GPIO.cleanup()
People who say times instead of multiply shouldn't be around.

Heater
Posts: 13097
Joined: Tue Jul 17, 2012 3:02 pm

Re: Need some help!- project!- IMPORTANT!

Sun Apr 17, 2016 2:14 am

That cannot be the content of your radio.py file. It's a total mess.

ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Re: Need some help!- project!- IMPORTANT!

Sun Apr 17, 2016 2:19 am

Oops, I accidentally mixed the script with the error message, here is the script.

Code: Select all

#!/usr/bin env python
import time import sleep
import os
import RPi.GPIO as GPIO
# I found loads of BBC Radio streams from http://bbcstreams.com/
GPIO.setmode(GPIO.BCM)
GPIO.setup(23 , GPIO.IN)
GPIO.setup(24 , GPIO.IN)
while True:
    if GPIO.input(23)==1:
        os.system(‘sudo killall mplayer’)
        os.system(‘mplayer -playlist http://bbc.co.uk/radio/listen/live/r1.asx &’)
    if GPIO.input(24)==1:
        os.system(‘sudo killall mplayer’)
        os.system(‘mplayer -playlist http://bbc.co.uk/radio/listen/live/r6.asx &’)
    sleep(0.1);
GPIO.cleanup()
People who say times instead of multiply shouldn't be around.

Heater
Posts: 13097
Joined: Tue Jul 17, 2012 3:02 pm

Re: Need some help!- project!- IMPORTANT!

Sun Apr 17, 2016 2:33 am

You have a problem with the line

Code: Select all

#!/usr/bin env python

ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Re: Need some help!- project!- IMPORTANT!

Sun Apr 17, 2016 2:43 am

And that would be?
People who say times instead of multiply shouldn't be around.


stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: Need some help!- project!- IMPORTANT!

Sun Apr 17, 2016 3:15 am

ConradG13 wrote: we get to do a project on a topic of our choosing. But, from what you are saying, the whole script does not work? I am confused.
1. If the topic is of your choosing, why are you fixated on this one way of starting up an application at boot? You might google into this forum about how to start a python script at boot and you might find several ways, some of which might be easier.

2. I don't know that the whole script can't work, I just know that if it has a syntax error right at the top, it not starting shouldn't surprise you.

3. No one is suggesting that you remove lines such as the one involving the import of sleep since you are later going to use the sleep function and need it. But that line needs to be correct and someone pointed that out previously and you didn't fix it. The only lines you should remove are the ones you don't need.

4. Make the program itself work correctly from the command line, consider the part about making it start automatically at boot to be something you are working on in parallel. Your drop dead date is fast approaching, from what you say, you don't want to finally get the program to start on boot and then it doesn't work right and you've got no time to fix it.

Return to “General discussion”