advertisement


Be real neat if

Thanks all.

I added the startup with
Code:
vi /opt/bootlocal.sh
and added
Code:
sudo /home/tc/relay.sh > /dev/null &"
Did the backup with
Code:
sudo filetool.sh -b

Then
Code:
sudo reboot

It is now not possible to SSH into the Rpi neither can my browser find the webgui.

Possible its due to me forgetting to stop the script before the backup was initiated.
Code:
sudo killall ./relay.sh
Maybe I should have stopped pCP also from the webbui.

Ill take the SD card work tomorrow and get a fresh image with a W7 machine and try again.
 
So I managed to re image the SD card with Linux some how!

This time I booted the system, stopped squeezelite, pasted in the relay script, made it executable but did not run it.
Nor did I add the start up command in /opt/bootlocal.sh

At this point I did the backup with filetool.sh

Then sudo reboot which was successful.

Lastly I ran the script ./relay.sh > /dev/nul &" and it crapped out again.

So it looks to be persitant now but I need to have a fiddle with the start up script as suggested by Greg

All seemed fine so I rebooted, stopped squeezelite and added the start up script to /opt/bootlocal.sh.
 
Thanks all.

I added the startup with
Code:
vi /opt/bootlocal.sh
and added
Code:
sudo /home/tc/relay.sh > /dev/null &"
I assume you didn't put the " in.
Did the backup with
Code:
sudo filetool.sh -b

Then
Code:
sudo reboot

It is now not possible to SSH into the Rpi neither can my browser find the webgui.
Been there. It can be fun working out, if it's a typo, wrong path, permissions or a timing issue.
Possible its due to me forgetting to stop the script before the backup was initiated.
Code:
sudo killall ./relay.sh
This is not a problem. Remember, piCore runs in memory. Everything starts from scratch after a reboot. A brand new file system in memory.
Maybe I should have stopped pCP also from the webbui.
Not an issue. I prefer to use the web interface as it uses a slightly more graceful process but its not mandatory.
Ill take the SD card work tomorrow and get a fresh image with a W7 machine and try again.
That's probably the quickest method, or
1. You probably should connect a console to the RPi to check for error messages. Plug a keyboard in to edit the file if the console works.
2. I have a Debian VM on my W7 machine for just such occasions. Its also handy for using expanding the partition.

regards
Greg
 
Thanks for the pointers Greg.
I have to say that pasting into or copying out off vi is most oddly very hit and miss, often the beginning or end gets changed, appended or missed.
Just realised it does not like me pasting into the first line, much more reliable to start the past at the second line and I have just worked out that cat relay.sh is a better way to copy out as I cannot scroll vi whilst selecting the text to copy.
All silly things really but coupled with limited underpinning knowledge it just leads to unnoticed mistakes.
Most likely you have found my error with
I assume you didn't put the " in.

I had some funny output the last time I manually started relay.sh with the redirect to null, quite probable that I had picked up on a typo that I kept pasting in.

I was worried about the backup being corrupted by running program user space data being copied back, but you have settled my mind on that one.

Its working a treat other than for needing the auto start script so very nearly there.

Regards
Tony
 
Looking very good, I ended up with

Code:
tc@piCorePlayer:~$ cat /opt/bootlocal.sh
#!/bin/sh
# put other system startup commands here
#amixer cset numid=3 2
sleep 5
sudo /home/tc/relay.sh > /dev/null &
#mnt/mmcblk0p2/tce/OliWeb-master/ivySox/myweb/do_rebootstuff.sh
/home/tc/www/cgi-bin/do_rebootstuff.sh

And hardly any CPU loading.
0.6 % CPU sh /home/tc/relay.sh

Been testing for a few hours and looks perfect
 
Looking very good, I ended up with

Code:
tc@piCorePlayer:~$ cat /opt/bootlocal.sh
#!/bin/sh
# put other system startup commands here
#amixer cset numid=3 2
sleep 5
sudo /home/tc/relay.sh > /dev/null &
#mnt/mmcblk0p2/tce/OliWeb-master/ivySox/myweb/do_rebootstuff.sh
/home/tc/www/cgi-bin/do_rebootstuff.sh

And hardly any CPU loading.
0.6 % CPU sh /home/tc/relay.sh

Been testing for a few hours and looks perfect

Fingers crossed. :D

BTW Tony, what version of piCorePlayer are you using?
 
Greg, still working perfectly, no issues.

I have been PMed by palmerx with a request for my image.
Here is your link
Might take some time to get the image across.

There should be just one folder accessible, its currently empty as the image is copying across.
Could someone just confirm that just the one folder is viable.

https://www.dropbox.com/sh/xumhl4vzxphmha2/AAB_6t9Ifuqvy9yav2172Qf9a?dl=0

Regards
Tony

Hi Tony,

Good news that it is working perfectly. :D

The links are working correctly. I started the download but stopped because it was going to take 25 minutes.

regards
Greg
 
Dear Bemused, dear Greg Erskine


Thank you very much for your help. The image from Tony was wery helpful for me.

What I did:


I modified the relay.sh with notepad++:

-The IP of my LMS
-The MAC of my Raspi
(and the on GPIO ON part)

Then I transferd it to the running raspi with WinSCP


On putty I loged in and did

sudo filetool.sh -b

so the script was stored.


Then I had a try with

sudo ./relay.sh

and it was working perfectly.


On the relay.sh I made another modification that the GPIO stays on during the play state of the Player.


The only nice thing would be to set the IP from the Raspi as static for a nice Networksetup. Is there a easy solution for that?
 
Pleased your sorted, I was getting tense as I need the dropbox space back for Monday morning.

The easy way to make the IP address static is in your routers setup GUI. Probable under advanced options.
Methods vary from router to router, with my current one its "keep this IP add" previous routers were "Set IP add" and "Set lease time to 100 years"
 
Dear Bemused, dear Greg Erskine


Thank you very much for your help. The image from Tony was wery helpful for me.

What I did:


I modified the relay.sh with notepad++:

-The IP of my LMS
-The MAC of my Raspi
(and the on GPIO ON part)

Then I transferd it to the running raspi with WinSCP


On putty I loged in and did

sudo filetool.sh -b

so the script was stored.


Then I had a try with

sudo ./relay.sh

and it was working perfectly.


On the relay.sh I made another modification that the GPIO stays on during the play state of the Player.


The only nice thing would be to set the IP from the Raspi as static for a nice Networksetup. Is there a easy solution for that?

hi palmerx,

I'm happy you got a result.

I must admit I was concerned that you didn't have the skills to get this done. I was so pleased to see your last post that showed you had the skills to do it.

I set a static IPs via my router. This way, all the static IPs of my computers are managed by one tool in one location. I can also backup this configuration, so none of the IPs are ever lost.

We are investigating zero config options which will make knowing the IP of piCorePlayer redundant.

regards
Greg
 
Hi there!


I just whant to show you the result of you help with the relay story.
At the first pictures you can see the self made Audio detection board with the OpAmps that I have made. This was never woking very satisfining.

Now that I can switch with the Playstate the Audioserver is working perfectly for tree Zones from the Raspis and one from the Vortexbox for the homecinema.

Again Thanks to you all!


https://www.dropbox.com/sh/2rinbtvh3wracha/AABsBm2DsbPHmsdTDFXmNxp4a?dl=0



Best regards,


Marc
 
Hi there!


I just whant to show you the result of you help with the relay story.
At the first pictures you can see the self made Audio detection board with the OpAmps that I have made. This was never woking very satisfining.

Now that I can switch with the Playstate the Audioserver is working perfectly for tree Zones from the Raspis and one from the Vortexbox for the homecinema.

Again Thanks to you all!


https://www.dropbox.com/sh/2rinbtvh3wracha/AABsBm2DsbPHmsdTDFXmNxp4a?dl=0



Best regards,


Marc

Hi Marc,

Wow! very impressive, thanks for sharing. :D

If you ever do a write up about it, please post a link, I'd be interested in more details.

regards
Greg
 
Hi there!


I just whant to show you the result of you help with the relay story.
At the first pictures you can see the self made Audio detection board with the OpAmps that I have made. This was never woking very satisfining.

Now that I can switch with the Playstate the Audioserver is working perfectly for tree Zones from the Raspis and one from the Vortexbox for the homecinema.

Again Thanks to you all!


https://www.dropbox.com/sh/2rinbtvh3wracha/AABsBm2DsbPHmsdTDFXmNxp4a?dl=0



Best regards,


Marc

Neato, it's nice when a plan comes together.

Another success with Gregs script.
 
Hi there,
with the information from this thread I managed to wire some buttons to the GPIOs and build a script to control volume, start/stop and some hard coded stations for my picoreplayer in the kitchen without the phone. Something my better half demands :)

Thank you for the info in this thread!

