Like many people I was very excited to see the Google AIY Raspberry Pi addon. Before my copy of the MagPi magazine arrived with the kit I had already installed the software on a linux laptop. One of the things I liked about the project is that, whilst it is to some extent targetted at the Raspberry Pi, it is actually a very good example of using standard modules and frameworks to produce something that is very cross platform and should work very easily on a variety of systems with very little work.
One of the aspects I would like to talk about today is the method used for the LED status indicator. Unlike the speech processing the LED is rather Raspberry Pi specific, as it depends on GPIO locationsupport which is not likely present on other platforms. However the way that this has been implemented allows you to ignore or reimplement it quite trivially in some other way.
How did they do this? Simply put they used a system called mknod to create a FIFO that can be accessed as a file. This file is then used as the input source to the led.py python script. Anyone that wants to change the led state simply writes to that file.
I have produced a simple example that illustrates how this can be done quite easily.
First the python file which will receive messages.
This simply loops until it sees user input that is equal to “Hello 9” printing what if not a:
ever is input in reverse (note this is for python 2.7, if you are using python 3 you would replace raw_input with input).
Next the producer
This writes to a file called myfifo.txt , flushes the write after each line and then sleeps.
If you just run this as it is you will end up with a file containing lines from Hello 0 to Hello 9
The secret sauce is in the next bit.
This will compile the C code for the producer
use mknod to create the fifo
Launch the python script in the background redirecting myfifo.txt as user input
and then launch the producer which will write to the fifo.
There you now have a nice simply way of sending a message from one process to another.
I am a big fan of online learning (or learning in general), and I periodically have a look at courses that interest me. So thought I could share some of my experiences here, starting with the first one I looked at. I will attempt to summarise the course content, style, difficulty and general presentation of the course so that you can see if it is for you.
The first online course I looked at was the EDx Harvard course ‘Science and Cooking: from Haute Cuisine to Soft Matter Science’ https://courses.edx.org/courses/HarvardX/SPU27x/2013_Oct/course/
This course mingles science and cooking, using bits from each to explain/demonstrate each. There are a number of top chefs who provide some interesting background to the course, but for me it was the science bits of it that were of interest.
The course goes into a fair amount of depth, and the review quiz’s are well spaced and sufficiently tricky that you actually need to pay attention and in some cases sit down with a calculator and work things out.
The course also has a number of (ungraded) lab excercises where you head to your kitchen and perform an experiment to underline something you have learned during the course. For example making ice-cream with ice-water and salt to produce sub-zero temperatures and demonstrate phase changes!
The course is well presented, the videos and text go together well, and it felt like they cover things in sufficient depth to actually be worthwhile without spending too long on any one thing.
Warning that there is some maths involved so, but it is not complex so shouldn’t put anyone off.
I have to confess I didn’t finish the course, I was initially trying to keep pace with it whilst it was a live course and fell behind due to life getting in the way, but I would definitely recommend the course and will try and get back to it at some point.
Just to mention that there is a site http://www.sudorandom.com this is a completely unrelated site to mine. Clearly the owner has excellent taste in urls! I assume that the owner picked the name for basically the same reason as me, they like a bit of word play and wanted something to represent an open-ended site with a technical slant.