summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--i2c.c5
-rw-r--r--i2c.h6
-rw-r--r--response.c7
3 files changed, 13 insertions, 5 deletions
diff --git a/i2c.c b/i2c.c
index 02e5812..fc9d48a 100644
--- a/i2c.c
+++ b/i2c.c
@@ -4,12 +4,13 @@
#include <sys/ioctl.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
+#include <glib.h>
#define I2C_BUS "/dev/i2c-3"
-int I2C_Write(int address, int value) {
+int I2C_Write(gulong address, guchar value) {
struct i2c_smbus_ioctl_data argswrite;
@@ -29,7 +30,7 @@ int I2C_Write(int address, int value) {
}
-int I2C_Read(int address) {
+guchar I2C_Read(gulong address) {
union i2c_smbus_data data;
struct i2c_smbus_ioctl_data argsread;
diff --git a/i2c.h b/i2c.h
index 5382c4e..6c0e5b9 100644
--- a/i2c.h
+++ b/i2c.h
@@ -1,2 +1,4 @@
-int I2C_Write(int address, int value);
-int I2C_Read(int address);
+#include <glib.h>
+
+int I2C_Write(gulong address, guchar value);
+guchar I2C_Read(gulong address);
diff --git a/response.c b/response.c
index efb96b7..e80222c 100644
--- a/response.c
+++ b/response.c
@@ -1,7 +1,9 @@
#include "response.h"
#include "socket-common.h"
+#include "i2c.h"
#include <string.h>
#include <stdlib.h>
+#include <glib.h>
//RESPONSE related functions from the server
@@ -104,9 +106,12 @@ void responseCb(gpointer instance, GObject *arg1, gpointer user_data)
// remove leading and trailing whitespace
g_strstrip (str);
+ I2C_Write (0x3b, 0xff);
+ guchar status = I2C_Read (0x3b);
+
// dummy response function
gchar* upper = g_ascii_strup(str, len);
- gchar *out_string = g_strdup_printf("%s\n%s\n%s\n",upper,upper,upper);
+ gchar *out_string = g_strdup_printf("%s\n%s\n%s\n%d\n",upper,upper,upper,status);
gssize out_len = strlen (out_string);
//send response back to client