Raspberry Pi 3


https://it.slashdot.org/story/17/07...-code-execution-for-two-years?sdsrc=popbyskid

You haven't been on the planet, and woke, for long enough to see when something hits a scene unnaturally fast - in any realm. That's an almost sure sign for a manifestation of evil.

And finally, the lamest vendor response award went to Systemd supremo Lennart Poettering for his controversial, and perhaps questionable, handling of the following bugs in everyone's favorite init replacement: 5998, 6225, 6214, 5144, and 6237... "Where you are dereferencing null pointers, or writing out of bounds, or not supporting fully qualified domain names, or giving root privileges to any user whose name begins with a number, there's no chance that the CVE number will referenced in either the change log or the commit message," reads the Pwnie nomination for Systemd, referring to the open-source project's allergy to assigning CVE numbers. "But CVEs aren't really our currency any more, and only the lamest of vendors gets a Pwnie!"

https://en.wikipedia.org/wiki/Heartbleed

See, I can find really bad bugs in critical pieces of software too!
 
https://it.slashdot.org/story/17/07...-code-execution-for-two-years?sdsrc=popbyskid

You haven't been on the planet, and woke, for long enough to see when something hits a scene unnaturally fast - in any realm. That's an almost sure sign for a manifestation of evil.

And finally, the lamest vendor response award went to Systemd supremo Lennart Poettering for his controversial, and perhaps questionable, handling of the following bugs in everyone's favorite init replacement: 5998, 6225, 6214, 5144, and 6237... "Where you are dereferencing null pointers, or writing out of bounds, or not supporting fully qualified domain names, or giving root privileges to any user whose name begins with a number, there's no chance that the CVE number will referenced in either the change log or the commit message," reads the Pwnie nomination for Systemd, referring to the open-source project's allergy to assigning CVE numbers. "But CVEs aren't really our currency any more, and only the lamest of vendors gets a Pwnie!"


Do you mind trying not to derail ontopic threads?? Make your own systemd thread if you want.. Nobody here really cares as this thread infact is about the Raspberry Pi 3.
 
"I know I need one of these to safely shut down the Pi but past that I can get no help on which music player to use or how to get it to continue when power is re-applied"

mplayer is a pretty good universal command-line music player as well. mpg321 works too, for mp3s.

Simplest way is to run something on boot is to put whatever script or command you need to run in the file /etc/rc.local
https://files.devuan.org/devuan_jessie/embedded/README.txt
 
Last edited:
Many thanks for your help with this guys but I'm giving up, it's just too frustrating.

I keep getting permission errors when trying to edit the config files, and the same when trying to put files in the default locations for mpd, it's just not worth the hassle.

All I want is full root access so that I can tinker to my hearts content, if I cock it up so be it but that's how I learnt on my Amiga and Windows, all those machines are still here and running fine.

Sick of using sudo all the time, nano is a completely archaic editor and even when using sudo I'm getting extra copies of files, it's not overwriting the file I'm editing.
 
Last edited:
I haven't read all the stuff leading up to this, but you should be able to use gksudo if you want to use a graphical text editor instead of nano. For example, you can give mousepad root permissions on Pandora with:

gksudo mousepad
 
I keep getting permission errors when trying to edit the config files, and the same when trying to put files in the default locations for mpd, it's just not worth the hassle.

All I want is full root access so that I can tinker to my hearts content, if I cock it up so be it but that's how I learnt on my Amiga and Windows, all those machines are still here and running fine.

Sick of using sudo all the time, nano is a completely archaic editor and even when using sudo I'm getting extra copies of files, it's not overwriting the file I'm editing.

so login as root user, or switch to root using 'su' command.
 
Many thanks for your help with this guys but I'm giving up, it's just too frustrating.

I keep getting permission errors when trying to edit the config files, and the same when trying to put files in the default locations for mpd, it's just not worth the hassle.

All I want is full root access so that I can tinker to my hearts content, if I cock it up so be it but that's how I learnt on my Amiga and Windows, all those machines are still here and running fine.

