Did you ever look into a room of a house, through a dirty window, while it is dark inside, and tell yourself, “Yeah, I can tell how big that room is.” Or “I got a pretty good idea what’s in there.” Then actually go into the house, see that room from the inside, and realize you had no idea what that room was actually like.
I’m beginning to feel like that. It’s a good thing hardly anybody has viewed my previous posts on this subject, because although they are correct, they are not very complete or clear. So let’s start at the top and work our way down.
The Operating System: When I loaded an OS onto my Raspberry Pi, I just blindly followed some steps, and did not really pay attention to what I was actually doing. In retrospect, I now realize that I used NOOBS, to load Raspbian which is based on Debian, (and optimized for use on the RBP hardware), which is a derivative of Linux, which is a free, open source, OS project begun by Linus Torvalds in the 1990’s response to the high cost of commercial OS’s such as Unix.
OK. Now I have a rough idea of how the Rasbian OS, came to be running on my RBP. BTW: You can use NOOBS to install other OSs too, and let’s not forget to mention Microsoft has a version of Windows 10 that runs on the Raspberry Pi 2.
Controlling the GPIO Pins: The reason I dove into the origins of the OS, is that a feature of the OS (sysfs), is used to control the RBP GPIO pins. Instead of trying to improve on Wikipedia’s description, I will just copy it:
“sysfs is a virtual file system provided by the Linux kernel. By using virtual files, sysfs exports information about various kernel subsystems, hardware devices and associated device drivers from the kernel’s device model to user space. In addition to providing information about various devices and kernel subsystems, exported virtual files are also used for their configuring.”
So now I know where all of that business about reading and writing files, to control the GPIO pins came from. This is not something created out of nothing by the Raspbery Pi gods. It is a standard feature of the Linux OS and its derivatives. Hence, it should be well understood and supported.
Now that I know to Google/Bing “sysfs”, it was relatively easy to find information like this: sysfs.txt. Which, although it is a little dense, is a complete list of the file names and values used by the sysfs system to manipulate the RBP GPIO pins. This will be very helpful in completing my pi_gpio.erl Erlang code module. I also found this article on page 12 of Issue 7 of MagPi: Interrupts and Other Activities with GPIO Pins. Although the links to the code examples are broken, I thought it was a very good explanation.
Not a lot of progress this week, but sometimes, you just have to stop and ask; “Where am I, what am I doing, and how did I get here?” Hope this clarifies things a bit for you. Let me know if you have any good Raspberry Pi resources.