Merge pull request #9 from anoo1/master

Watchdog support
diff --git a/Makefile b/Makefile
index 2177c9d..1f2c7aa 100755
--- a/Makefile
+++ b/Makefile
@@ -1,19 +1,33 @@
 CXX ?= $(CROSS_COMPILE)g++
 
+TESTER = testit
+
 DAEMON = ipmid
 DAEMON_OBJ  = $(DAEMON).o
 LIB_APP_OBJ = apphandler.o     \
               sensorhandler.o  \
               storagehandler.o \
-              dcmihandler.o
+              dcmihandler.o    \
+              ipmisensor.o     \
+
+
+TESTER_OBJ = ipmisensor.o 	   \
+			 testit.o
 
 LIB_APP     = libapphandler.so
+INSTALLED_LIBS += $(LIB_APP)
+INSTALLED_HEADERS = ipmid-api.h
 
 INC_FLAG += $(shell pkg-config --cflags --libs libsystemd) -I. -O2 --std=gnu++11
 LIB_FLAG += $(shell pkg-config  --libs libsystemd) -rdynamic
-IPMID_PATH ?= -DHOST_IPMI_LIB_PATH=\"/usr/lib/host-ipmid/\" 
+IPMID_PATH ?= -DHOST_IPMI_LIB_PATH=\"/usr/lib/host-ipmid/\"
 
-all: $(DAEMON) $(LIB_APP) 
+DESTDIR ?= /
+SBINDIR ?= /usr/sbin
+INCLUDEDIR ?= /usr/include
+LIBDIR ?= /usr/lib
+
+all: $(DAEMON) $(LIB_APP) $(TESTER)
 
 %.o: %.C
 	$(CXX) -fpic -c $< $(CXXFLAGS) $(INC_FLAG) $(IPMID_PATH) -o $@
@@ -24,5 +38,17 @@
 $(DAEMON): $(DAEMON_OBJ)
 	$(CXX) $^ $(LDFLAGS) $(LIB_FLAG) -o $@ -ldl
 
+$(TESTER): $(TESTER_OBJ)
+	$(CXX) $^ $(LDFLAGS) $(LIB_FLAG) -o $@ -ldl
+
 clean:
