Directory Locations Referenced from root Use “/”, e.g. “/home/pi/my_directory_name” Create Directory If It Doesn’t Exist List contents of a directory
All posts by
.General PHP Code Tricks
Issuing Commands From Web Pages If you install a PHP web server on your RPi you can issue commands using the PHP system() function. Examples: //Echo some system status: echo '<pre>'; system('netstat -a'); echo '</pre>'; //Run an executable file: echo '<pre>'; system("sudo /home/pi/projects/my_project.a"); //system() will echo the output of the executable, use shell_exec() instead if […]
Root user privileges
After logging in as user pi, using this command give you root user privileges: sudo su Exiting root user mode Use the exit command: exit or su username: su pi sudo In GUI If you are developing programs which use the IO pin from the GUI you do not have to use "sudo startx" to […]
PHP/Apache
Installing PHP/Apache See our page here, works with Raspberry Pi OS too Adding Your HTML, PHP etc Files Copy them into the “/var/www/html/” directory. You will need root permission to write to this directory, so if you are using the GUI file manager use “sudo su” to elevate yourself to the root user before starting the […]
Text Files – Editors
nano (Better than vi) sudo nano /etc/apache2/sites-enabled/000-default vi sudo vi /boot/cmdline.txt
Null
Use NULL, e.g.: void * tmpAddrPtr = NULL;
Network Interface Code Snippets
These are bits of code we've found for linux that don't necessarily relate exactly to raspbian on the RPi, but may be useful Network Config //Code sourced from: http://www.network-builders.com/programatically-change-ip-address-t58439.html //The RPi doesn't have a folder "/etc/sysconfig/" so this isn't usable as currently implemented #include <stdio.h> #include <errno.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> #include […]
Read Local Network Adaptors
Get IP Address and Sunet Mask Of Each Network Interface #include <stdio.h> #include <sys/types.h> #include <ifaddrs.h> #include <netinet/in.h> #include <string.h> #include <arpa/inet.h> #define MAX_NETWORK_ADAPTORS 3 #define MAX_ADAPTOR_NAME_LENGTH 20 BYTE found_network_adaptors_count; char NetworkAdaptorName[MAX_NETWORK_ADAPTORS][MAX_ADAPTOR_NAME_LENGTH]; char NetworkAdaptorIpAddress[MAX_NETWORK_ADAPTORS][INET_ADDRSTRLEN]; char NetworkAdaptorSubnetMask[MAX_NETWORK_ADAPTORS][INET_ADDRSTRLEN]; //*************************************************** //*************************************************** //********** READ NETWORK ADAPTOR SETTINGS ********** //*************************************************** //*************************************************** void network_read_network_adaptor_settings (void) { struct ifaddrs * ifAddrStruct = […]
File Extensions In Linux
Good Resources http://www.debianhelp.co.uk/fileext.htm
.C++ Strings General
Header Files In C++, strings are not a built-in data type, but rather a Standard Library facility. Memory Allocation For Strings Its handled automatically – you don’t have to specify a size when creating a string. The string class functions simply compute the size every time they need to allocate memory, at a runtime cost (by, for example, using […]