init
This commit is contained in:
BIN
ApCreate/bin/wifi
Executable file
BIN
ApCreate/bin/wifi
Executable file
Binary file not shown.
@@ -33,7 +33,6 @@ bp::child net_proc; // 开启网络进程
|
|||||||
string filepath = "/home/orangepi/InitAuth/conf/.env";
|
string filepath = "/home/orangepi/InitAuth/conf/.env";
|
||||||
string cameraPath = "/opt/rknn-yolov11/.env";
|
string cameraPath = "/opt/rknn-yolov11/.env";
|
||||||
string passwd = "/home/orangepi/InitAuth/pwd/.env";
|
string passwd = "/home/orangepi/InitAuth/pwd/.env";
|
||||||
// string cameraPath = "/home/orangepi/InitAuth/.env";
|
|
||||||
|
|
||||||
string url = "http://116.147.36.110:8095/device/validateDevice";
|
string url = "http://116.147.36.110:8095/device/validateDevice";
|
||||||
|
|
||||||
@@ -130,6 +129,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//开启服务
|
||||||
thread(StartService).detach();
|
thread(StartService).detach();
|
||||||
|
|
||||||
thread Rtsp(OpenRTSP);
|
thread Rtsp(OpenRTSP);
|
||||||
@@ -152,7 +152,7 @@ int main(int argc, char *argv[])
|
|||||||
// 开启服务
|
// 开启服务
|
||||||
void StartService()
|
void StartService()
|
||||||
{
|
{
|
||||||
string commnd = "echo 'orangepi' | sudo -S ../../StartService/start start";
|
string commnd = "echo 'orangepi' | sudo -S ../../StartService/bin/start start";
|
||||||
system(commnd.c_str());
|
system(commnd.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
GPIOSignal/bin/sendGpioSignal
Executable file
BIN
GPIOSignal/bin/sendGpioSignal
Executable file
Binary file not shown.
9
GPIOSignal/src/makefile
Normal file
9
GPIOSignal/src/makefile
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
all:sendGpioSignal
|
||||||
|
|
||||||
|
sendGpioSignal:
|
||||||
|
g++ -g -o sendGpioSignal sendGpioSignal.cpp /home/orangepi/RKApp/ApCreate/NetraLib/src/Netra.cpp -I/home/orangepi/RKApp/ApCreate/NetraLib/include -lwiringPi
|
||||||
|
|
||||||
|
mv sendGpioSignal ../bin
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf sendGpioSignal
|
107
GPIOSignal/src/sendGpioSignal.cpp
Normal file
107
GPIOSignal/src/sendGpioSignal.cpp
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
本程序用于读取配置文件
|
||||||
|
根据配置文件发送高低电平
|
||||||
|
发送引脚固定:7,8
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <wiringPi.h>
|
||||||
|
|
||||||
|
#include "/home/orangepi/RKApp/ApCreate/NetraLib/include/Netra.hpp"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace QCL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Parmas:
|
||||||
|
argv[1]: GPIO引脚编号
|
||||||
|
argv[2]: 设置引脚为高/低电平
|
||||||
|
*/
|
||||||
|
|
||||||
|
const string SetFile = "/home/orangepi/InitAuth/conf/.env";
|
||||||
|
|
||||||
|
// 初始化GPIO引脚
|
||||||
|
int InitGpio(int GPIO_Pin1, int GPIO_Pin2);
|
||||||
|
|
||||||
|
// 写入GPIO引脚
|
||||||
|
void WriteGpio(int GPIO_Pin, int value);
|
||||||
|
|
||||||
|
// 获取输出模式
|
||||||
|
bool GetOutValue(int &value);
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int GPIO_Pin1 = 7;
|
||||||
|
int GPIO_Pin2 = 8;
|
||||||
|
|
||||||
|
int value = 0;
|
||||||
|
cout << "[sendGpioSignal] 启动,读取配置: " << SetFile << endl;
|
||||||
|
if (GetOutValue(value) == false)
|
||||||
|
{
|
||||||
|
cerr << "[sendGpioSignal] 未读取到 outPutMode,程序退出" << endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
cout << "[sendGpioSignal] 读取到 outPutMode=" << (value == 1 ? "true" : "false") << endl;
|
||||||
|
|
||||||
|
// 初始化GPIO引脚
|
||||||
|
if (InitGpio(GPIO_Pin1, GPIO_Pin2) != 0)
|
||||||
|
{
|
||||||
|
cout << "Error: Failed to initialize GPIO pin " << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
// 写入GPIO引脚
|
||||||
|
cout << "[sendGpioSignal] 设置 GPIO(" << GPIO_Pin1 << "," << GPIO_Pin2 << ") 为 "
|
||||||
|
<< (value == 1 ? "HIGH" : "LOW") << endl;
|
||||||
|
WriteGpio(GPIO_Pin1, value);
|
||||||
|
WriteGpio(GPIO_Pin2, value);
|
||||||
|
cout << "[sendGpioSignal] 完成" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取输出模式
|
||||||
|
bool GetOutValue(int &value)
|
||||||
|
{
|
||||||
|
bool flag = true;
|
||||||
|
// 读取文件
|
||||||
|
ReadFile *rf =new ReadFile(SetFile);
|
||||||
|
if (rf->Open() == false)
|
||||||
|
{
|
||||||
|
cerr << "读取文件失败" << endl;
|
||||||
|
flag = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto str = rf->ReadLines();
|
||||||
|
for (auto &ii : str)
|
||||||
|
{
|
||||||
|
if (ii.find("outPutMode") != string::npos)
|
||||||
|
{
|
||||||
|
value = (ii.substr(string("outPutMode:").size()) == "true" ? 1 : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化GPIO引脚
|
||||||
|
int InitGpio(int GPIO_Pin1, int GPIO_Pin2)
|
||||||
|
{
|
||||||
|
// 使用物理引脚编号,确保与实际排针一致
|
||||||
|
if (wiringPiSetupPhys() != 0)
|
||||||
|
{
|
||||||
|
return -1; // 初始化失败
|
||||||
|
}
|
||||||
|
|
||||||
|
pinMode(GPIO_Pin1, OUTPUT);
|
||||||
|
pinMode(GPIO_Pin2, OUTPUT);
|
||||||
|
digitalWrite(GPIO_Pin1, LOW); // 默认设置为低电平
|
||||||
|
digitalWrite(GPIO_Pin2, LOW); // 默认设置为低电平
|
||||||
|
|
||||||
|
return 0; // 初始化成功
|
||||||
|
}
|
||||||
|
|
||||||
|
// 写入GPIO引脚
|
||||||
|
void WriteGpio(int GPIO_Pin, int value)
|
||||||
|
{
|
||||||
|
digitalWrite(GPIO_Pin, value == 1 ? HIGH : LOW);
|
||||||
|
}
|
BIN
StartService/bin/start
Executable file
BIN
StartService/bin/start
Executable file
Binary file not shown.
5
StartService/bin/start.sh
Normal file
5
StartService/bin/start.sh
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#开启pubimg.service
|
||||||
|
sudo systemctl start pubimg.service
|
||||||
|
|
||||||
|
#开启fastapi
|
||||||
|
sudo systemctl start fastApi.service
|
3
StartService/bin/stop.sh
Normal file
3
StartService/bin/stop.sh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
sudo systemctl stop fastApi.service
|
||||||
|
|
||||||
|
sudo systemctl stop pubimg.service
|
9
StartService/src/makefile
Normal file
9
StartService/src/makefile
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
all:start
|
||||||
|
|
||||||
|
start:
|
||||||
|
g++ -g -o start start.cpp
|
||||||
|
|
||||||
|
mv start ../bin
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf start
|
36
StartService/src/start.cpp
Normal file
36
StartService/src/start.cpp
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
本程序为BSD服务启动程序,主要用于进行BSD系统的服务启动
|
||||||
|
*/
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
if (argc != 2)
|
||||||
|
{
|
||||||
|
cout << "Using:./start start/stop" << endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
string commnd = "";
|
||||||
|
|
||||||
|
string action(argv[1]);
|
||||||
|
if (action == "start")
|
||||||
|
{
|
||||||
|
commnd = "echo 'orangepi' | sh /home/orangepi/RKApp/StartService/bin/start.sh";
|
||||||
|
}
|
||||||
|
else if(action == "stop")
|
||||||
|
{
|
||||||
|
commnd = "echo 'orangepi' | sh /home/orangepi/RKApp/StartService/bin/stop.sh";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cout << "Unknown action: " << action << "\nUsing: ./start start|stop" << endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
system(commnd.c_str());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Reference in New Issue
Block a user