Turning off the screen saver – Easy way An easy way to achieve this is to install xscreensaver then configure it to disable (its also the Raspberry Pi recommended way) Then in the GUI go to Preferences > Screensaver > Display Modes > Select disable screen saver from the dropdown. Turning off the console screen saver – […]
All posts by
Detecting Hardware Version
Use /proc/cpuinfo to read the One-Time-Programmable hardware version number value burned into the SoC at manufacture (along with the unique serial number, etc). 000f means the Rev 2.0 board with 512M memory. Some of those had 5 burnt in by mistake, but firmware interprets that as f
Scripts
Auto running a script Create the script Create a folder to store the script in mkdir ./bin cd ./bin Create the script using the nano text editor sudo nano script_auto_run In the nano editor, type this script: #!/bin/bash # Script to start our application echo "Doing autorun script…" sudo /home/pi/projects/my_project.a & Replace "sudo /home/pi/projects/my_project.a […]
Auto Running Programs-Command Line
Auto running applications in the GUI See here Auto running terminal applications (non GUI) First ensure your program is executable by finding it in the file manager. Right click on the file and select properties. Select the permissions tab, check the ‘Make the file executable’ box and press OK. Or from the command line use: sudo chmod […]
.Command Line General
Good Resources The Linux Command Line – free pdf book Get previously entered commands Use the up and down cursor keys. Issuing multiple commands in a single line If subsequent commands should only occur if the previous command succeeded use "&&": sudo ifdown eth0 && sudo ifup eth0 If subsequent commands should occur regardless of […]
CR and LF
UNIX only requries LF "\n" at the end of the line but will generally accept the windows CR+LF "\r\n" if present (apart from shell scripts)
Using console commands in code
The command line in Linux is so incredibly powerful with so many functions available to you via the OS and optional applications you can install. It is often the easiest solution in C++ programs to just use the command line to achieve something you need doing rather than finding a harder way to do it in code and the following […]
Configuring Network Adaptors
Editing Network Adaptor Settings Restarting After Changes After changes to the network interface configuration, you have to restart the network interface using this (assuming the interface is called “eth0”). sudo ip link set eth0 down && sudo ip link set eth0 up Assigning A Manual IP Address For recent versions of Raspbian /etc/network/interfaces should no longer be […]
Getting Arguments Supplied To The Program
int main(int argc, char **argv) { if (argc < 2) //Check enough arguments we're supplied { fprintf(stderr, "You didn't supply enough aruuments\n"); exit(EXIT_FAILURE); } //Check the arguments int i; for(i = 1; i <argc; i++) //argc is always >=1 as the first argument is always the programs name { ++argv; if (strncmp(*argv, "somevalue1", 100) == […]
Named Pipes / FIFO’s
If you need unrelated processes to be able to exchange data you can do this using FIFOs, often referred to as named pipes. A named pipe is a special type of file (everything is a file in linux!) that exists as a name in the file system but behaves like unnamed pipes. Once created […]