Sick of using sudo all the time, nano is a completely archaic editor and even when using sudo I'm getting extra copies of files, it's not overwriting the file I'm editing.

This is a great learning moment. Are you aware that *nix is a multiuser environment? It enforces limits on who can do what.
ls -l will show you all the files in a directory and who owns them.
By default, mpd is setup so that only privlidged users can add files to the default directory. You could "sudo chmod a+w /var/lib/mpd" to allow anyone to add files to this directory but you are still going to fall short I think on the loading files from sd card problem.

I'm a user of vi to edit my files. So I don't know how you are getting extra copies.
To edit a file in vi, you need to edit insert mode or append mode by pressing i or a. Then you can type.
You can leave this mode by pressing escape.
To write the file, make sure you are in command mode (escape) then :wq
To quit without saving, command mode, :q!
 
FWIW, vi irritates me in that when I want to change something such as a word, and I enter cw in command mode to do that, it just puts a $ at the end of the word and only fixes up the line length if you exceed the length of the original word or hit escape to exit the change edit. I much prefer the way vim does it which is to initially delete the word and put you into change edit mode, and as you type the line grows just like in other editors. Maybe when line speeds were so slow we used to describe them in baud, it was the best way of representing that change, but it just feels so foreign to me that if I'm ever in an environment without vim it really grates.
 
Last edited:
I must be a glutton for punishment but I did have some progress.

I now have the Pi playing music when powered on and it starts on the file it was powered down on, I haven't set it to delete any files yet until I am sure it is working 100%

Now to try and get it to work using some buttons connected to the GPIO pins, anyone point me to a tutorial? I need 3 buttons: Play/Pause, Next and Previous track.
 
I'm glad you were able to push your way through your problems. Was it just a different day that helped or has some advice improved your understanding?

You are about to step outside what I am able to help with though. You'll have to write some code to deal with your hardware setup. I haven't really go the time to be setting up buttons on my pi.
What you need to do is set up some software interrupts for the GPIO pins and call commands.
http://raspi.tv/2013/how-to-use-interrupts-with-python-on-the-raspberry-pi-and-rpi-gpio-part-3 should be all you need.

You need to set up your pins > GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
Define the method to be called when the pin is triggered > def my_callback(channel):
Link the pin to the method > GPIO.add_event_detect(17, GPIO.FALLING, callback=my_callback, bouncetime=300)

What you want to do when the buttons are pressed is mpc toggle, mpc next and mpc prev.
You should be able to do these by:
import os
os.system('<the command>')

Do things one step at a time. Make sure you can control mpd from python. Then start looking at the GPIO problem.

An important note about GPIO on the pi, python needs to be run as root to do the modifications so your friend sudo will be back.

-- edit after thinking of alternatives --
I originally thought about using a usb keyboard that had 3-5 buttons controlling mpd. You would map the buttons from this small keyboard to the shortcuts in ncmpc (P > and <)
Since you wanted to go the gpio option, I looked around.
I found http://blog.gegg.us/2017/01/setting-up-a-gpio-button-keyboard-on-a-raspberry-pi/ which enables you to map gpio ports to key presses. I originally passed on it because you couldn't map the keys to shift modified characters. On reflection, this might be an easier method to build upon though.
You would still need to write a program that takes keyboard input and converts it to the right mpc call. This is much easier to test as you could use any keyboard.
Then it is just a matter of getting that dts system working. Once you have the buttons wired up and the dts installed, you can see whether the buttons generate output on a console.
Then link it all together. The advantage of this approach is the program listening to keyboard events doesn't need to be executed as root. You don't have to clean up the GPIO configuration. Hopefully the kernel is handling the interrupt configuration as efficiently as possible.
 
Last edited:
Was it just a different day that helped or has some advice improved your understanding?

I think it was a bit of both, reading through your post and googling for the mpc/mpd commands.

I haven't written any code since Basic on my ZX Spectrum so this is going to be fun, but I'm not giving up now.

Many thanks for your help.
 
