I made a simple application to get GPIOs status (EVERY SECOND) and send them to a remote PC by socket over WiFi.
After one week SD card is currupted.
The function that get GPIO status is the following:
Code: Select all
public static int getGPIOstatus(int gpioNumber){
/*
Read value of GPIO 7:
cat /sys/class/gpio/gpio7/value
*/
BufferedReader br = null;
int ret=0;
try {
String sCurrentLine;
br = new BufferedReader(new FileReader("/sys/class/gpio/gpio"+gpioNumber+"/value"));
if ((sCurrentLine = br.readLine()) != null) {
//System.out.println("Current GPIO value is: "+sCurrentLine);
ret= Integer.parseInt(sCurrentLine);;
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null)br.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
return ret;
}