Merge "dump_power: parse vimon in dumpstate board" into main

This commit is contained in:
Hiroshi Akiyama 2024-06-12 23:59:24 +00:00 committed by Android (Google) Code Review
commit 85d5e68b88

View file

@ -776,6 +776,11 @@ void dumpMitigationDirs() {
};
const int eraseCnt[] = {6, 6, 4, 0};
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::string content;
@ -783,6 +788,9 @@ void dumpMitigationDirs() {
std::string source;
std::string subModuleName;
std::string readout;
char *endptr;
bool vimon_found = false;
for (int i = 0; i < paramCount; i++) {
printTitle(titles[i]);
@ -800,11 +808,40 @@ void dumpMitigationDirs() {
readout = android::base::Trim(content);
if (strncmp(file.c_str(), vimon_name, vimon_len) == 0)
vimon_found = true;
subModuleName = std::string(file);
subModuleName.erase(subModuleName.find(paramSuffix[i]), eraseCnt[i]);
if (useTitleRow[i]) {
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 {
printf("%s=%s\n", subModuleName.c_str(), readout.c_str());
}