Skip to content
This repository has been archived by the owner on Oct 16, 2023. It is now read-only.

Commit

Permalink
Fixes to code. Virt funcs and syslog
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Jul 8, 2020
1 parent 8ddcefb commit 9b7c720
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@


CXX=g++
SRC=src
BUILD=build
BIN=bin
LIB=lib
INSTALL_PATH?=./install

CXX_FLAGS=-Iinclude -std=c++11 -fPIC -Wall -g -O3
CXX_FLAGS=-Iinclude -std=c++11 -fPIC -Wall -g -O3 -Werror -Wpedantic
LD_FLAGS=-lboost_program_options -lboost_system -Wl,-rpath=$(PWD)/lib

#================================================================================
Expand Down
6 changes: 6 additions & 0 deletions include/atca/ApolloBlade.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ public:
virtual int Report();

virtual float GetVal();

protected:
virtual int DoConnect();

private:



void SetModuleNumber(std::string const &);

void SetDatabaseBaseString(std::string const &);
Expand Down
9 changes: 6 additions & 3 deletions src/ApolloMonitor/ApolloMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <vector>
#include <stdexcept>

#include <syslog.h>

int ApolloMonitor::Report() {
int sensorCount = 0;
try{
Expand All @@ -25,18 +27,19 @@ int ApolloMonitor::Report() {
close(sockfd);
sockfd = -1;
return -1;
}
}
//write "."
writen(sockfd, ".", 1);
//write the rest of the value
writen(sockfd,sensorVals.c_str() + iS,end - iS);
sensorCount++;
iS = end;
}
}
}catch(BUException::exBase const & e){
//syslog(LOG_ERR,"Caught BUException: %s\n Info: %s\n",e.what(),e.Description());
syslog(LOG_ERR,"Caught BUException: %s\n Info: %s\n",e.what(),e.Description());
}catch(std::exception const & e){
//syslog(LOG_ERR,"Caught std::exception: %s\n",e.what());
syslog(LOG_ERR,"Caught std::exception: %s\n",e.what());
}
return sensorCount;
}
Expand Down
6 changes: 3 additions & 3 deletions src/atca/ApolloBlade.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void ApolloBlade::SetSensors(){
// sensorNames.push_back(std::pair<std::string,std::string>("16", "PIM_Temp"));
// sensorNames.push_back(std::pair<std::string,std::string>("17", "PIM_I"));

for(size_t iSensor; iSensor < sensorNames.size();iSensor++){
for(size_t iSensor = 0; iSensor < sensorNames.size();iSensor++){
args[0] = sensorNames[iSensor].second;
args[2] = sensorNames[iSensor].first;

Expand All @@ -74,7 +74,7 @@ void ApolloBlade::SetSensors(){
}

int ApolloBlade::DoConnect() {
for(int i = 0; i < apolloSensors.size(); i++){
for(size_t i = 0; i < apolloSensors.size(); i++){
// need to throw exception if one of these fails
if(apolloSensors[i]->Connect(IP, port) < 0) {
return -1;
Expand All @@ -84,7 +84,7 @@ int ApolloBlade::DoConnect() {
}

int ApolloBlade::Report() {
for(int i = 0; i < apolloSensors.size(); i++){
for(size_t i = 0; i < apolloSensors.size(); i++){
try {
apolloSensors[i]->Report();
} catch (std::runtime_error &e) {
Expand Down
21 changes: 10 additions & 11 deletions src/atca/FRUReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include <string.h>
#include <string>

FRUReader::FRUReader(char *hostname_, uint8_t deviceAddr, int fru_id_){
FRUReader::FRUReader(char *hostname_, uint8_t deviceAddr, int fru_id_)
{

hostname = hostname_;
deviceAccessAddress = deviceAddr;
Expand Down Expand Up @@ -180,25 +181,23 @@ int FRUReader::ReadInformationLength(ipmi_ctx_t ipmiContext) {

const size_t buf_rs_size = 256;
uint8_t buf_rs[buf_rs_size];
try{
int raw_result = ipmi_cmd_raw_ipmb(ipmiContext,
channel_number,
deviceAccessAddress,
lun,
net_fn,
(void const *) buf_rq, buf_rq_size,
buf_rs, buf_rs_size);
} catch(std::runtime_error &e){
std::cerr << e.what() << '\n';
if (raw_result < 0){
ipmi_ctx_close(ipmiContext);
throw std::runtime_error(strerror(ipmi_ctx_errnum(ipmiContext)));
}
// if (raw_result < 0){
//printf("nothing found for length\n");
//}

uint8_t length_ls_byte = buf_rs[2];
uint8_t length_ms_byte = buf_rs[3];

informationLength = 256*length_ms_byte + length_ls_byte;

return 0;
}


Expand All @@ -221,7 +220,7 @@ void FRUReader::ReadInternalUse(){
std::vector<uint8_t>::const_iterator first = data.begin() + internalUseStartingOffset;
std::vector<uint8_t>::const_iterator last = data.begin() + internalUseStartingOffset + lenInternalUse;
internalUseData = std::vector<uint8_t>(first, last);
for (int i = 0; i < internalUseData.size(); i++){
for (size_t i = 0; i < internalUseData.size(); i++){
if(i % 8 == 0){
printf("\n");
}
Expand Down Expand Up @@ -343,7 +342,7 @@ void FRUReader::ReadBoardArea(){
}
std::string FRUReader::ReadBoardField(uint8_t field_type_and_length, uint8_t field_index){
uint8_t field_length = ((field_type_and_length) & 0x3f);
uint8_t field_type = ((field_type_and_length) & 0xc0);
//uint8_t field_type = ((field_type_and_length) & 0xc0); //Check in future...
std::string field = "";
for(int i = 0; i < field_length; i++){
field += boardData[field_index+i];
Expand Down Expand Up @@ -489,7 +488,7 @@ void FRUReader::ReadProductInfo(){
}
std::string FRUReader::ReadProductField(uint8_t field_type_and_length, uint8_t field_index){
uint8_t field_length = ((field_type_and_length) & 0x3f);
uint8_t field_type = ((field_type_and_length) & 0xc0);
// uint8_t field_type = ((field_type_and_length) & 0xc0); //check in future...
std::string field = "";
for(int i = 0; i < field_length; i++){
field += productInfoData[field_index+i];
Expand Down
2 changes: 1 addition & 1 deletion src/atca/IPMIFanSpeedSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ float IPMIFanSpeedSensor::GetVal(){


float raw_fan_speed = float(ipmbSensorVal->sensorValue);
float fan_speed_rpm = raw_fan_speed*46;
// float fan_speed_rpm = raw_fan_speed*46;
int fan_speed_percent = raw_fan_speed/1.46;
return fan_speed_percent;
}

0 comments on commit 9b7c720

Please sign in to comment.