dump_power: parse vimon in dumpstate board

Bug: 345835957
Test: generate bugreport
Flag: EXEMPT bugfix
Change-Id: Id611cd76a0133e1525ffe74e82a6c0d940e39aab
Signed-off-by: Hiroshi Akiyama <hiroshiakiyama@google.com>
This commit is contained in:
Hiroshi Akiyama 2024-06-07 21:58:00 +00:00
parent cbaaa20f41
commit 9bcf2600ec

View file

@ -776,6 +776,11 @@ void dumpMitigationDirs() {
}; };
const int eraseCnt[] = {6, 6, 4, 0}; const int eraseCnt[] = {6, 6, 4, 0};
const bool useTitleRow[] = {true, true, true, false}; const bool useTitleRow[] = {true, true, true, false};
const char *vimon_name = "vimon_buff";
const char delimiter = '\n';
const int vimon_len = strlen(vimon_name);
const double VIMON_VMULT = 7.8122e-5;
const double VIMON_IMULT = 7.8125e-4;
std::vector<std::string> files; std::vector<std::string> files;
std::string content; std::string content;
@ -783,6 +788,9 @@ void dumpMitigationDirs() {
std::string source; std::string source;
std::string subModuleName; std::string subModuleName;
std::string readout; std::string readout;
char *endptr;
bool vimon_found = false;
for (int i = 0; i < paramCount; i++) { for (int i = 0; i < paramCount; i++) {
printTitle(titles[i]); printTitle(titles[i]);
@ -800,11 +808,40 @@ void dumpMitigationDirs() {
readout = android::base::Trim(content); readout = android::base::Trim(content);
if (strncmp(file.c_str(), vimon_name, vimon_len) == 0)
vimon_found = true;
subModuleName = std::string(file); subModuleName = std::string(file);
subModuleName.erase(subModuleName.find(paramSuffix[i]), eraseCnt[i]); subModuleName.erase(subModuleName.find(paramSuffix[i]), eraseCnt[i]);
if (useTitleRow[i]) { if (useTitleRow[i]) {
printf("%s \t%s\n", subModuleName.c_str(), readout.c_str()); printf("%s \t%s\n", subModuleName.c_str(), readout.c_str());
} else if (vimon_found) {
std::vector<std::string> tokens;
std::istringstream tokenStream(readout);
std::string token;
while (std::getline(tokenStream, token, delimiter)) {
tokens.push_back(token);
}
bool oddEntry = true;
for (auto &hexval : tokens) {
int val = strtol(hexval.c_str(), &endptr, 16);
if (*endptr != '\0') {
printf("invalid vimon readout\n");
break;
}
if (oddEntry) {
int vbatt = int(1000 * (val * VIMON_VMULT));
printf("vimon vbatt: %d ", vbatt);
} else {
int ibatt = int(1000 * (val * VIMON_IMULT));
printf("ibatt: %d\n", ibatt);
}
oddEntry = !oddEntry;
}
} else { } else {
printf("%s=%s\n", subModuleName.c_str(), readout.c_str()); printf("%s=%s\n", subModuleName.c_str(), readout.c_str());
} }