ODROID-COMMON: Add function for input data to sysnode.
Signed-off-by: steve.jeong <jkhpro1003@gmail.com>
Change-Id: I7a1c6b82f8461b78aa5f9616531f9e2ae08c0fd3
diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c
index 0d02b8a..c631dac 100644
--- a/wiringPi/wiringPi.c
+++ b/wiringPi/wiringPi.c
@@ -27,6 +27,7 @@
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <sys/utsname.h>
+#include <sys/types.h>
#include <asm/ioctl.h>
/*----------------------------------------------------------------------------*/
@@ -266,6 +267,29 @@
/*----------------------------------------------------------------------------*/
/*
+ * input data to sys node.
+ */
+/*----------------------------------------------------------------------------*/
+int inputToSysNode (const char* sysPath, const char* node, char* data) {
+ char dest[(BLOCK_SIZE * 2)];
+ FILE *fd;
+
+ memset(dest, 0, sizeof(dest));
+
+ sprintf(dest, "%s/%s", sysPath, node);
+
+ if((fd = fopen(dest, "w")) == NULL) {
+ printf("Invalid sysnode path\n");
+ return -1;
+ }
+ fprintf(fd, "%s\n", data);
+ fclose(fd);
+
+ return 0;
+}
+
+/*----------------------------------------------------------------------------*/
+/*
* setKernelVersion:
* It sets current operating kernel version to the global struct variable.
*/
diff --git a/wiringPi/wiringPi.h b/wiringPi/wiringPi.h
index cb9fefb..bb8721c 100644
--- a/wiringPi/wiringPi.h
+++ b/wiringPi/wiringPi.h
@@ -342,6 +342,9 @@
extern void digitalWriteByte (int value) UNU;
extern void digitalWriteByte2 (int value) UNU;
+// sys node
+extern int inputToSysNode (const char* sysPath, const char* node, char* data);
+
#ifdef __cplusplus
}
#endif