diff options
author | Tom Joseph <tomjoseph@in.ibm.com> | 2018-01-25 00:14:34 +0530 |
---|---|---|
committer | Tom Joseph <tomjoseph@in.ibm.com> | 2018-01-30 08:44:29 +0000 |
commit | 9642391d3953754761d5312f59ecbc90341b4759 (patch) | |
tree | 774612a1aa13f5024d1d7f9714dacf2e4473c764 | |
parent | 31ff6e6f4a8f7bac3214e48974a2b0d38b5e0bbb (diff) | |
download | phosphor-host-ipmid-9642391d3953754761d5312f59ecbc90341b4759.tar.gz phosphor-host-ipmid-9642391d3953754761d5312f59ecbc90341b4759.zip |
sensor: Modify Get Device SDR command implementation
a) Specify the sensor name deduction in the yaml
b) Entity ID and entity instance is populated
c) Sensor owner is set to BMC address, since all the sensors are present
on the BMC.
Change-Id: I7b64c48ad1dbd386e12b20af459e40baf0d97cd4
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
-rw-r--r-- | sensorhandler.cpp | 31 | ||||
-rw-r--r-- | sensorhandler.h | 5 |
2 files changed, 22 insertions, 14 deletions
diff --git a/sensorhandler.cpp b/sensorhandler.cpp index c8505e7..8877bb3 100644 --- a/sensorhandler.cpp +++ b/sensorhandler.cpp @@ -850,22 +850,23 @@ ipmi_ret_t populate_record_from_dbus(get_sdr::SensorDataFullRecordBody *body, get_sdr::body::set_b_exp(info->exponentB, body); get_sdr::body::set_r_exp(scale, body); - /* ID string */ - std::string id_string = info->sensorPath.substr( - info->sensorPath.find_last_of('/')+1, info->sensorPath.length()); get_sdr::body::set_id_type(0b00, body); // 00 = unicode - if (id_string.length() > FULL_RECORD_ID_STR_MAX_LENGTH) - { - get_sdr::body::set_id_strlen(FULL_RECORD_ID_STR_MAX_LENGTH, body); - } - else - { - get_sdr::body::set_id_strlen(id_string.length(), body); - } - strncpy(body->id_string, id_string.c_str(), - get_sdr::body::get_id_strlen(body)); } + /* ID string */ + auto id_string = info->sensorNameFunc(*info); + + if (id_string.length() > FULL_RECORD_ID_STR_MAX_LENGTH) + { + get_sdr::body::set_id_strlen(FULL_RECORD_ID_STR_MAX_LENGTH, body); + } + else + { + get_sdr::body::set_id_strlen(id_string.length(), body); + } + strncpy(body->id_string, id_string.c_str(), + get_sdr::body::get_id_strlen(body)); + return IPMI_CC_OK; }; @@ -901,12 +902,14 @@ ipmi_ret_t ipmi_sen_get_sdr(ipmi_netfn_t netfn, ipmi_cmd_t cmd, record.header.record_length = sizeof(get_sdr::SensorDataFullRecord); /* Key */ + get_sdr::key::set_owner_id_bmc(&(record.key)); record.key.sensor_number = sensor_id; /* Body */ - record.body.entity_id = sensor_id; + record.body.entity_id = sensor->second.entityType; record.body.sensor_type = sensor->second.sensorType; record.body.event_reading_type = sensor->second.sensorReadingType; + record.body.entity_instance = sensor->second.instance; // Set the type-specific details given the DBus interface ret = populate_record_from_dbus(&(record.body), &(sensor->second), diff --git a/sensorhandler.h b/sensorhandler.h index b2392ff..8995447 100644 --- a/sensorhandler.h +++ b/sensorhandler.h @@ -181,6 +181,11 @@ inline void set_owner_id_system_sw(SensorDataRecordKey* key) key->owner_id |= 0x01; }; +inline void set_owner_id_bmc(SensorDataRecordKey* key) +{ + key->owner_id |= 0x20; +}; + inline void set_owner_id_address(uint8_t addr, SensorDataRecordKey* key) { key->owner_id &= 0x01; |