diff --git a/clientapi/sysmgr.cpp b/clientapi/sysmgr.cpp index 310521c..8408e51 100644 --- a/clientapi/sysmgr.cpp +++ b/clientapi/sysmgr.cpp @@ -726,8 +726,23 @@ namespace sysmgr { { scope_lock llock(&this->lock); - std::string parameters; + std::vector cmd8; for (std::string::iterator it = cmd.begin(); it != cmd.end(); it++) + cmd8.push_back(static_cast(*it)); + + std::vector rsp8 = this->raw_card(crate, fru, cmd8); + + std::string raw; + for (std::vector::iterator it = rsp8.begin(); it != rsp8.end(); it++) + raw.push_back(static_cast(*it)); + return raw; + } + std::vector sysmgr::raw_card(uint8_t crate, uint8_t fru, std::vector cmd) + { + scope_lock llock(&this->lock); + + std::string parameters; + for (std::vector::iterator it = cmd.begin(); it != cmd.end(); it++) parameters += stdsprintf(" 0x%02x", *it); uint32_t msgid = this->get_msgid(); @@ -737,9 +752,9 @@ namespace sysmgr { if (rsp.size() < 1) throw sysmgr_exception("RAW_CARD response not understood"); - std::string raw; + std::vector raw; for (std::vector::iterator it = rsp.begin(); it != rsp.end(); it++) - raw.push_back(static_cast(parse_uint8(*it))); + raw.push_back(parse_uint8(*it)); return raw; } @@ -747,8 +762,23 @@ namespace sysmgr { { scope_lock llock(&this->lock); - std::string parameters; + std::vector cmd8; for (std::string::iterator it = cmd.begin(); it != cmd.end(); it++) + cmd8.push_back(static_cast(*it)); + + std::vector rsp8 = this->raw_forwarded(crate, bridgechan, bridgeaddr, targetchan, targetaddr, cmd8); + + std::string raw; + for (std::vector::iterator it = rsp8.begin(); it != rsp8.end(); it++) + raw.push_back(static_cast(*it)); + return raw; + } + std::vector sysmgr::raw_forwarded(uint8_t crate, uint8_t bridgechan, uint8_t bridgeaddr, uint8_t targetchan, uint8_t targetaddr, std::vector cmd) + { + scope_lock llock(&this->lock); + + std::string parameters; + for (std::vector::iterator it = cmd.begin(); it != cmd.end(); it++) parameters += stdsprintf(" 0x%02x", *it); uint32_t msgid = this->get_msgid(); @@ -758,9 +788,9 @@ namespace sysmgr { if (rsp.size() < 1) throw sysmgr_exception("RAW_FORWARDED response not understood"); - std::string raw; + std::vector raw; for (std::vector::iterator it = rsp.begin(); it != rsp.end(); it++) - raw.push_back(static_cast(parse_uint8(*it))); + raw.push_back(parse_uint8(*it)); return raw; } @@ -768,8 +798,23 @@ namespace sysmgr { { scope_lock llock(&this->lock); - std::string parameters; + std::vector cmd8; for (std::string::iterator it = cmd.begin(); it != cmd.end(); it++) + cmd8.push_back(static_cast(*it)); + + std::vector rsp8 = this->raw_direct(crate, targetchan, targetaddr, cmd8); + + std::string raw; + for (std::vector::iterator it = rsp8.begin(); it != rsp8.end(); it++) + raw.push_back(static_cast(*it)); + return raw; + } + std::vector sysmgr::raw_direct(uint8_t crate, uint8_t targetchan, uint8_t targetaddr, std::vector cmd) + { + scope_lock llock(&this->lock); + + std::string parameters; + for (std::vector::iterator it = cmd.begin(); it != cmd.end(); it++) parameters += stdsprintf(" 0x%02x", *it); uint32_t msgid = this->get_msgid(); @@ -779,11 +824,12 @@ namespace sysmgr { if (rsp.size() < 1) throw sysmgr_exception("RAW_DIRECT response not understood"); - std::string raw; + std::vector raw; for (std::vector::iterator it = rsp.begin(); it != rsp.end(); it++) - raw.push_back(static_cast(parse_uint8(*it))); + raw.push_back(parse_uint8(*it)); return raw; } + std::string sysmgr::get_slotstring(uint8_t fru) { if (fru == 3 || fru == 4) diff --git a/clientapi/sysmgr.h b/clientapi/sysmgr.h index fe0493e..fc00ed8 100644 --- a/clientapi/sysmgr.h +++ b/clientapi/sysmgr.h @@ -283,10 +283,24 @@ namespace sysmgr { // cmd = [ NetFN, CMD, ParamList ] // ret = [ CmplCode, ParamList ] + + /* Note that std::string, unlike C strings, are size-based rather + * than null-terminated. This allows you to embed null bytes in + * your command strings as shown, when using the + * std::string(char *str, int length) constructor: + * + * char raw_command[5] = { 0x2c, 0x04, 0x00, 0x06, 0x00 }; + * sm.raw_direct(2, 0, 0x82, std::string(raw_command, 5)); + * sm.raw_direct(2, 0, 0x82, std::string("\x2c\x04\x00\x06\x00", 5)); + */ std::string raw_card(uint8_t crate, uint8_t fru, std::string cmd); std::string raw_forwarded(uint8_t crate, uint8_t bridgechan, uint8_t bridgeaddr, uint8_t targetchan, uint8_t targetaddr, std::string cmd); std::string raw_direct(uint8_t crate, uint8_t targetchan, uint8_t targetaddr, std::string cmd); + std::vector raw_card(uint8_t crate, uint8_t fru, std::vector cmd); + std::vector raw_forwarded(uint8_t crate, uint8_t bridgechan, uint8_t bridgeaddr, uint8_t targetchan, uint8_t targetaddr, std::vector cmd); + std::vector raw_direct(uint8_t crate, uint8_t targetchan, uint8_t targetaddr, std::vector cmd); + /* This helper function will return a short human-readable string * version of the given FRU id, such as MCH1 AMC01 PM1 CU1, or * failing all else, FRU1.