summaryrefslogtreecommitdiffstats
path: root/testaddsel.C
diff options
context:
space:
mode:
authorChris Austen <austenc@us.ibm.com>2015-10-25 03:45:42 -0500
committerPatrick Williams <patrick@stwcx.xyz>2015-10-28 17:32:54 -0500
commit41a4b3165ff3a161d184b755969ce316732f8450 (patch)
tree6fdecaaf8e1cf7b79645fd946515a3bb5f4f4e51 /testaddsel.C
parentf3e0137164be7b5098cd300e82a7f6ae717de49a (diff)
downloadphosphor-host-ipmid-41a4b3165ff3a161d184b755969ce316732f8450.tar.gz
phosphor-host-ipmid-41a4b3165ff3a161d184b755969ce316732f8450.zip
Allow esels to be sent to dbus event log
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Diffstat (limited to 'testaddsel.C')
-rw-r--r--testaddsel.C107
1 files changed, 107 insertions, 0 deletions
diff --git a/testaddsel.C b/testaddsel.C
new file mode 100644
index 0000000..202200a
--- /dev/null
+++ b/testaddsel.C
@@ -0,0 +1,107 @@
+#include <stdlib.h>
+#include <limits.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdint.h>
+#include <systemd/sd-bus.h>
+#include "sensorhandler.h"
+
+
+extern void send_esel(uint16_t recordid);
+
+sd_bus *bus = NULL;
+
+// 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;
+}
+
+
+
+
+int main(int argc, char *argv[])
+{
+ int base;
+ char *endptr, *str;
+ long val;
+ uint16_t num;
+ int r;
+
+ if (argc < 2) {
+ fprintf(stderr, "Usage: %s sensornumber\n", argv[0]);
+ return -1;
+ }
+
+ str = argv[1];
+ base = (argc > 2) ? atoi(argv[2]) : 10;
+
+ val = strtol(str, &endptr, base);
+
+ num = (uint16_t) val;
+
+
+
+ /* Connect to system bus */
+ r = sd_bus_open_system(&bus);
+ if (r < 0) {
+ fprintf(stderr, "Failed to connect to system bus: %s\n",
+ strerror(-r));
+ goto finish;
+ }
+
+ send_esel(num);
+
+
+finish:
+ sd_bus_unref(bus);
+
+ return 0;
+} \ No newline at end of file
OpenPOWER on IntegriCloud