blob: 8907595ced72603b2ace7d93207d3b8354c17cff [file] [log] [blame]
#include "bruno/basictypes.h"
#include "bruno/criticalsection.h"
#include "bruno/logging.h"
#include "bruno/flags.h"
#include "bruno/time.h"
#include "platform_peripheral_api.h"
#include "fancontrol.h"
#include "platform.h"
#include "mailbox.h"
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
// using namespace bruno_platform_peripheral;
int main(int argc, char** argv) {
DEFINE_int(soc_low, 1, "SOC Low temperature");
DEFINE_int(soc_high, 10, "SOC High temperature");
DEFINE_int(hdd_low, 1, "HDD Low temperature");
DEFINE_int(hdd_high, 10, "HDD High temperature");
DEFINE_int(aux1_low, 1, "AUX1 Low temperature");
DEFINE_int(aux1_high, 10, "AUX1 High temperature");
DEFINE_int(percent, 0, "Percentage of the maximum speed the fan starts at");
DEFINE_int(count, 10, "Repeat times");
DEFINE_int(interval, 1, "Interval");
DEFINE_bool(dec_temp, false, "Test with decreasing temperature");
DEFINE_bool(debug, false, "Enable debug log");
DEFINE_bool(help, false, "Prints this message");
// parse options
if (0 != FlagList::SetFlagsFromCommandLine(&argc, argv, true)) {
FlagList::Print(NULL, false);
return 0;
}
if (FLAG_help) {
FlagList::Print(NULL, false);
return 0;
}
if (FLAG_debug) {
bruno_base::LogMessage::LogToDebug(bruno_base::LS_VERBOSE);
} else {
bruno_base::LogMessage::LogToDebug(bruno_base::LS_INFO);
}
bruno_platform_peripheral::Platform platform(
"Unknown", bruno_platform_peripheral::BRUNO_UNKNOWN, false, false, false);
platform.Init();
bruno_platform_peripheral::FanControl fan_control(&platform);
fan_control.Init(NULL);
uint16_t fan_speed;
std::string soc_voltage;
fan_control.DrivePwm(FLAG_percent);
sleep(2);
int i, h, g;
LOG(LS_VERBOSE) << "soc_low=" << FLAG_soc_low << " soc_high=" << FLAG_soc_high
<< " hdd_low=" << FLAG_hdd_low << " hdd_high=" << FLAG_hdd_high
<< " aux1_low=" << FLAG_aux1_low << " aux1_high=" << FLAG_aux1_high;
for (i=FLAG_soc_low, h=FLAG_hdd_low, g=FLAG_aux1_low;
((i<FLAG_soc_high) || (h<FLAG_hdd_high) || (g<FLAG_aux1_high));
i++, h++, g++) {
for (int j=0; j<FLAG_count; ++j) {
fan_control.ReadFanSpeed(&fan_speed);
fan_control.AdjustSpeed(
static_cast<uint16_t>(i), static_cast<uint16_t>(h), static_cast<uint16_t>(g), fan_speed);
fan_control.ReadFanSpeed(&fan_speed);
fan_control.ReadSocVoltage(&soc_voltage);
LOG(LS_INFO) << "voltage:" << soc_voltage
<< " emu-soc_temperature:" << i
<< " emu-hdd_temperature:" << h
<< " emu-aux1_temperature:" << g
<< " fanspeed:" << fan_speed;
sleep(FLAG_interval);
}
}
if (FLAG_dec_temp == true) {
for (i=FLAG_soc_high, h=FLAG_hdd_high, g=FLAG_aux1_high;
((i>FLAG_soc_low) || (h>FLAG_hdd_low) || (g>FLAG_aux1_low));
i--, h--, g--) {
for (int j=0; j<FLAG_count; ++j) {
fan_control.ReadFanSpeed(&fan_speed);
fan_control.AdjustSpeed(
static_cast<uint16_t>(i), static_cast<uint16_t>(h), static_cast<uint16_t>(g), fan_speed);
fan_control.ReadFanSpeed(&fan_speed);
fan_control.ReadSocVoltage(&soc_voltage);
LOG(LS_INFO) << "voltage:" << soc_voltage
<< " emu-soc_temperature:" << i
<< " emu-hdd_temperature:" << h
<< " emu-aux1_temperature:" << g
<< " fanspeed:" << fan_speed;
sleep(FLAG_interval);
}
}
}
fan_control.Terminate();
return 0;
}
#ifdef __cplusplus
} // extern "C" {
#endif