Here's the script, maybe it is of use to somebody:

Code:
#!/bin/sh

player=started

echo "17" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio17/direction

echo "27" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio27/direction

echo "22" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio22/direction

echo "23" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio23/direction

echo "24" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio24/direction

echo "25" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio25/direction

echo "4" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio4/direction

while true
do
    PRESSED17=$(cat /sys/class/gpio/gpio17/value)
    PRESSED27=$(cat /sys/class/gpio/gpio27/value)
    PRESSED22=$(cat /sys/class/gpio/gpio22/value)
    PRESSED23=$(cat /sys/class/gpio/gpio23/value)
    PRESSED24=$(cat /sys/class/gpio/gpio24/value)
    PRESSED25=$(cat /sys/class/gpio/gpio25/value)
    PRESSED4=$(cat /sys/class/gpio/gpio4/value)
    # echo $PRESSED
    # sleep 1
    if [ $PRESSED17 = 1 ]; then
        if [ $player = stopped ]; then
            echo "Start player"
            echo "RASPI_MAC_ADRESS_GOES_HERE play" | telnet LMS_IP_ADRESS:9090
            player=started
            sleep 0.2
        else
            echo "Stop player"
            echo "RASPI_MAC_ADRESS_GOES_HERE stop" | telnet LMS_IP_ADRESS:9090
            player=stopped
            sleep 0.2
        fi
    fi
    if [ $PRESSED27 = 1 ]; then 
        echo "RASPI_MAC_ADRESS_GOES_HERE mixer volume +10" | telnet LMS_IP_ADRESS:9090
        sleep 0.2
    fi
    if [ $PRESSED22 = 1 ]; then 
        echo "RASPI_MAC_ADRESS_GOES_HERE mixer volume -10" | telnet LMS_IP_ADRESS:9090
        sleep 0.2
    fi
    if [ $PRESSED23 = 1 ]; then 
        # 1Live 
        echo "RASPI_MAC_ADRESS_GOES_HERE playlist play http://opml.radiotime.com/Tune.ashx?id=s25260&formats=aac,ogg,mp3&partnerId=16&serial=2528c649c658ffeadb7b041df6321e3e" | telnet LMS_IP_ADRESS:9090
        sleep 0.2
    fi
    if [ $PRESSED24 = 1 ]; then 
        # radioeins
        echo "RASPI_MAC_ADRESS_GOES_HERE playlist play http://opml.radiotime.com/Tune.ashx?id=s25111&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=afe440bda10df77274ddb47d62a6025f" | telnet LMS_IP_ADRESS:9090
        sleep 0.2
    fi
    if [ $PRESSED25 = 1 ]; then 

        sleep 0.2
    fi
    if [ $PRESSED4 = 1 ]; then  

        sleep 0.2
    fi
    [B]sleep 0.2[/B]
done

echo "17" > /sys/class/gpio/unexport

exit

I observed that the last "sleep 0.2" needs to be present to reduce the load that this script produces. I played around with the value a bit to get a good tradeoff between responsiveness and cpu load. If the sleep command is omitted here, my CPU load just from the script was around 10% all the time. With 0.2, CPU load is around 1-2% which I think is ok. With higher values, response to a short button press cannot be guaranteed, as the script might be in the sleeping stage while the GPIO changes from 0 to 1 and back to 0 again.

A nicer way to do this would propably be to use interupts, but from what I read we would need python for this, correct?

Might there be a way to include a stripped down python environment into picoreplayer that doesn't affect boot time to much?

I just feel like this endless loop is a dirty way to implement this :)

Any thoughts?
 
Understand what your saying but sleep 2 makes it well behaved.
I use interrupts in my industrial stuff but hwve no idea how to assign an interrupt to a pi event.
Looks neat I may use your script and qdd volume to our bathroom player.
Thanks for sharing, I think its neat.
 
hi Holtugan,

Great to see a successful project. :D

I agree that an endless loop is a bit of a hack but as I said in post #4

Also, I believe the solution should not bloat piCorePlayer, that means no bash, no perl, no python just shell. It might not be as elegant, but it keeps with to the piCorePlayer philosophy of minimal and compact.

Python and dependencies are about 10MB , not much, but compared to piCorePlayer in total being only 37MB it is a big increase. In a standard distribution there are also other considerations and compromises.

What we are working on is the ability to easily load piCore extensions from the web interface and also a method to expand the file system to accommodate these additions.

regards
Greg
 


advertisement


Back
Top