-	rm -f $(DAEMON) *.o *.so
+	rm -f $(DAEMON) $(TESTER) *.o *.so
+
+install:
+		install -m 0755 -d $(DESTDIR)$(SBINDIR)
+		install -m 0755 ipmid $(DESTDIR)$(SBINDIR)
+		install -m 0755 -d $(DESTDIR)$(LIBDIR)/host-ipmid
+		install -m 0755 $(INSTALLED_LIBS) $(DESTDIR)$(LIBDIR)/host-ipmid
+		install -m 0755 -d $(DESTDIR)$(INCLUDEDIR)/host-ipmid
+		install -m 0644 $(INSTALLED_HEADERS) $(DESTDIR)$(INCLUDEDIR)/host-ipmid
+
diff --git a/ipmid.C b/ipmid.C
index d0dfba8..4f0831e 100644
--- a/ipmid.C
+++ b/ipmid.C
@@ -37,7 +37,7 @@
 void hexdump(void *mem, size_t len)
 {
         unsigned int i, j;
-        
+
         for(i = 0; i < len + ((len % HEXDUMP_COLS) ? (HEXDUMP_COLS - len % HEXDUMP_COLS) : 0); i++)
         {
                 /* print offset */
@@ -45,7 +45,7 @@
                 {
                         printf("0x%06x: ", i);
                 }
- 
+
                 /* print hex data */
                 if(i < len)
                 {
@@ -55,7 +55,7 @@
                 {
                         printf("   ");
                 }
-                
+
                 /* print ASCII dump */
                 if(i % HEXDUMP_COLS == (HEXDUMP_COLS - 1))
                 {
@@ -67,7 +67,7 @@
                                 }
                                 else if(isprint(((char*)mem)[j])) /* printable char */
                                 {
-                                        putchar(0xFF & ((char*)mem)[j]);        
+                                        putchar(0xFF & ((char*)mem)[j]);
                                 }
                                 else /* other char */
                                 {
@@ -150,11 +150,11 @@
     // Response message from the plugin goes into a byte post the base response
     rc = (handler_and_context.first) (netfn, cmd, request, respo,
                                       data_len, handler_and_context.second);
- 
+
     // Now copy the return code that we got from handler and pack it in first
     // byte.
     memcpy(response, &rc, IPMI_CC_LEN);
- 
+
     // Data length is now actual data + completion code.
     *data_len = *data_len + IPMI_CC_LEN;
 
@@ -191,7 +191,7 @@
         fprintf(stderr, "Failed add the netfn and others : %s\n", strerror(-r));
         return -1;
     }
-   
+
     r = sd_bus_message_append_array(m, 'y', buf, len);
     if (r < 0) {
         fprintf(stderr, "Failed to add the string of response bytes: %s\n", strerror(-r));
@@ -210,7 +210,7 @@
     r = sd_bus_message_read(reply, "x", &pty);
 #ifdef __IPMI_DEBUG__
     printf("RC from the ipmi dbus method :%d \n", pty);
-#endif    
+#endif
     if (r < 0) {
        fprintf(stderr, "Failed to get a rc from the method: %s\n", strerror(-r));
 
@@ -223,7 +223,7 @@
 
 #ifdef __IPMI_DEBUG__
     printf("%d : %s\n", __LINE__, __PRETTY_FUNCTION__ );
-#endif    
+#endif
     return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 
 }
@@ -258,11 +258,11 @@
     printf("Seq 0x%02x, NetFn 0x%02x, CMD: 0x%02x \n", sequence, netfn, cmd);
     hexdump((void*)request, sz);
 
-    // Allow the length field to be used for both input and output of the 
+    // Allow the length field to be used for both input and output of the
     // ipmi call
     resplen = sz;
 
-    // Now that we have parsed the entire byte array from the caller 
+    // Now that we have parsed the entire byte array from the caller
     // we can call the ipmi router to do the work...
     r = ipmi_netfn_router(netfn, cmd, (void *)request, (void *)response, &resplen);
     if(r != 0)
@@ -300,7 +300,7 @@
     if(strstr(entry->d_name, IPMI_PLUGIN_EXTN))
     {
         // It is possible that .so could be anywhere in the string but unlikely
-        // But being careful here. Get the base address of the string, move 
+        // But being careful here. Get the base address of the string, move
         // until end and come back 3 steps and that gets what we need.
         strcpy(dname_copy, (entry->d_name + strlen(entry->d_name)-strlen(IPMI_PLUGIN_EXTN)));
         if(strcmp(dname_copy, IPMI_PLUGIN_EXTN) == 0)
@@ -312,7 +312,7 @@
 }
 
 // This will do a dlopen of every .so in ipmi_lib_path and will dlopen everything so that they will
-// register a callback handler 
+// register a callback handler
 void ipmi_register_callback_handlers(const char* ipmi_lib_path)
 {
     // For walking the ipmi_lib_path
@@ -331,11 +331,11 @@
     {
         // 1: Open ipmi_lib_path. Its usually "/usr/lib/phosphor-host-ipmid"
         // 2: Scan the directory for the files that end with .so
-        // 3: For each one of them, just do a 'dlopen' so that they register 
+        // 3: For each one of them, just do a 'dlopen' so that they register
         //    the handlers for callback routines.
 
         std::string handler_fqdn = ipmi_lib_path;
-        
+
         // Append a "/" since we need to add the name of the .so. If there is
         // already a .so, adding one more is not any harm.
         handler_fqdn += "/";
@@ -350,8 +350,8 @@
             lib_handler = dlopen(handler_fqdn.c_str(), RTLD_NOW);
             if(lib_handler == NULL)
             {
-                fprintf(stderr,"ERROR opening:[%s]\n",handler_fqdn.c_str());
-                dlerror();
+                fprintf(stderr,"ERROR opening [%s]: %s\n",
+                        handler_fqdn.c_str(), dlerror());
             }
             // Wipe the memory allocated for this particular entry.
             free(handler_list[num_handlers]);
@@ -381,7 +381,7 @@
     for(auto& iter : g_ipmid_router_map)
     {
         ipmi_fn_cmd_t fn_and_cmd = iter.first;
-        printf("NETFN:[0x%X], cmd[0x%X]\n", fn_and_cmd.first, fn_and_cmd.second);  
+        printf("NETFN:[0x%X], cmd[0x%X]\n", fn_and_cmd.first, fn_and_cmd.second);
     }
 #endif
 
@@ -426,3 +426,168 @@
     return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 
 }
+
+
+#define MAX_DBUS_PATH 128
+struct dbus_interface_t {
+    uint8_t  sensornumber;
+    uint8_t  sensortype;
+
+    char  bus[MAX_DBUS_PATH];
+    char  path[MAX_DBUS_PATH];
+    char  interface[MAX_DBUS_PATH];
+};
+
+
+
+// Use a lookup table to find the interface name of a specific sensor
+// This will be used until an alternative is found.  this is the first
+// step for mapping IPMI
+int find_openbmc_path(const char *type, const uint8_t num, dbus_interface_t *interface) {
+
+    const char  *busname = "org.openbmc.managers.System";
+    const char  *objname = "/org/openbmc/managers/System";
+
+    char  *str1, *str2, *str3;
+    sd_bus_error error = SD_BUS_ERROR_NULL;
+    sd_bus_message *reply = NULL, *m=NULL;
+
+
+    int r;
+
+    r = sd_bus_message_new_method_call(bus,&m,busname,objname,busname,"getObjectFromByteId");
+    if (r < 0) {
+        fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
+    }
+
+    r = sd_bus_message_append(m, "sy", type, num);
+    if (r < 0) {
+        fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
+    }
+
+    // Call the IPMI responder on the bus so the message can be sent to the CEC
+    r = sd_bus_call(bus, m, 0, &error, &reply);
+    if (r < 0) {
+        fprintf(stderr, "Failed to call the method: %s", strerror(-r));
+        goto final;
+    }
+
+
+    r = sd_bus_message_read(reply, "(sss)", &str1, &str2, &str3);
+    if (r < 0) {
+        fprintf(stderr, "Failed to get a response: %s", strerror(-r));
+        goto final;
+    }
+
+    strncpy(interface->bus, str1, MAX_DBUS_PATH);
+    strncpy(interface->path, str2, MAX_DBUS_PATH);
+    strncpy(interface->interface, str3, MAX_DBUS_PATH);
+
+    interface->sensornumber = num;
+
+
+final:
+
+    sd_bus_error_free(&error);
+    sd_bus_message_unref(m);
+
+    return r;
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// Routines used by ipmi commands wanting to interact on the dbus
+//
+/////////////////////////////////////////////////////////////////////
+
+
+// Simple set routine because some methods are standard.
+int set_sensor_dbus_state(uint8_t number, const char *method, const char *value) {
+
+
+    dbus_interface_t a;
+    int r;
+    sd_bus_error error = SD_BUS_ERROR_NULL;
+    sd_bus_message *reply = NULL, *m=NULL;
+
+    printf("Attempting to set a dbus Sensor 0x%02x via %s with a value of %s\n",
+        number, method, value);
+
+    r = find_openbmc_path("SENSOR", number, &a);
+
+    printf("**********************\n");
+    printf("%s\n", a.bus);
+    printf("%s\n", a.path);
+    printf("%s\n", a.interface);
+
+
+    r = sd_bus_message_new_method_call(bus,&m,a.bus,a.path,a.interface,method);
+    if (r < 0) {
+        fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
+    }
+
+    r = sd_bus_message_append(m, "s", value);
+    if (r < 0) {
+        fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
+    }
+
+    // Call the IPMI responder on the bus so the message can be sent to the CEC
+    r = sd_bus_call(bus, m, 0, &error, &reply);
+    if (r < 0) {
+        fprintf(stderr, "Failed to call the method: %s", strerror(-r));
+    }
+
+
+
+    sd_bus_error_free(&error);
+    sd_bus_message_unref(m);
+
+    return 0;
+
+
+}
+
+int set_sensor_dbus_state_v(uint8_t number, const char *method, char *value) {
+
+
+    dbus_interface_t a;
+    int r;
+    sd_bus_error error = SD_BUS_ERROR_NULL;
+    sd_bus_message *reply = NULL, *m=NULL;
+
+    printf("Attempting to set a dbus Variant Sensor 0x%02x via %s with a value of %s\n",
+        number, method, value);
+
+    r = find_openbmc_path("SENSOR", number, &a);
+
+    printf("**********************\n");
+    printf("%s\n", a.bus);
+    printf("%s\n", a.path);
+    printf("%s\n", a.interface);
+
+
+    r = sd_bus_message_new_method_call(bus,&m,a.bus,a.path,a.interface,method);
+    if (r < 0) {
+        fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
+    }
+
+    r = sd_bus_message_append(m, "v", "s", value);
+    if (r < 0) {
+        fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
+    }
+
+
+    // Call the IPMI responder on the bus so the message can be sent to the CEC
+    r = sd_bus_call(bus, m, 0, &error, NULL);
+    if (r < 0) {
+        fprintf(stderr, "12 Failed to call the method: %s", strerror(-r));
+    }
+
+
+
+    sd_bus_error_free(&error);
+    sd_bus_message_unref(m);
+
+    return 0;
+}
diff --git a/ipmisensor.C b/ipmisensor.C
new file mode 100644
index 0000000..f60db18
--- /dev/null
+++ b/ipmisensor.C
@@ -0,0 +1,229 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+
+
+extern unsigned char findSensor(char);
+extern int set_sensor_dbus_state_v(uint8_t , const char *, char *);
+
+
+struct sensorRES_t {
+	uint8_t sensor_number;
+	uint8_t operation;
+	uint8_t sensor_reading;
+	uint8_t assert_state7_0;
+	uint8_t assert_state14_8;	
+	uint8_t deassert_state7_0;
+	uint8_t deassert_state14_8;	
+	uint8_t event_data1;
+	uint8_t event_data2;
+	uint8_t event_data3;	
+} __attribute__ ((packed));
+
+#define ISBITSET(x,y) (((x)>>(y))&0x01)
+#define ASSERTINDEX 0
+#define DEASSERTINDEX 1
+
+// Sensor Type,  Offset, function handler, Dbus Method, Assert value, Deassert value
+struct lookup_t {
+	uint8_t sensor_type;
+	uint8_t offset;
+	int (*func)(const sensorRES_t *, const lookup_t *, const char *);
+	char    method[16];
+	char    assertion[16];
+	char    deassertion[16];
+};
+
+
+extern int updateDbusInterface(uint8_t , const char *, const char *) ;
+extern int set_sensor_dbus_state(uint8_t ,const char *, const char *);
+
+
+int set_sensor_dbus_state_simple(const sensorRES_t *pRec, const lookup_t *pTable, const char *value) {
+
+	return set_sensor_dbus_state(pRec->sensor_number, pTable->method, value);
+}
+
+struct event_data_t {
+	uint8_t data;
+	char    text[32];
+};
+
+event_data_t g_fwprogress02h[] = {
+	{0x00, "Unspecified"},
+	{0x01, "Memory Init"},
+	{0x02, "HD Init"},
+	{0x03, "Secondary Proc Init"},
+	{0x04, "User Authentication"},
+	{0x05, "User init system setup"},
+	{0x06, "USB configuration"},
+	{0x07, "PCI configuration"},
+	{0x08, "Option ROM Init"},
+	{0x09, "Video Init"},
+	{0x0A, "Cache Init"},
+	{0x0B, "SM Bus init"},
+	{0x0C, "Keyboard Init"},
+	{0x0D, "Embedded ctrl init"},
+	{0x0E, "Docking station attachment"},
+	{0x0F, "Enable docking station"},
+	{0x10, "Docking station ejection"},
+	{0x11, "Disabling docking station"},
+	{0x12, "Calling OS Wakeup"},
+	{0x13, "Starting OS"},
+	{0x14, "Baseboard Init"},
+	{0x15, ""},
+	{0x16, "Floppy Init"},
+	{0x17, "Keyboard Test"},
+	{0x18, "Pointing Device Test"},
+	{0x19, "Primary Proc Init"},
+	{0xFF, "Unknown"}
+};
+
+
+char *getfw02string(uint8_t b) {
+
+	int i = 0;
+	event_data_t *p = g_fwprogress02h;
+
+	do {
+
+		if ((p+i)->data == b)
+			break;
+		i++;
+	} while ((p+i)->data != 0xFF);
+
+	return (p+i)->text;
+}
+//  The fw progress sensor contains some additional information that needs to be processed
+//  prior to calling the dbus code.  
+int set_sensor_dbus_state_fwprogress(const sensorRES_t *pRec, const lookup_t *pTable, const char *value) {
+
+	char valuestring[32];
+	char* pStr = valuestring;
+
+	switch (pTable->offset) {
+
+		case 0x00 : sprintf(valuestring, "POST Error, 0x%02x", pRec->event_data2);
+					break;
+		case 0x01 : sprintf(valuestring, "FW Hang, 0x%02x", pRec->event_data2);
+					break;
+		case 0x02 : sprintf(valuestring, "FW Progress, %s", getfw02string(pRec->event_data2));
+	}
+
+	return set_sensor_dbus_state_v(pRec->sensor_number, pTable->method, pStr);
+}
+
+// Handling this special OEM sensor by coping what is in byte 4.  I also think that is odd
+// considering byte 3 is for sensor reading.  This seems like a misuse of the IPMI spec
+int set_sensor_dbus_state_osboot(const sensorRES_t *pRec, const lookup_t *pTable, const char *value) {
+	char valuestring[32];
+	char* pStr = valuestring;
+
+	sprintf(valuestring, "%d", pRec->assert_state7_0);
+
+	return set_sensor_dbus_state_v(pRec->sensor_number, pTable->method, pStr);
+}
+
+
+//  This table lists only senors we care about telling dbus about.
+//  Offset definition cab be found in section 42.2 of the IPMI 2.0 
+//  spec.  Add more if/when there are more items of interest.
+lookup_t g_ipmidbuslookup[] = {
+
+	{0x07, 0x07, set_sensor_dbus_state_simple, "setPresent", "True", "False"},
+	{0x07, 0x08, set_sensor_dbus_state_simple, "setFault",   "True", "False"},
+	{0x0C, 0x06, set_sensor_dbus_state_simple, "setPresent", "True", "False"},
+	{0x0C, 0x04, set_sensor_dbus_state_simple, "setFault",   "True", "False"},
+	{0x0F, 0x02, set_sensor_dbus_state_fwprogress, "setValue", "True", "False"},
+	{0x0F, 0x01, set_sensor_dbus_state_fwprogress, "setValue", "True", "False"},
+	{0x0F, 0x00, set_sensor_dbus_state_fwprogress, "setValue", "True", "False"},
+	{0xC7, 0x01, set_sensor_dbus_state_simple, "setFault", "True", "False"},
+	{0x07, 0x00, set_sensor_dbus_state_simple, "setPresent", "False", "False"}, // OCC Inactive 0
+	{0x07, 0x01, set_sensor_dbus_state_simple, "setPresent", "True", "True"},   // OCC Active 1 
+	{0xc3, 0x00, set_sensor_dbus_state_osboot, "setValue", "" ,""},
+
+	{0xFF, 0xFF, NULL, "", "", ""}
+};
+
+
+
+void reportSensorEventAssert(sensorRES_t *pRec, int index) {
+	lookup_t *pTable = &g_ipmidbuslookup[index];
+	(*pTable->func)(pRec, pTable, pTable->assertion);
+}
+void reportSensorEventDeassert(sensorRES_t *pRec, int index) {
+	lookup_t *pTable = &g_ipmidbuslookup[index];
+	(*pTable->func)(pRec, pTable, pTable->deassertion);
+}
+
+
+int findindex(const uint8_t sensor_type, int offset, int *index) {
+	
+	int i=0, rc=0;
+	lookup_t *pTable = g_ipmidbuslookup;
+
+	do {
+		if ( ((pTable+i)->sensor_type == sensor_type) && 
+			 ((pTable+i)->offset  == offset) ) {
+			rc = 1;
+			*index = i;
+			break;
+		}
+		i++;
+	} while ((pTable+i)->sensor_type  != 0xFF);
+
+	return rc;
+}
+
+void debug_print_ok_to_dont_care(uint8_t stype, int offset)
+{
+	printf("Sensor should not be reported:  Type 0x%02x, Offset 0x%02x\n",
+		stype, offset);
+}
+
+bool shouldReport(uint8_t sensorType, int offset, int *index) {
+
+	bool rc = false;
+
+	if (findindex(sensorType, offset, index)) { rc = true;	}
+
+	if (rc==false) { debug_print_ok_to_dont_care(sensorType, offset); }
+
+	return rc;
+}
+
+
+int updateSensorRecordFromSSRAESC(const void *record) {
+
+	sensorRES_t *pRec = (sensorRES_t *) record;
+	unsigned char stype;
+	int index, i=0;
+	stype = findSensor(pRec->sensor_number);
+
+	// Scroll through each bit position .  Determine 
+	// if any bit is either asserted or Deasserted.
+	for(i=0;i<8;i++) {
+		if ((ISBITSET(pRec->assert_state7_0,i))  &&
+			(shouldReport(stype, i, &index)))
+		{
+			reportSensorEventAssert(pRec, index);
+		}
+		if ((ISBITSET(pRec->assert_state14_8,i+8))  &&
+			(shouldReport(stype, i+8, &index)))
+		{
+			reportSensorEventAssert(pRec, index);
+		}
+		if ((ISBITSET(pRec->deassert_state7_0,i))  &&
+			(shouldReport(stype, i, &index)))
+		{
+			reportSensorEventDeassert(pRec, index);
+		}
+		if ((ISBITSET(pRec->deassert_state14_8,i+8))  &&
+			(shouldReport(stype, i+8, &index)))
+		{
+			reportSensorEventDeassert(pRec, index);
+		}
+	}
+
+	return 0;
+}
diff --git a/sensorhandler.C b/sensorhandler.C
index 9f0c975..0b16d10 100644
--- a/sensorhandler.C
+++ b/sensorhandler.C
@@ -4,6 +4,7 @@
 #include <string.h>
 #include <stdint.h>
 
+extern int updateSensorRecordFromSSRAESC(const void *);
 
 void register_netfn_sen_functions()   __attribute__((constructor));
 
@@ -166,20 +167,22 @@
     ipmi_ret_t rc = IPMI_CC_OK;
     unsigned short rlen;
 
-    rlen = (unsigned short) *data_len - 1;
+    rlen = (unsigned short) *data_len;
 
     sprintf(string, "%s%02x", "/tmp/sen", reqptr->sennum);
 
     printf("IPMI SET_SENSOR [%s]\n",string);
 
     if ((fp = fopen(string, "wb")) != NULL) {
-        fwrite(reqptr+1,rlen,1,fp);
+        fwrite(reqptr,rlen,1,fp);
         fclose(fp);
     } else {
         fprintf(stderr, "Error trying to write to sensor file %s\n",string);
         ipmi_ret_t rc = IPMI_CC_INVALID;        
     }
 
+    updateSensorRecordFromSSRAESC(reqptr);
+
     *data_len=0;
 
 
@@ -209,5 +212,6 @@
 
     printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_SENSOR, IPMI_CMD_SET_SENSOR);
     ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_SET_SENSOR, NULL, ipmi_sen_set_sensor);
+
     return;
 }
diff --git a/testit.C b/testit.C
new file mode 100644
index 0000000..021d534
--- /dev/null
+++ b/testit.C
@@ -0,0 +1,166 @@
+
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+
+
+unsigned char g_sensortype [][2] = {
+    {0xc7, 58},
+{0x01, 113},
+{0xc7, 56},
+{0x01, 114},
+{0xc6, 54},
+{0x07, 40},
+{0xC1, 121},
+{0xC2, 137},
+{0x07, 36},
+{0x07, 43},
+{0xC1, 122},
+{0xC1, 119},
+{0x01, 12},
+{0x01, 111},
+{0x01, 116},
+{0xC1, 127},
+{0xC2, 134},
+{0xC2, 130},
+{0xc, 33},
+{0xC1, 125},
+{0x01, 115},
+{0x22, 4},
+{0xC2, 138},
+{0x01, 108},
+{0x01, 102},
+{0xc, 46},
+{0x7, 11},
+{0xC1, 120},
+{0x07, 39},
+{0x07, 42},
+{0x5, 21},
+{0xC2, 131},
+{0xc1, 48},
+{0x12, 53},
+{0xC1, 124},
+{0x01, 117},
+{0xC1, 126},
+{0xf, 5},
+{0x23, 0},
+{0xC2, 139},
+{0x07, 34},
+{0x09, 146},
+{0x02, 178},
+{0xC2, 140},
+{0xC1, 118},
+{0xC2, 133},
+{0x07, 38},
+{0xC2, 143},
+{0x01, 101},
+{0xc3, 9},
+{0x7, 10},
+{0xc2, 51},
+{0x01, 109},
+{0xc, 32},
+{0x7, 8},
+{0xC1, 129},
+{0x01, 112},
+{0x01, 107},
+{0x07, 37},
+{0x07, 44},
+{0x1f, 50},
+{0xC2, 144},
+{0xc7, 52},
+{0xC2, 141},
+{0x01, 106},
+{0x01, 110},
+{0x01, 103},
+{0x9, 28},
+{0x07, 35},
+{0xc7, 55},
+{0x03, 179},
+{0x07, 41},
+{0xc, 30},
+{0x01, 100},
+{0xC1, 128},
+{0xC2, 135},
+{0x01, 105},
+{0x7, 47},
+{0xC2, 145},
+{0xc7, 57},
+{0x01, 104},
+{0x07, 45},
+{0xC2, 132},
+{0xc4, 49},
+{0xC1, 123},
+{0xC2, 142},
+{0x01, 13},
+{0xC2, 136},
+{0xc, 31},
+{0xff,0xff}
+};
+
+unsigned char findSensor(char sensor_number) {
+
+    int i=0;
+
+    // TODO : This function should actually call
+    // a dbus object and have it return the data
+    // it is not ready yet so use a Palmetto 
+    // based lookup table for now.  The g_sensortype
+    // can be removed once the dbus method exists
+    while (g_sensortype[i][0] != 0xff) {
+        if (g_sensortype[i][1] == sensor_number) {
+            break;
+        } else {
+            i++;
+        }
+
+    }
+
+    return g_sensortype[i][0];
+
+}
+
+
+int set_sensor_dbus_state_v(uint8_t number, const char *method, char *value) {
+    printf("Attempting to log Variant Sensor 0x%02x via %s with a value of %s\n", 
+        number, method, value);
+
+}
+
+int set_sensor_dbus_state(uint8_t number, const char *method, const char *value) {
+
+	printf("Attempting to log Sensor 0x%02x via %s with a value of %s\n", 
+		number, method, value);
+
+	return 0;
+}
+
+
+extern int updateSensorRecordFromSSRAESC(const void *record);
+
+
+
+uint8_t testrec_boot1[] = {0x05, 0xa9, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00};
+uint8_t testrec_boot2[] = {0x05, 0xa9, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00};
+uint8_t testrec_boot3[] = {0x05, 0xa9, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00};
+uint8_t testrec_boot4[] = {0x05, 0xa9, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00};                       
+
+
+
+// DIMM Present
+uint8_t testrec_sensor1[] {0x1F, 0xa9, 0x00, 0x40, 0x00, 0x10, 0x00, 0x00};
+
+// DIMM Not present
+uint8_t testrec_sensor2[] {0x1F, 0xa9, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00};
+
+
+uint8_t testrec_bootprogress[]  = {05, 0xa9, 0x00, 0x04, 0x00, 0x00, 0x14, 0x00 };
+
+int main() {
+
+	updateSensorRecordFromSSRAESC(testrec_bootprogress);
+	updateSensorRecordFromSSRAESC(testrec_sensor1);
+	updateSensorRecordFromSSRAESC(testrec_sensor2);
+
+
+	return 0;
+}
\ No newline at end of file