添加了对/proc/mounts下硬件列表的检测功能,无法识别到TF卡挂在的话 程序将闪灯提示异常,不再继续执行
This commit is contained in:
107
main.cpp
107
main.cpp
@ -6,8 +6,39 @@
|
||||
#include "ZZ_Types.h"
|
||||
#include "DataFileProcessor.h"
|
||||
#include "MakeDarkCurrentTable.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
bool is_mounted(const std::string& device, const std::string& mount_point)
|
||||
{
|
||||
std::ifstream mounts("/proc/mounts");
|
||||
std::string line;
|
||||
|
||||
if (mounts.is_open())
|
||||
{
|
||||
while (getline(mounts, line))
|
||||
{
|
||||
std::istringstream iss(line);
|
||||
std::string dev, mnt, fstype, options;
|
||||
|
||||
if (iss >> dev >> mnt >> fstype >> options)
|
||||
{
|
||||
if (dev == device && mnt == mount_point)
|
||||
{
|
||||
mounts.close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
mounts.close();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||
@ -15,17 +46,42 @@ int main(int argc, char* argv[])
|
||||
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
QEventLoop qeLoop;
|
||||
QTimer::singleShot(30000, &qeLoop, SLOT(quit()));
|
||||
qeLoop.exec();
|
||||
|
||||
//ָʾ<D6B8>ƿ<EFBFBD><C6BF><EFBFBD>
|
||||
//system("sudo mount / dev / mmcblk1p1 / home / data");
|
||||
system("gpio mode 4 out");
|
||||
system("gpio mode 5 out");
|
||||
|
||||
qDebug() << "system(gpio mode 4 out)";
|
||||
qDebug() << "system(gpio mode 5 out)";
|
||||
|
||||
///check tf card
|
||||
std::string device = "/dev/mmcblk1p1";
|
||||
std::string mount_point = "/home/data";
|
||||
if (!is_mounted(device, mount_point)/*1*/)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
system("gpio write 4 1");
|
||||
QEventLoop qeLoop;
|
||||
QTimer::singleShot(200, &qeLoop, SLOT(quit()));
|
||||
qeLoop.exec();
|
||||
system("gpio write 4 0");
|
||||
system("gpio write 5 1");
|
||||
|
||||
QTimer::singleShot(200, &qeLoop, SLOT(quit()));
|
||||
qeLoop.exec();
|
||||
system("gpio write 5 0");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QEventLoop qeLoop;
|
||||
QTimer::singleShot(30000, &qeLoop, SLOT(quit()));
|
||||
//QTimer::singleShot(10000, &qeLoop, SLOT(quit()));
|
||||
qeLoop.exec();
|
||||
|
||||
|
||||
|
||||
OneFSContext m_struFSParam;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
GPSInfo m_struGPSInfo;
|
||||
//FodisRP m_struMiscRunParams;
|
||||
@ -35,15 +91,17 @@ int main(int argc, char* argv[])
|
||||
CMainGrabber m_mgMainGrabber;//<2F><><EFBFBD>ɼ<EFBFBD>
|
||||
DataFileProcessor m_dfpDataSaver;
|
||||
|
||||
#ifndef WIN32
|
||||
QT_LOG::ZZ_InitLogger("/home/data/Log/"); //test
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////test code block
|
||||
//DataFrame aaaa;
|
||||
//int xxxx = sizeof(aaaa);
|
||||
//m_dfpDataSaver.LoadWaveLengthFile("E:/WavelengthInfo.txt");
|
||||
//m_dfpDataSaver.LoadSingleDataFile("D:/15_55_18.datrecv");
|
||||
//m_dfpDataSaver.RecoverBackground("D:/15_55_18.dat", "D:/DCTable.txt");
|
||||
//m_dfpDataSaver.LoadSingleDataFile("D:/Data/2023_07_04/15_55_18.dat");
|
||||
//m_dfpDataSaver.RecoverBackground("D:/Data/2023_07_04/15_55_18.dat", "D:/DCTable.txt");
|
||||
//////////////////////////////////////////////////////////////////////////test code block
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////Check Settings File
|
||||
bool bRes = false;
|
||||
|
||||
@ -71,9 +129,27 @@ int main(int argc, char* argv[])
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int iSize = m_qfiSettingFileInfo.size();
|
||||
if (iSize<50)
|
||||
{
|
||||
bool bRes = QFile::remove("/home/data/Setting/DeviceSettings.ini");
|
||||
if (!bRes)
|
||||
{
|
||||
qDebug() << " QFile::remove Failed.";
|
||||
return -2;
|
||||
}
|
||||
|
||||
bRes = QFile::copy("/root/DeviceSettings.ini", "/home/data/Setting/DeviceSettings.ini");
|
||||
if (!bRes)
|
||||
{
|
||||
qDebug() << " QFile::copy Failed.";
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////Check Settings File
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////Load Settings File
|
||||
///configger
|
||||
m_syscfSettings.Initialize();
|
||||
@ -115,8 +191,6 @@ int main(int argc, char* argv[])
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool bRes = QFile::copy("/root/DCTable.txt", "/home/data/Data/DCTable.txt");
|
||||
if (!bRes)
|
||||
{
|
||||
@ -124,12 +198,8 @@ int main(int argc, char* argv[])
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////Check DCTable
|
||||
|
||||
|
||||
|
||||
////////////////////////////////test only
|
||||
//MakeDCT m_test;
|
||||
//m_test.SetRunParams(m_struFSParam);
|
||||
@ -138,7 +208,6 @@ int main(int argc, char* argv[])
|
||||
//m_test.Initialize_Part();
|
||||
//m_test.LoadTable();
|
||||
////////////////////////////////test only
|
||||
|
||||
m_ctrlGPS.SetContext(m_mgMainGrabber);//<2F><>ʼ<EFBFBD><CABC>gps
|
||||
m_ctrlGPS.SetupMessagePipeline();
|
||||
m_ctrlGPS.Initialize(m_struGPSInfo);
|
||||
@ -153,13 +222,11 @@ int main(int argc, char* argv[])
|
||||
|
||||
m_mgMainGrabber.Initialize();//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
||||
|
||||
//m_ctrlGPS.SyncDateOnce();
|
||||
//m_ctrlGPS.VSlot_SkipSyncDateOnce();
|
||||
|
||||
cout << "System Started..." << endl;
|
||||
///////
|
||||
|
||||
|
||||
|
||||
|
||||
//long long int a1;// 8
|
||||
//long long b; // 8
|
||||
//double c; // 8
|
||||
|
Reference in New Issue
Block a user