diff options
-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; |