ok, here is a good example of how you can run a BBB-specific shell script with the DAEMON1 code examples. It reads back to you the current configurations for pins on the P8/9 headers. Its not just a cat of a config file but saves to a text file AND is entirely available in a C program.
You can also read the resulting text file in python btw.
IMPORTANT: requires the shell script to be in the same directory as the executable. Make "pinmux.sh" and put these lines of shell script in it:
[code]
cat /sys/kernel/debug/pinctrl/44e10800.pinmux/pingroups > ./pinmux.txt
sleep 1
exit
[/code]
IMPORTANT: remember to "chmod 777 pinmux.sh" or it won't run. ie. make is executable.
[code]
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <dirent.h>
main()
{
int ppid;
int status;
FILE *fptr;
char c;
remove("pinmux.txt");
printf("generating pin group data /sys/kernel/debug/pinctrl/44e10800.pinmux/pingroups...\n");
fflush(NULL);
if ((ppid=fork())==0)
{
printf("Child process\n");
execlp("bash","bash","./pinmux.sh","",NULL);
return; //terminates child process
}
//does this block? YES!
// printf("Parent process %d\n",ppid);
wait(&status);
fptr=fopen("pinmux.txt","r");
while(!feof(fptr))
{
fread(&c,1,1,fptr);
printf("%c",c);
}
fclose(fptr);
}
[/code]
Compile with "gcc pinmux.c -o pinmux -lm" and execute with "./pinmux"