Merge pull request #55 from shgoupf/master
Add get/set ipmid command support with correct DBUS property handling.
diff --git a/Makefile b/Makefile
index 57ad6fe..472bfaa 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@
TESTADDSEL = testaddsel
DAEMON = ipmid
-DAEMON_OBJ = ipmid.o host-services.o
+DAEMON_OBJ = ipmid.o
LIB_APP_OBJ = apphandler.o \
sensorhandler.o \
@@ -16,6 +16,7 @@
storageaddsel.o \
transporthandler.o \
+LIB_HOST_SRV_OBJ = host-services.o
TESTADDSEL_OBJ = $(TESTADDSEL).o \
storageaddsel.o
@@ -24,7 +25,9 @@
testit.o
LIB_APP = libapphandler.so
-INSTALLED_LIBS += $(LIB_APP)
+LIB_HOST_SRV = libhostservice.so
+
+INSTALLED_LIBS += $(LIB_APP) $(LIB_HOST_SRV)
INSTALLED_HEADERS = ipmid-api.h
CXXFLAGS += -Wall -Wno-unused-result
@@ -39,7 +42,7 @@
INCLUDEDIR ?= /usr/include
LIBDIR ?= /usr/lib
-all: $(DAEMON) $(LIB_APP) $(TESTER)
+all: $(DAEMON) $(LIB_APP) $(LIB_HOST_SRV) $(TESTER)
%.o: %.C
$(CXX) -std=c++14 -fpic -c $< $(CXXFLAGS) $(INC_FLAG) $(IPMID_PATH) -o $@
@@ -47,6 +50,9 @@
$(LIB_APP): $(LIB_APP_OBJ)
$(CXX) $^ -shared $(LDFLAGS) $(LIB_FLAG) -o $@
+$(LIB_HOST_SRV): $(LIB_HOST_SRV_OBJ)
+ $(CXX) $^ -shared $(LDFLAGS) $(LIB_FLAG) -o $@
+
$(DAEMON): $(DAEMON_OBJ)
$(CXX) $^ $(LDFLAGS) $(LIB_FLAG) -o $@ -ldl
diff --git a/host-services.c b/host-services.c
index ab9cfcc..23aa55e 100644
--- a/host-services.c
+++ b/host-services.c
@@ -5,6 +5,8 @@
#include "ipmid-api.h"
+void register_host_services() __attribute__((constructor));
+
// OpenBMC Host IPMI dbus framework
const char *bus_name = "org.openbmc.HostIpmi";
const char *object_name = "/org/openbmc/HostIpmi/1";
@@ -13,69 +15,69 @@
//-------------------------------------------------------------------
// Gets called by PowerOff handler when a Soft Power off is requested
//-------------------------------------------------------------------
-static int soft_power_off(sd_bus_message *m, void *userdata, sd_bus_error *ret_error)
+static int soft_power_off(sd_bus_message *m, void *userdata, sd_bus_error *ret_error)
{
- int64_t bt_resp = -1;
- int rc = 0;
+ int64_t bt_resp = -1;
+ int rc = 0;
- // Steps to be taken when we get this.
- // 1: Send a SMS_ATN to the Host
- // 2: Host receives it and sends a GetMsgFlags IPMI command
- // 3: IPMID app handler will respond to that with a MSgFlag with bit:0x2
- // set indicating we have a message for Host
- // 4: Host sends a GetMsgBuffer command and app handler will respond to
- // that with a OEM-SEL with certain fields packed indicating to the
- // host that it do a shutdown of the partitions.
- // 5: Host does the partition shutdown and calls Chassis Power off command
- // 6: App handler handles the command by making a call to ChassisManager
- // Dbus
-
- // Now the job is to send the SMS_ATTN.
-
+ // Steps to be taken when we get this.
+ // 1: Send a SMS_ATN to the Host
+ // 2: Host receives it and sends a GetMsgFlags IPMI command
+ // 3: IPMID app handler will respond to that with a MSgFlag with bit:0x2
+ // set indicating we have a message for Host
+ // 4: Host sends a GetMsgBuffer command and app handler will respond to
+ // that with a OEM-SEL with certain fields packed indicating to the
+ // host that it do a shutdown of the partitions.
+ // 5: Host does the partition shutdown and calls Chassis Power off command
+ // 6: App handler handles the command by making a call to ChassisManager
+ // Dbus
+
+ // Now the job is to send the SMS_ATTN.
+
// Req message contains the specifics about which method etc that we want to
// access on which bus, object
sd_bus_message *response = NULL;
- // Error return mechanism
+ // Error return mechanism
sd_bus_error bus_error = SD_BUS_ERROR_NULL;
- // Gets a hook onto either a SYSTEM or SESSION bus
- sd_bus *bus = ipmid_get_sd_bus_connection();
+ // Gets a hook onto either a SYSTEM or SESSION bus
+ sd_bus *bus = ipmid_get_sd_bus_connection();
- rc = sd_bus_call_method(bus, // On the System Bus
- bus_name, // Service to contact
- object_name, // Object path
- intf_name, // Interface name
- "setAttention", // Method to be called
- &bus_error, // object to return error
- &response, // Response buffer if any
- NULL); // No input arguments
- if(rc < 0)
- {
- fprintf(stderr,"ERROR initiating Power Off:[%s]\n",bus_error.message);
- goto finish;
- }
+ rc = sd_bus_call_method(bus, // In the System Bus
+ bus_name, // Service to contact
+ object_name, // Object path
+ intf_name, // Interface name
+ "setAttention", // Method to be called
+ &bus_error, // object to return error
+ &response, // Response buffer if any
+ NULL); // No input arguments
+ if(rc < 0)
+ {
+ fprintf(stderr,"ERROR initiating Power Off:[%s]\n",bus_error.message);
+ goto finish;
+ }
- // See if we were able to successfully raise SMS_ATN
+ // See if we were able to successfully raise SMS_ATN
rc = sd_bus_message_read(response, "x", &bt_resp);
- if (rc < 0)
- {
- fprintf(stderr, "Failed to get a rc from BT for SMS_ATN: %s\n", strerror(-rc));
- goto finish;
+ if (rc < 0)
+ {
+ fprintf(stderr, "Failed to get a rc from BT for SMS_ATN: %s\n", strerror(-rc));
+ goto finish;
}
finish:
sd_bus_error_free(&bus_error);
sd_bus_message_unref(response);
- if(rc < 0)
- {
- return sd_bus_reply_method_return(m, "x", rc);
- }
- else
- {
- return sd_bus_reply_method_return(m, "x", bt_resp);
- }
+ if(rc < 0)
+ {
+ return sd_bus_reply_method_return(m, "x", rc);
+ }
+ else
+ {
+ return sd_bus_reply_method_return(m, "x", bt_resp);
+ }
}
//-------------------------------------------
@@ -83,10 +85,10 @@
//-------------------------------------------
static const sd_bus_vtable host_services_vtable[] =
{
- SD_BUS_VTABLE_START(0),
- // Takes No("") arguments -but- returns a value of type 64 bit integer("x")
- SD_BUS_METHOD("SoftPowerOff", "", "x", &soft_power_off, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_VTABLE_END,
+ SD_BUS_VTABLE_START(0),
+ // Takes No("") arguments -but- returns a value of type 64 bit integer("x")
+ SD_BUS_METHOD("SoftPowerOff", "", "x", &soft_power_off, SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_VTABLE_END,
};
//------------------------------------------------------
@@ -94,28 +96,43 @@
// -----------------------------------------------------
int start_host_service(sd_bus *bus, sd_bus_slot *slot)
{
- int rc = 0;
+ int rc = 0;
- /* Install the object */
- rc = sd_bus_add_object_vtable(bus,
- &slot,
- "/org/openbmc/HostServices", /* object path */
- "org.openbmc.HostServices", /* interface name */
- host_services_vtable,
- NULL);
- if (rc < 0)
- {
- fprintf(stderr, "Failed to issue method call: %s\n", strerror(-rc));
- }
- else
- {
- /* Take one in OpenBmc */
- rc = sd_bus_request_name(bus, "org.openbmc.HostServices", 0);
- if (rc < 0)
- {
- fprintf(stderr, "Failed to acquire service name: %s\n", strerror(-rc));
- }
- }
+ /* Install the object */
+ rc = sd_bus_add_object_vtable(bus,
+ &slot,
+ "/org/openbmc/HostServices", /* object path */
+ "org.openbmc.HostServices", /* interface name */
+ host_services_vtable,
+ NULL);
+ if (rc < 0)
+ {
+ fprintf(stderr, "Failed to issue method call: %s\n", strerror(-rc));
+ }
+ else
+ {
+ /* Take one in OpenBmc */
+ rc = sd_bus_request_name(bus, "org.openbmc.HostServices", 0);
+ if (rc < 0)
+ {
+ fprintf(stderr, "Failed to acquire service name: %s\n", strerror(-rc));
+ }
+ }
- return rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+ return rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+}
+
+//------------------------------------------------------
+// Callback register function
+// -----------------------------------------------------
+void register_host_services()
+{
+ // Gets a hook onto SYSTEM bus used by host-ipmid
+ sd_bus *bus = ipmid_get_sd_bus_connection();
+
+ // Gets a hook onto SYSTEM bus slot used by host-ipmid
+ sd_bus_slot *ipmid_slot = ipmid_get_sd_bus_slot();
+
+ //start_host_service(bus, ipmid_slot);
+ start_host_service(bus, ipmid_slot);
}
diff --git a/ipmid-api.h b/ipmid-api.h
index 4f4b9de..4f00798 100644
--- a/ipmid-api.h
+++ b/ipmid-api.h
@@ -97,6 +97,7 @@
};
sd_bus *ipmid_get_sd_bus_connection(void);
+sd_bus_slot *ipmid_get_sd_bus_slot(void);
#ifdef __cplusplus
}
diff --git a/ipmid.C b/ipmid.C
index 76e612d..0f4139c 100644
--- a/ipmid.C
+++ b/ipmid.C
@@ -13,8 +13,8 @@
#include <errno.h>
#include "sensorhandler.h"
-
sd_bus *bus = NULL;
+sd_bus_slot *ipmid_slot = NULL;
FILE *ipmiio, *ipmidbus, *ipmicmddetails;
@@ -214,6 +214,7 @@
r = sd_bus_call(bus, m, 0, &error, &reply);
if (r < 0) {
fprintf(stderr, "Failed to call the method: %s\n", strerror(-r));
+ fprintf(stderr, "Dest: %s, Path: %s\n", dest, path);
goto final;
}
@@ -371,9 +372,12 @@
return bus;
}
+sd_bus_slot *ipmid_get_sd_bus_slot(void) {
+ return ipmid_slot;
+}
+
int main(int argc, char *argv[])
{
- sd_bus_slot *slot = NULL;
int r;
unsigned long tvalue;
int c;
@@ -416,11 +420,8 @@
// Register all the handlers that provider implementation to IPMI commands.
ipmi_register_callback_handlers(HOST_IPMI_LIB_PATH);
- // Start the Host Services Dbus Objects
- start_host_service(bus, slot);
-
// Watch for BT messages
- r = sd_bus_add_match(bus, &slot, FILTER, handle_ipmi_command, NULL);
+ r = sd_bus_add_match(bus, &ipmid_slot, FILTER, handle_ipmi_command, NULL);
if (r < 0) {
fprintf(stderr, "Failed: sd_bus_add_match: %s : %s\n", strerror(-r), FILTER);
goto finish;
@@ -446,7 +447,7 @@
}
finish:
- sd_bus_slot_unref(slot);
+ sd_bus_slot_unref(ipmid_slot);
sd_bus_unref(bus);
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
@@ -560,44 +561,7 @@
// 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;
-
- fprintf(ipmidbus, "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);
-
- 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));
- }
-
- 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) {
+int set_sensor_dbus_state_s(uint8_t number, const char *method, const char *value) {
dbus_interface_t a;
@@ -623,7 +587,7 @@
r = sd_bus_call(bus, m, 0, &error, NULL);
if (r < 0) {
- fprintf(stderr, "12 Failed to call the method: %s", strerror(-r));
+ fprintf(stderr, "Failed to call the method: %s", strerror(-r));
}
@@ -632,3 +596,38 @@
return 0;
}
+int set_sensor_dbus_state_y(uint8_t number, const char *method, const uint8_t value) {
+
+
+ dbus_interface_t a;
+ int r;
+ sd_bus_error error = SD_BUS_ERROR_NULL;
+ sd_bus_message *m=NULL;
+
+ fprintf(ipmidbus, "Attempting to set a dbus Variant Sensor 0x%02x via %s with a value of 0x%02x\n",
+ number, method, value);
+
+ r = find_openbmc_path("SENSOR", number, &a);
+
+ 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", "y", value);
+ if (r < 0) {
+ fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
+ }
+
+
+ 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;
+}
\ No newline at end of file
diff --git a/ipmid.H b/ipmid.H
index 3de2c8c..679392d 100644
--- a/ipmid.H
+++ b/ipmid.H
@@ -16,8 +16,10 @@
// The BT FIFO in the AST2400 can only handle 64 bytes.
// Can only allow 63 because the BT interface still
// needs 1 byte for the length field.
-#define MAX_IPMI_BUFFER 63
+#define MAX_IPMI_BUFFER 64
extern FILE *ipmiio, *ipmidbus, *ipmicmddetails;
-#endif
+int set_sensor_dbus_state_s(uint8_t , const char *, const char *);
+int set_sensor_dbus_state_y(uint8_t , const char *, const uint8_t);
+#endif
\ No newline at end of file
diff --git a/ipmisensor.C b/ipmisensor.C
index 1f60f64..b6927ac 100644
--- a/ipmisensor.C
+++ b/ipmisensor.C
@@ -2,10 +2,10 @@
#include <string.h>
#include <stdint.h>
#include <malloc.h>
-
+#include <ipmid.H>
+#include "sensorhandler.h"
extern uint8_t find_sensor(uint8_t);
-extern int set_sensor_dbus_state_v(uint8_t , const char *, char *);
struct sensorRES_t {
@@ -30,19 +30,20 @@
uint8_t sensor_type;
uint8_t offset;
int (*func)(const sensorRES_t *, const lookup_t *, const char *);
- char method[16];
+ char member[16];
char assertion[64];
char deassertion[64];
};
-
-extern int updateDbusInterface(uint8_t , const char *, const char *) ;
-extern int set_sensor_dbus_state(uint8_t ,const char *, const char *);
+extern int updateDbusInterface(uint8_t , const char *, const char *);
+extern int find_openbmc_path(const char *, const uint8_t , dbus_interface_t *) ;
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);
+ return set_sensor_dbus_state_s(pRec->sensor_number,
+ pTable->member,
+ value);
}
struct event_data_t {
@@ -133,18 +134,17 @@
break;
}
- return set_sensor_dbus_state_v(pRec->sensor_number, pTable->method, p);
+ return set_sensor_dbus_state_s(pRec->sensor_number,
+ pTable->member,
+ p);
}
// 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_osbootcount(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);
+ return set_sensor_dbus_state_y(pRec->sensor_number,
+ "setValue",
+ pRec->assert_state7_0);
}
int set_sensor_dbus_state_system_event(const sensorRES_t *pRec, const lookup_t *pTable, const char *value) {
@@ -167,7 +167,9 @@
break;
}
- return set_sensor_dbus_state_v(pRec->sensor_number, pTable->method, p);
+ return set_sensor_dbus_state_s(pRec->sensor_number,
+ pTable->member,
+ p);
}
diff --git a/sensorhandler.C b/sensorhandler.C
index c96b7a7..d171bf5 100644
--- a/sensorhandler.C
+++ b/sensorhandler.C
@@ -3,6 +3,7 @@
#include <stdio.h>
#include <string.h>
#include <stdint.h>
+#include <systemd/sd-bus.h>
extern int updateSensorRecordFromSSRAESC(const void *);
extern int find_interface_property_fru_type(dbus_interface_t *interface, const char *property_name, char *property_value) ;
@@ -32,6 +33,7 @@
{0x12, 0x6F, "SYSTEM_EVENT"},
{0xC7, 0x03, "SYSTEM"},
{0xC7, 0x03, "MAIN_PLANAR"},
+ {0xC2, 0x6F, "PowerCap"},
{0xFF, 0x00, ""},
};
@@ -40,6 +42,11 @@
uint8_t sennum;
} __attribute__ ((packed)) ;
+struct sensorreadingresp_t {
+ uint8_t value;
+ uint8_t operation;
+ uint8_t indication[2];
+} __attribute__ ((packed)) ;
uint8_t dbus_to_sensor_type(char *p) {
@@ -104,6 +111,10 @@
return r;
}
+
+
+
+
ipmi_ret_t ipmi_sen_get_sensor_type(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
ipmi_request_t request, ipmi_response_t response,
ipmi_data_len_t data_len, ipmi_context_t context)
@@ -149,6 +160,72 @@
return rc;
}
+
+ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
+ ipmi_request_t request, ipmi_response_t response,
+ ipmi_data_len_t data_len, ipmi_context_t context)
+{
+ sensor_data_t *reqptr = (sensor_data_t*)request;
+ ipmi_ret_t rc = IPMI_CC_SENSOR_INVALID;
+ uint8_t type;
+ sensorreadingresp_t *resp = (sensorreadingresp_t*) response;
+ int r;
+ dbus_interface_t a;
+ sd_bus *bus = ipmid_get_sd_bus_connection();
+ sd_bus_message *reply = NULL;
+ uint8_t reading;
+
+
+ printf("IPMI GET_SENSOR_READING [0x%02x]\n",reqptr->sennum);
+
+ r = find_openbmc_path("SENSOR", reqptr->sennum, &a);
+
+ type = find_sensor(reqptr->sennum);
+
+ fprintf(stderr, "Bus: %s, Path: %s, Interface: %s\n", a.bus, a.path, a.interface);
+
+ *data_len=0;
+
+ switch(type) {
+ case 0xC3:
+ case 0xC2:
+ r = sd_bus_get_property(bus,a.bus, a.path, a.interface, "value", NULL, &reply, "y");
+ if (r < 0) {
+ fprintf(stderr, "Failed to call sd_bus_get_property:%d, %s\n", r, strerror(-r));
+ fprintf(stderr, "Bus: %s, Path: %s, Interface: %s\n",
+ a.bus, a.path, a.interface);
+ break;
+ }
+
+ r = sd_bus_message_read(reply, "y", &reading);
+ if (r < 0) {
+ fprintf(stderr, "Failed to read byte: %s\n", strerror(-r));
+ break;
+ }
+
+ printf("Contents of a 0x%02x is 0x%02x\n", type, reading);
+
+ rc = IPMI_CC_OK;
+ *data_len=sizeof(sensorreadingresp_t);
+
+ resp->value = reading;
+ resp->operation = 0;
+ resp->indication[0] = 0;
+ resp->indication[1] = 0;
+ break;
+
+ default:
+ *data_len=0;
+ rc = IPMI_CC_SENSOR_INVALID;
+ break;
+ }
+
+
+ sd_bus_message_unref(reply);
+
+ return rc;
+}
+
ipmi_ret_t ipmi_sen_wildcard(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
ipmi_request_t request, ipmi_response_t response,
ipmi_data_len_t data_len, ipmi_context_t context)
@@ -173,5 +250,8 @@
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);
+ printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_READING);
+ ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_READING, NULL, ipmi_sen_get_sensor_reading);
+
return;
}
diff --git a/sensorhandler.h b/sensorhandler.h
index 7b89a18..dd940dc 100644
--- a/sensorhandler.h
+++ b/sensorhandler.h
@@ -6,6 +6,7 @@
// IPMI commands for net functions.
enum ipmi_netfn_sen_cmds
{
+ IPMI_CMD_GET_SENSOR_READING = 0x2D,
IPMI_CMD_GET_SENSOR_TYPE = 0x2F,
IPMI_CMD_SET_SENSOR = 0x30,
};
diff --git a/storagehandler.C b/storagehandler.C
index f3e2532..a68da8f 100644
--- a/storagehandler.C
+++ b/storagehandler.C
@@ -60,6 +60,7 @@
struct timeval sel_time;
sel_time.tv_sec = le32toh(*secs);
+ sel_time.tv_usec = 0;
ipmi_ret_t rc = IPMI_CC_OK;
int rct = settimeofday(&sel_time, NULL);
diff --git a/testit.C b/testit.C
index bfd9334..a0cd2c1 100644
--- a/testit.C
+++ b/testit.C
@@ -37,25 +37,31 @@
char g_results_value[64];
-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_s(unsigned char number, const char *member, const char *value) {
+ printf("Attempting to log 0x%02x via %s with a value of %s\n",
+ number, member, value);
- strcpy(g_results_method, method);
+ strcpy(g_results_method, member);
strcpy(g_results_value, value);
return 0;
}
-int set_sensor_dbus_state(uint8_t number, const char *method, const char *value) {
+int set_sensor_dbus_state_y(unsigned char number, char const* member, uint8_t value) {
+
+ char val[2];
- printf("Attempting to log Sensor 0x%02x via %s with a value of %s\n",
- number, method, value);
- strcpy(g_results_method, method);
- strcpy(g_results_value, value);
+ printf("Attempting to log Variant Sensor 0x%02x via %s with a value of 0x%02x\n",
+ number, member, value);
- return 0;
+
+ snprintf(val, 2, "%d", value);
+
+ strcpy(g_results_method, member);
+ strcpy(g_results_value, val);
+
+ return 0;
}