rk3399_arm_lvds/testwakeup/main.cpp

45 lines
1.2 KiB
C++

#include <iostream>
#include <memory>
#include <fstream>
#include <thread>
#include "wakeup.hpp"
#include "uartregsaccess.h"
#include "uartregaccessb.h"
using namespace std;
int main()
{
remove("./out.text");
std::shared_ptr<WakeUp> wake;
wake.reset(new WakeUp());
std::shared_ptr<UartRegsAccess> uart;
wake->power_off();
uint reg_val = 0;
std::uint64_t index =0;
std::uint64_t error =0;
while(true)
{
index++;
std::this_thread::sleep_for(std::chrono::seconds(600));
wake->power_on();
std::this_thread::sleep_for(std::chrono::seconds(3));
uart.reset(new UartRegsAccess("/dev/ttyUSB0", 921600, 0x03, 0x83));
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if(!uart->read(15,reg_val))
{
error++;
}
std::this_thread::sleep_for(std::chrono::milliseconds(100));
uart.reset();
std::this_thread::sleep_for(std::chrono::seconds(120));
wake->power_off();
std::string str = "测试次数 = "+to_string(index)+" 异常次数 = "+to_string(error);
printf("\n%s",str.c_str());
std::ofstream o("./out.text");
o << str;
o.close();
}
return 0;
}