.Working With Directories

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

Read More

.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 […]

Read More

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 […]

Read More

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 […]

Read More

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 More

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 = […]

Read More

.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 […]

Read More