I found http://blog.gegg.us/2017/01/setting-up-a-gpio-button-keyboard-on-a-raspberry-pi/ which enables you to map gpio ports to key presses. I originally passed on it because you couldn't map the keys to shift modified characters. On reflection, this might be an easier method to build upon though.
That's pretty neat, and much easier than what I did...
For my bedtime media player, I use the filesystem access to GPIO (I think it's via /sys/class/gpio) and created a virtual keyboard, then monitor the GPIO states and update the relative virtual keyboard state
 
I have a tenkeyless 60% size folding bluetooth keyboard from the early days of bluetooth, and that works fine on my Pandora I'm expecting it to on my Pyra just as well, but we won't know for sure until we all have ours. I'd half expect these things to use the same protocol, but I don't know they haven't reinvented the wheel for myself.
 
That's pretty neat, and much easier than what I did...
For my bedtime media player, I use the filesystem access to GPIO (I think it's via /sys/class/gpio) and created a virtual keyboard, then monitor the GPIO states and update the relative virtual keyboard state
How was the cpu usage of that setup?
Did you write a program to do the monitoring or could you pull it off with a bash script?
Did you have any problem with missed input? Did you have to hold the button down until the command was received or was it very responsive?

Do Bluetooth keyboard things work?
I have one that looks a bit like this, that I was messing about with on the Pandora a while back:
https://www.ebay.co.uk/itm/311605485573
Or this one:
https://www.ebay.co.uk/itm/263385563328
They don't have much documentation though, so hard to know what they actually do before buying.
I've used a dongle based keyboard but a bluetooth tiny keyboard should also work. My major concern would be ensuring that the pi and keyboard always paired. You would need a kill switch on the pi just in case it became unpaired. I should add one of these to my list of things to get. Looks like fun :)
 
How was the cpu usage of that setup?
Never really checked, not much as far as I'm aware, more is probably spent on X and Audacity than my Qt app

Did you write a program to do the monitoring or could you pull it off with a bash script?
It's a Qt graphical app (I only did it as graphical, because I was using an X based media player). You might be able to do bash script, but I don't know bash scripting all that well.
I've uploaded the source in case you're interested in having a look, you'll see that it's quite hacky (I wired up pin 15, but for some reason it only ever reports "1" regardless of my switch status, never figured out why, so I just ignored that pin)

Did you have any problem with missed input? Did you have to hold the button down until the command was received or was it very responsive?
Well, when I first wrote it, I had quite a slow "check" timer, so you had to hold down the volume buttons for about 2 seconds for it to register, then release and repress; but I ended up shortening the timer, and I also added code that mimics key down and key up when you actually press and release the keys (rather than just "press" the key if the button is down).
Bizarrely, when I press the volume key, it doesn't take long to speed through the volume, so I don't know if there's a very quick key repeat, or it's just the way Audacity is handling it.

It pretty much does the job (though I always forget which switches do what on my hat, and generally just leave it with 4 hour shutdown playing C64radio.com). I could really do with a little display on it, even if it's some of those lettered LED segments.

Here's a picture of my board (well, first and second revision - first I soldered upside down because I was an idiot)
https://snag.gy/Ge7gXz.jpg

To be fair, I wouldn't actually recommend those protoboards. The holes in the "breadboard" part are fine for wires, and my DIP switch, however, you cannot fit any push-switches in, so they don't sit flush against the board.
 

Attachments

  • automusic.7z
    3.7 KB · Views: 135
Here's a picture of my board (well, first and second revision - first I soldered upside down because I was an idiot)
https://snag.gy/Ge7gXz.jpg

To be fair, I wouldn't actually recommend those protoboards. The holes in the "breadboard" part are fine for wires, and my DIP switch, however, you cannot fit any push-switches in, so they don't sit flush against the board.
That's cool. Thanks for sharing that. I can't imagine it using much power/cycles but it is using a polling method which in my ideal world I would want to avoid. Understand that it does just work though.

Pity about the protoboard. Although I've had trouble with buttons fitting on other protoboards (event breadboards) so maybe it's just a case that the buttons aren't meant to be used that way.

I could see that setup working with a bash script although it would be fiddly.
 
Back
Top