Pacific Simplicity is the home to my tech blog of sorts, aiming to assist and provide information easily to other Linux users and Open Source hackers out there.  It contains articles on Linux, system admin hints, scripting, programming embedded systems, OpenWRT and of course Drupal . Check it out and don't forget to comment!

Posted: Fri, 09/23/2016 - 12:06

Here is part 2 of the previous explanation app.

Posted: Fri, 09/23/2016 - 06:47

Here is a simple libudev example that performs the following:

  • Enumerates static plugged in USB storage devices
  • Using epoll, polls for USB and block device changes

To compile:

gcc -Wall -g -o udev_example usbtest2.c -ludev<code>

<p>The code:</p>

Posted: Tue, 09/20/2016 - 07:22

Here is a simple function pointer example I wrote for one of my friends just learning to program in C - it should be easy to follow:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

typedef void (*ledFuncPtr) (int[], int);

void myFunctionTest(int pins[], int size)

        int i = 0;
        for (i = 0; i <= size; i++) {
                printf("val: %d\n", pins[i]);

Posted: Mon, 09/19/2016 - 11:22

Here is simple file chunker that writes only complete complete records read in from a file to another file. For example, there are JSON records delimited with a '\' character and because they are variable in size, the buffer size WILL not align and therefore needs us to read X bytes, then walk backwards until we find the last complete record.

This requires us to use fseek (fseek(fp,i-tmp_bytes_read,SEEK_CUR);) to re-adjust the filepointer such that the next read will begin at the correct point.

Posted: Tue, 09/13/2016 - 17:48

While scouting about looking for information about the FriendlyArm's NanoPC-T2 GPIO pins and using some of their source - I noticed that the documentation regarding how to setup an LED for example was missing from their forums etc... Here is a quick example: