Skip to content
This repository has been archived by the owner on May 19, 2022. It is now read-only.

Commit

Permalink
Exposed (get|set)_sensor_event_enables protocol command in client API.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtikalsky committed Feb 8, 2017
1 parent 9d2cd64 commit 8da70d0
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
30 changes: 30 additions & 0 deletions clientapi/sysmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,36 @@ namespace sysmgr {
throw sysmgr_exception("SET_THRESHOLD response not understood");
}

sensor_event_enables sysmgr::get_sensor_event_enables(uint8_t crate, uint8_t fru, std::string sensor)
{
scope_lock llock(&this->lock);

uint32_t msgid = this->get_msgid();
this->write(stdsprintf("%u GET_EVENT_ENABLES %hhu %hhu \"%s\"\n", msgid, crate, fru, quote_string(sensor).c_str()));

std::vector<std::string> rsp = this->get_line(msgid);
if (rsp.size() < 4)
throw sysmgr_exception("GET_EVENT_ENABLES response not understood");
sensor_event_enables ena;

ena.events_enabled = parse_uint8(rsp[0]);
ena.scanning_enabled = parse_uint8(rsp[1]);
ena.assertion_bitmask = parse_uint16(rsp[2]);
ena.deassertion_bitmask = parse_uint16(rsp[3]);

return ena;
}

void sysmgr::set_sensor_event_enables(uint8_t crate, uint8_t fru, std::string sensor, sensor_event_enables enables)
{
scope_lock llock(&this->lock);

uint32_t msgid = this->get_msgid();
this->write(stdsprintf("%u SET_EVENT_ENABLES %hhu %hhu \"%s\" %hhu %hhu 0x%04hx 0x%04hx\n", msgid, crate, fru, quote_string(sensor).c_str(), (enables.events_enabled ? 1 : 0), (enables.scanning_enabled ? 1 : 0), enables.assertion_bitmask, enables.deassertion_bitmask));

std::vector<std::string> rsp = this->get_line(msgid);
}

std::string sysmgr::raw_card(uint8_t crate, uint8_t fru, std::string cmd)
{
scope_lock llock(&this->lock);
Expand Down
42 changes: 42 additions & 0 deletions clientapi/sysmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,39 @@ namespace sysmgr {
: lnc_set(false), lc_set(false), lnr_set(false), unc_set(false), uc_set(false), unr_set(false) { };
};

/* Sensor Event Enable Information
*
* events_enabled: "All event messages enabled/disabled from this sensor."
* scanning_enabled: "Sensor scanning enabled/disabled."
*
* The (de)assertion bitmask indicates what states have (de)assertion
* events enabled.
*
* For threshold sensors, the order of states is:
*
* Bit Event
* --- -----
* 0 Lower noncritical going low
* 1 Lower noncritical going high
* 2 Lower critical going low
* 3 Lower critical going high
* 4 Lower nonrecoverable going low
* 5 Lower nonrecoverable going high
* 6 Upper noncritical going low
* 7 Upper noncritical going high
* 8 Upper critical going low
* 9 Upper critical going high
* a Upper nonrecoverable going low
* b Upper nonrecoverable going high
*/
class sensor_event_enables {
public:
bool events_enabled;
bool scanning_enabled;
uint16_t assertion_bitmask;
uint16_t deassertion_bitmask;
};

/* This is the primary system manager class, it reflects your connection to
* the system manager and handles all interactions with it.
*/
Expand Down Expand Up @@ -277,6 +310,15 @@ namespace sysmgr {
sensor_thresholds get_sensor_thresholds(uint8_t crate, uint8_t fru, std::string sensor);
void set_sensor_thresholds(uint8_t crate, uint8_t fru, std::string sensor, sensor_thresholds thresholds);

/* These functions allow you to read or write the event enables
* for a sensor.
*
* See the documentation for the sensor_thresholds object for more
* details.
*/
sensor_event_enables get_sensor_event_enables(uint8_t crate, uint8_t fru, std::string sensor);
void set_sensor_event_enables(uint8_t crate, uint8_t fru, std::string sensor, sensor_event_enables enables);

// cmd = [ NetFN, CMD, ParamList ]
// ret = [ CmplCode, ParamList ]

Expand Down

0 comments on commit 8da70d0

Please sign in to comment.