init
This commit is contained in:
24
main.cc
Normal file
24
main.cc
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "include/serial.h"
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
using namespace std::literals::chrono_literals;
|
||||
|
||||
void PrintLog(const std::string& msg){
|
||||
std::cout<<msg<<std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char** const argv){
|
||||
Serial serial;
|
||||
serial.SetLogCallBack(PrintLog);
|
||||
if(!serial.OpenDevice(R"(\\.\COM11)", 115200)){
|
||||
std::cout<<"Open device failed"<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
auto startTime = std::chrono::system_clock::now();
|
||||
// auto res = serial.GetAtUntil("AT+CFUN=1","OK", 200);
|
||||
// std::cout<<res.value_or("ERROR")<<std::endl;
|
||||
auto res = serial.GetAtResponse("AT+ECICCID", 200);
|
||||
std::cout<<res.value_or("ERROR")<<std::endl;
|
||||
auto endTime = std::chrono::system_clock::now();
|
||||
std::cout<<std::chrono::duration_cast<std::chrono::milliseconds>(endTime-startTime).count();
|
||||
}
|
||||
Reference in New Issue
Block a user