M350b版本
This commit is contained in:
4
99-custom-serial.rules
Normal file
4
99-custom-serial.rules
Normal file
@ -0,0 +1,4 @@
|
||||
# Rule for FT232 USB-Serial (UART) IC (ID 0403:6001)
|
||||
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE:="0666", SYMLINK+="ttyAirborn"
|
||||
# Rule for QinHeng Electronics HL-340 USB-Serial adapter (ID 1a86:7523)
|
||||
SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", MODE:="0666", SYMLINK+="ttyWind"
|
||||
@ -1,11 +1,11 @@
|
||||
sudo apt-get install libudev-dev
|
||||
sudo apt-get install libusb-1.0-0-dev
|
||||
sudo apt-get install libopus-dev
|
||||
sudo apt-get install ffmpeg
|
||||
sudo apt install libavformat-dev
|
||||
sudo apt-get install libswscale-dev
|
||||
sudo apt-get install libqt5websockets5-dev
|
||||
sudo apt-get install libssl-dev
|
||||
sudo apt-get install libudev-dev -y
|
||||
sudo apt-get install libusb-1.0-0-dev -y
|
||||
sudo apt-get install libopus-dev -y
|
||||
sudo apt-get install ffmpeg -y
|
||||
sudo apt install libavformat-dev -y
|
||||
sudo apt-get install libswscale-dev -y
|
||||
sudo apt-get install libqt5websockets5-dev -y
|
||||
sudo apt-get install libssl-dev -y
|
||||
|
||||
#!/bin/bash
|
||||
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="2ca3", MODE="0666"' > /etc/udev/rules.d/DJIDevice.rules
|
||||
|
||||
@ -27,7 +27,7 @@ int main()
|
||||
QEventLoop qeLoop;
|
||||
QTimer::singleShot(15000, &qeLoop, SLOT(quit()));
|
||||
qeLoop.exec();
|
||||
QT_LOG::ZZ_InitLogger("/home/data/Log/");
|
||||
// QT_LOG::ZZ_InitLogger("/home/data/Log/");
|
||||
|
||||
CMainAcqThread MainCtrl;
|
||||
MainCtrl.SetupContext();
|
||||
|
||||
@ -62,7 +62,7 @@ int DataFileManager::GenerateFile()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DataFileManager::WriteData(M300RTKDataFrame struM300RTKDataFrame, GSDataFrame struGSDataFrame, UASDataFrame struUASDataFrame)
|
||||
int DataFileManager::WriteData(M350RTKDataFrame struM300RTKDataFrame, GSDataFrame struGSDataFrame, UASDataFrame struUASDataFrame)
|
||||
{
|
||||
// QFile qfData(m_qstrFullFileName);
|
||||
// bool bRes = qfData.open(QFile::WriteOnly | QFile::Text | QIODevice::Append);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#include "pch.h"
|
||||
#include "ZZ_Types.h"
|
||||
|
||||
using namespace ZZ_DATA_DEF::M300RTK;
|
||||
using namespace ZZ_DATA_DEF::DJI;
|
||||
using namespace ZZ_DATA_DEF::CO2_GAS_SENSOR;
|
||||
using namespace ZZ_DATA_DEF::UA_SENSOR;
|
||||
|
||||
@ -16,7 +16,7 @@ public:
|
||||
public:
|
||||
void GenerateFilePath();
|
||||
int GenerateFile();
|
||||
int WriteData(M300RTKDataFrame struM300RTKDataFrame,GSDataFrame struGSDataFrame,UASDataFrame struUASDataFrame);
|
||||
int WriteData(M350RTKDataFrame struM300RTKDataFrame,GSDataFrame struGSDataFrame,UASDataFrame struUASDataFrame);
|
||||
int CloseData();
|
||||
private:
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "ConfigParser_M300RTK.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////M300
|
||||
ZZ_ConfigParser_M300RTK::ZZ_ConfigParser_M300RTK(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_bInit = false;
|
||||
@ -201,3 +202,180 @@ int ZZ_ConfigParser_M300RTK::LoadParams()
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////M350RTK
|
||||
ZZ_ConfigParser_M350RTK::ZZ_ConfigParser_M350RTK(QObject* parent)
|
||||
{
|
||||
m_bInit = false;
|
||||
}
|
||||
|
||||
ZZ_ConfigParser_M350RTK::~ZZ_ConfigParser_M350RTK()
|
||||
{
|
||||
}
|
||||
|
||||
int ZZ_ConfigParser_M350RTK::Initialize(QString qstrConfigFolderPath)
|
||||
{
|
||||
if (m_bInit)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
QDir qdConfigFiles(qstrConfigFolderPath);
|
||||
if (!qdConfigFiles.exists())
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M350RTK: Func Initialize. Dir not exists";
|
||||
return 1;
|
||||
}
|
||||
|
||||
qdConfigFiles.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
||||
qdConfigFiles.setSorting(QDir::DirsFirst);
|
||||
|
||||
QFileInfoList qfList = qdConfigFiles.entryInfoList();
|
||||
if (qfList.size() < 1)
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M350RTK:Func Initialize. Empty folder";
|
||||
return 2;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
do
|
||||
{
|
||||
QFileInfo qfInfo = qfList.at(i);
|
||||
bool bisDir = qfInfo.isDir();
|
||||
if (bisDir)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (qfInfo.fileName() == "AppInfoConfig.ini")
|
||||
{
|
||||
//QSettings qsTemp(qfInfo.filePath(), QSettings::Format::IniFormat);
|
||||
m_pqfM350ConfigFiles[0] = new QSettings(qfInfo.filePath(), QSettings::Format::IniFormat);
|
||||
qDebug() << qfInfo.filePath();
|
||||
j++;
|
||||
}
|
||||
if (qfInfo.fileName() == "HardwareSettings.ini")
|
||||
{
|
||||
//m_qfM300ConfigFiles[1].setUserIniPath(qfInfo.filePath());
|
||||
m_pqfM350ConfigFiles[1] = new QSettings(qfInfo.filePath(), QSettings::Format::IniFormat);
|
||||
qDebug() << qfInfo.filePath();
|
||||
j++;
|
||||
}
|
||||
//qDebug() << qfInfo.filePath() << ":" << qfInfo.fileName();
|
||||
}
|
||||
++i;
|
||||
} while (i < qfList.size());
|
||||
|
||||
if (j != 2)
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M350RTK:Func Initialize. File count not match";
|
||||
return 3;
|
||||
}
|
||||
|
||||
m_bInit = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ConfigParser_M350RTK::LoadParams()
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
QString qstrUSER_APP_NAME = m_pqfM350ConfigFiles[0]->value(QString("DJI/USER_APP_NAME"), "Error").toString();
|
||||
qDebug() << qstrUSER_APP_NAME;
|
||||
if (qstrUSER_APP_NAME == "Error")
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M350RTK:Func LoadParams.USER_APP_NAME not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
QString qstrUSER_APP_ID = m_pqfM350ConfigFiles[0]->value(QString("DJI/USER_APP_ID"), "Error").toString();
|
||||
qDebug() << qstrUSER_APP_ID;
|
||||
if (qstrUSER_APP_ID == "Error")
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M350RTK:Func LoadParams.USER_APP_ID not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
QString qstrUSER_APP_KEY = m_pqfM350ConfigFiles[0]->value(QString("DJI/USER_APP_KEY"), "Error").toString();
|
||||
qDebug() << qstrUSER_APP_KEY;
|
||||
if (qstrUSER_APP_KEY == "Error")
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M350RTK:Func LoadParams.USER_APP_KEY not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
QString qstrUSER_APP_LICENSE = m_pqfM350ConfigFiles[0]->value(QString("DJI/USER_APP_LICENSE"), "Error").toString();
|
||||
qDebug() << qstrUSER_APP_LICENSE;
|
||||
if (qstrUSER_APP_LICENSE == "Error")
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M350RTK:Func LoadParams.USER_APP_KEY not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
QString qstrUSER_DEVELOPER_ACCOUNT = m_pqfM350ConfigFiles[0]->value(QString("DJI/USER_DEVELOPER_ACCOUNT"), "Error").toString();
|
||||
qDebug() << qstrUSER_DEVELOPER_ACCOUNT;
|
||||
if (qstrUSER_DEVELOPER_ACCOUNT == "Error")
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M350RTK:Func LoadParams.USER_APP_KEY not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_struAppRegInfo.qstrUserAppAcc = qstrUSER_DEVELOPER_ACCOUNT;
|
||||
m_struAppRegInfo.qstrUserAppID = qstrUSER_APP_ID;
|
||||
m_struAppRegInfo.qstrUserAppKey = qstrUSER_APP_KEY;
|
||||
m_struAppRegInfo.qstrUserAppLic = qstrUSER_APP_LICENSE;
|
||||
m_struAppRegInfo.qstrUserAppName = qstrUSER_APP_NAME;
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
QString qstrUSER_BAUD_RATE = m_pqfM350ConfigFiles[1]->value(QString("COMPORT/USER_BAUD_RATE"), "NULL").toString();
|
||||
qDebug() << qstrUSER_BAUD_RATE;
|
||||
if (qstrUSER_BAUD_RATE == "NULL")
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M350RTK:Func LoadParams.USER_BAUD_RATE not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
int iCONFIG_HARDWARE_CONNECTION = m_pqfM350ConfigFiles[1]->value(QString("ADV MODE/CONFIG_HARDWARE_CONNECTION"), 10000).toInt();
|
||||
qDebug() << iCONFIG_HARDWARE_CONNECTION;
|
||||
if (iCONFIG_HARDWARE_CONNECTION == 10000)
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M350RTK:Func LoadParams.CONFIG_HARDWARE_CONNECTION not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_struHardwareInfo.enumHCM = HardwareConnectionMode(iCONFIG_HARDWARE_CONNECTION);
|
||||
m_struHardwareInfo.qstrBaudRate = qstrUSER_BAUD_RATE;
|
||||
|
||||
QString qstrWindSensorPort = m_pqfM350ConfigFiles[1]->value(QString("SENSOR/WIND"), "NULL").toString();
|
||||
qDebug() << qstrWindSensorPort;
|
||||
if (qstrWindSensorPort == "NULL")
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M350RTK:Func LoadParams.qstrWindSensorPort not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
QString qstrGasSensorPort = m_pqfM350ConfigFiles[1]->value(QString("SENSOR/GAS"), "NULL").toString();
|
||||
qDebug() << qstrGasSensorPort;
|
||||
if (qstrGasSensorPort == "NULL")
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M350RTK:Func LoadParams.qstrGasSensorPort not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_struSensorPortInfo.qstrGasSensorPort = qstrGasSensorPort;
|
||||
m_struSensorPortInfo.qstrWindSensorPort = qstrWindSensorPort;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ConfigParser_M350RTK::GetParams(AppRegInfo& struAppRegInfo, HardwareInfo& struHardwareInfo, SensorPort& struSensorPortInfo)
|
||||
{
|
||||
Initialize("/home/DJI/Settings/");
|
||||
LoadParams();
|
||||
struAppRegInfo = m_struAppRegInfo;
|
||||
struHardwareInfo = m_struHardwareInfo;
|
||||
struSensorPortInfo = m_struSensorPortInfo;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,10 +1,36 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include "ZZ_Types_M300.h"
|
||||
using namespace ZZ::Device::DJI::M300RTK;
|
||||
#include "ZZ_Types_DJI.h"
|
||||
#include "ZZ_Types.h"
|
||||
using namespace ZZ::Device::DJI;
|
||||
using namespace ZZ_DATA_DEF::MainConfig;
|
||||
|
||||
class ZZ_ConfigParser_M350RTK :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ZZ_ConfigParser_M350RTK(QObject* parent = nullptr);
|
||||
virtual ~ZZ_ConfigParser_M350RTK();
|
||||
|
||||
private:
|
||||
bool m_bInit;
|
||||
QSettings* m_pqfM350ConfigFiles[2];
|
||||
|
||||
AppRegInfo m_struAppRegInfo;
|
||||
HardwareInfo m_struHardwareInfo;
|
||||
SensorPort m_struSensorPortInfo;
|
||||
public:
|
||||
private:
|
||||
int Initialize(QString qstrConfigFolderPath);
|
||||
int LoadParams();
|
||||
public:
|
||||
int GetParams(AppRegInfo& struAppRegInfo, HardwareInfo& struHardwareInfo, SensorPort& struSensorPortInfo);
|
||||
};
|
||||
|
||||
|
||||
class ZZ_ConfigParser_M300RTK :public QObject
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
ZZ_ConfigParser_M300RTK(QObject* parent = nullptr);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[DJI]
|
||||
USER_APP_NAME=Project_Grixis
|
||||
USER_APP_ID=126401
|
||||
USER_APP_KEY=a313e3617b16c56a11502bd91a61d6f
|
||||
USER_APP_LICENSE=BNrpsD+UJ2lj8kmVgN4GnXg+AZiQwaxSuf/WvA072DFdLy2h+NCQizf+nR+WcjEEKeTknSzPbfqlvAc/WSJwrtqV/gYXSVPtSlK0AaV61SeKBvZQpogoyaZy07fWNCZrha3OAQsHj18TtU5RjOn6gYapzGDAPQVG6Q/At/H/9GSPQr5uwxI20fVWUTOkymYLM/04CNQGsToPD+fZwixExjjjHjdD9K7R0D4EgyvbqMpMLlkspBLR/9h6/oVxefOyaHJIi+pk+IdLFFC3omnrh7U3/4b95LA3t22J1GJvqvO2cyphjrSXsaDdctvtj6EjE8WhEXQCvmYm0VIHWz/0Qw==
|
||||
USER_APP_NAME=Project_Fiora
|
||||
USER_APP_ID=151266
|
||||
USER_APP_KEY=d8bc685458ca5dca9280abcdc992d93
|
||||
USER_APP_LICENSE=lXcHSZDwjws7SQnm3TjUINbKIyCC7438vJqiRBBhGe/ckOg3WmhhbYJC5aS/uKSRRMnB2UrqmiE6z+Ta+fBbUOmQUObSQJFrn/VHAsgGKR9nOMdrRNDDSwBbfLcheDIbJwjVmBAgk8RPcTZPH3WNtCohlRcpxuLIrG7oUWaawbLDwwwJ11hx5RqKKHn31I/CXTrbYQbJOm2Da32l/U7/BPF22eBUIJKts7aNfBBbFESNJI3p/xosmxfALkuXYKXMGBiIHk9bu+u0dT53Ddhz++tHh/oFyNQuyhCH4EtecvZu0PR3aMsmxyXbvXhAIocB5+AKZN+kykxhF8ToQS61bQ==
|
||||
USER_DEVELOPER_ACCOUNT=1033584732@qq.com
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
[COMPORT]
|
||||
USER_BAUD_RATE=230400
|
||||
[ADV MODE]
|
||||
CONFIG_HARDWARE_CONNECTION=1
|
||||
CONFIG_HARDWARE_CONNECTION=2
|
||||
@ -14,8 +14,9 @@
|
||||
#include "hal_network.h"
|
||||
|
||||
#include "time.h"
|
||||
#include "ZZ_Types_M300.h"
|
||||
//#include "ZZ_Types_M300.h"
|
||||
|
||||
using namespace ZZ_DATA_DEF::DJI;
|
||||
#define ZZ_UNUSED(x) ((x) = (x))
|
||||
#define ZZ_MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define ZZ_MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
@ -49,27 +50,27 @@ T_DjiReturnCode VehicleController::DjiTest_FcSubscriptionReceiveFlightStatusCall
|
||||
|
||||
T_DjiReturnCode VehicleController::DjiTest_FcSubscriptionReceiveHeightCallback(const uint8_t* data, uint16_t dataSize, const T_DjiDataTimestamp* timestamp)
|
||||
{
|
||||
float fHeight = *((T_DjiFcSubscriptionAltitudeFused*)data);
|
||||
//qDebug() <<"[Fused Height]:"<< fHeight;
|
||||
// float fHeight = *((T_DjiFcSubscriptionAltitudeFused*)data);
|
||||
// //qDebug() <<"[Fused Height]:"<< fHeight;
|
||||
|
||||
///Pump need to be added
|
||||
if (m_siFlagIsPumpWorking==0&& fHeight > 10)
|
||||
{
|
||||
//system("sudo gpio mode 7 out");
|
||||
m_siFlagIsPumpWorking = 1;
|
||||
system("sudo gpio write 7 1");
|
||||
qDebug() << "[Fused Height]:" << fHeight;
|
||||
}
|
||||
if (m_siFlagIsPumpWorking == 1 && fHeight < 10)
|
||||
{
|
||||
//system("sudo gpio mode 7 out");
|
||||
m_siFlagIsPumpWorking = 0;
|
||||
system("sudo gpio write 7 0");
|
||||
qDebug() << "[Fused Height]:" << fHeight;
|
||||
}
|
||||
|
||||
//T_DjiOsalHandler* osalHandler = DjiPlatform_GetOsalHandler();
|
||||
//osalHandler->TaskSleepMs(2000);
|
||||
// ///Pump need to be added
|
||||
// if (m_siFlagIsPumpWorking==0&& fHeight > 10)
|
||||
//{
|
||||
// //system("sudo gpio mode 7 out");
|
||||
// m_siFlagIsPumpWorking = 1;
|
||||
// system("sudo gpio write 7 1");
|
||||
// qDebug() << "[Fused Height]:" << fHeight;
|
||||
// }
|
||||
// if (m_siFlagIsPumpWorking == 1 && fHeight < 10)
|
||||
// {
|
||||
// //system("sudo gpio mode 7 out");
|
||||
// m_siFlagIsPumpWorking = 0;
|
||||
// system("sudo gpio write 7 0");
|
||||
// qDebug() << "[Fused Height]:" << fHeight;
|
||||
// }
|
||||
//
|
||||
// //T_DjiOsalHandler* osalHandler = DjiPlatform_GetOsalHandler();
|
||||
// //osalHandler->TaskSleepMs(2000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -82,37 +83,41 @@ T_DjiReturnCode VehicleController::ZZ_DjiWaypointV2EventCallback(T_DjiWaypointV2
|
||||
}
|
||||
if (eventData.event == 0x10)
|
||||
{
|
||||
if (eventData.data.waypointIndex==0 && m_siFlagIsStartCaptureSignalEmitted==0)
|
||||
{
|
||||
if (m_scCaptureMode==0)
|
||||
{
|
||||
m_siFlagIsStartCaptureSignalEmitted++;
|
||||
spCaller->emit Signal_StartCapture();
|
||||
}
|
||||
// emit Signal_StartCapture();
|
||||
|
||||
}
|
||||
// if (eventData.data.waypointIndex==0 && m_siFlagIsStartCaptureSignalEmitted==0)
|
||||
// {
|
||||
// if (m_scCaptureMode==0)
|
||||
// {
|
||||
// m_siFlagIsStartCaptureSignalEmitted++;
|
||||
//spCaller->emit Signal_StartCapture();
|
||||
// }
|
||||
// // emit Signal_StartCapture();
|
||||
//
|
||||
// }
|
||||
}
|
||||
if (eventData.event == 0x11)
|
||||
{
|
||||
qDebug() << "eventData.event" << m_siFlagIsStartCaptureSignalEmitted;
|
||||
if (m_siFlagIsStartCaptureSignalEmitted > 0)
|
||||
/*if (m_siFlagIsStartCaptureSignalEmitted > 0)
|
||||
{
|
||||
m_siFlagIsStartCaptureSignalEmitted = 0;
|
||||
spCaller->emit Signal_StopCapture();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VehicleController::Initialize()
|
||||
{
|
||||
//m_clsWidget.GetSettings(m_struUIConfig);
|
||||
m_clsConfigParser.GetParams(m_struAppRegInfo, m_struHardwareInfo, m_struSensorPort);
|
||||
|
||||
//m_clsConfigParser.UpdateUIConfig(m_struUIConfig);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VehicleController::SetupEnvironment_M300RTK()
|
||||
int VehicleController::SetupEnvironment()
|
||||
{
|
||||
using namespace ZZ::Device::DJI::M300RTK;
|
||||
// using namespace ZZ::Device::DJI::M300RTK;
|
||||
|
||||
spCaller = this;
|
||||
|
||||
@ -121,7 +126,7 @@ int VehicleController::SetupEnvironment_M300RTK()
|
||||
//clsConfigParser.GetParams(m_struAppRegInfo, m_struHardwareInfo, m_struUIConfig);
|
||||
//
|
||||
//for use
|
||||
m_clsConfigParser.GetParams(m_struAppRegInfo, m_struHardwareInfo, m_struUIConfig);
|
||||
//m_clsConfigParser.GetParams(m_struAppRegInfo, m_struHardwareInfo, m_struUIConfig);
|
||||
|
||||
|
||||
|
||||
@ -212,8 +217,18 @@ int VehicleController::SetupEnvironment_M300RTK()
|
||||
qDebug() << "VehicleController: Func DjiPlatform_RegHalUartHandler. Register hal uart handler error";
|
||||
throw std::runtime_error("Register hal uart handler error.");
|
||||
}
|
||||
//
|
||||
// if (/*m_struHardwareInfo.enumHCM == HardwareConnectionMode::UartAndUSBBulk*/1)
|
||||
// {
|
||||
// returnCode = DjiPlatform_RegHalUsbBulkHandler(&usbBulkHandler);
|
||||
// if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
// {
|
||||
// qDebug() << "VehicleController: Func DjiPlatform_RegHalUsbBulkHandler. Register hal usb bulk handler error";
|
||||
// throw std::runtime_error("Register hal usb bulk handler error.");
|
||||
// }
|
||||
// }
|
||||
|
||||
if (m_struHardwareInfo.enumHCM == HardwareConnectionMode::UartAndNetwork)
|
||||
if (/*m_struHardwareInfo.enumHCM == HardwareConnectionMode::UartAndNetwork*/ 1)
|
||||
{
|
||||
returnCode = DjiPlatform_RegHalNetworkHandler(&networkHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
@ -222,29 +237,29 @@ int VehicleController::SetupEnvironment_M300RTK()
|
||||
throw std::runtime_error("Register hal network handler error");
|
||||
}
|
||||
}
|
||||
else if (m_struHardwareInfo.enumHCM == HardwareConnectionMode::UartAndUSBBulk)
|
||||
{
|
||||
returnCode = DjiPlatform_RegHalUsbBulkHandler(&usbBulkHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "VehicleController: Func DjiPlatform_RegHalUsbBulkHandler. Register hal usb bulk handler error";
|
||||
throw std::runtime_error("Register hal usb bulk handler error.");
|
||||
}
|
||||
}
|
||||
else if (m_struHardwareInfo.enumHCM == HardwareConnectionMode::UartOnly)
|
||||
{
|
||||
returnCode = DjiPlatform_RegSocketHandler(&socketHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "VehicleController: Func DjiPlatform_RegSocketHandler. Register osal socket handler error";
|
||||
throw std::runtime_error("register osal socket handler error");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "VehicleController: Func DjiPlatform_RegSocketHandler. Register osal socket handler error";
|
||||
throw std::runtime_error("hardware connection configuration error");
|
||||
}
|
||||
//else if (m_struHardwareInfo.enumHCM == HardwareConnectionMode::UartAndUSBBulk)
|
||||
//{
|
||||
// returnCode = DjiPlatform_RegHalUsbBulkHandler(&usbBulkHandler);
|
||||
// if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
// {
|
||||
// qDebug() << "VehicleController: Func DjiPlatform_RegHalUsbBulkHandler. Register hal usb bulk handler error";
|
||||
// throw std::runtime_error("Register hal usb bulk handler error.");
|
||||
// }
|
||||
// }
|
||||
//else if (m_struHardwareInfo.enumHCM == HardwareConnectionMode::UartOnly)
|
||||
//{
|
||||
// returnCode = DjiPlatform_RegSocketHandler(&socketHandler);
|
||||
// if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
// {
|
||||
// qDebug() << "VehicleController: Func DjiPlatform_RegSocketHandler. Register osal socket handler error";
|
||||
// throw std::runtime_error("register osal socket handler error");
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// qDebug() << "VehicleController: Func DjiPlatform_RegSocketHandler. Register osal socket handler error";
|
||||
// throw std::runtime_error("hardware connection configuration error");
|
||||
//}
|
||||
|
||||
returnCode = DjiPlatform_RegFileSystemHandler(&fileSystemHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
@ -264,8 +279,9 @@ int VehicleController::SetupEnvironment_M300RTK()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VehicleController::StartupPSDK_M300RTK()
|
||||
int VehicleController::StartupPSDK_M350RTK()
|
||||
{
|
||||
|
||||
T_DjiUserInfo userInfo;
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiAircraftInfoBaseInfo aircraftInfoBaseInfo;
|
||||
@ -308,27 +324,27 @@ int VehicleController::StartupPSDK_M300RTK()
|
||||
throw std::runtime_error("Start sdk application error.");
|
||||
}
|
||||
|
||||
//osalHandler->TaskSleepMs(5000);
|
||||
SetupWidget();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><DFBC>л<EFBFBD>
|
||||
//osalHandler->TaskSleepMs(5000);
|
||||
SetupMessagePipe();//widget<65><74>vehicle
|
||||
SetupWaypointStatusCallback();
|
||||
InitSystemParams();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䣬<EFBFBD><E4A3AC><EFBFBD><EFBFBD>ϵͳʱ<CDB3>䣬Ȼ<E4A3AC><C8BB>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>Ϊ<EFBFBD><EFBFBD>ͬʱ<CDAC><CAB1><EFBFBD><EFBFBD>5<EFBFBD><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
SetupSubscriptions();//ʵ<><CAB5><EFBFBD><EFBFBD>Ҫ<EFBFBD>Ķ<EFBFBD><C4B6>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD><CCAB><EFBFBD><EFBFBD>
|
||||
osalHandler->TaskSleepMs(5000);
|
||||
SetupWidget();
|
||||
osalHandler->TaskSleepMs(5000);
|
||||
SetupMessagePipe();
|
||||
//SetupWaypointStatusCallback();
|
||||
//InitSystemParams();
|
||||
SetupSubscriptions();
|
||||
|
||||
|
||||
qDebug()<<"M300RTK PSDK Channel Started.";
|
||||
qDebug()<<"M350RTK PSDK Channel Started.";
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VehicleController::UpdateUIConfig()
|
||||
{
|
||||
m_clsWidget.GetSettings(m_struUIConfig);
|
||||
m_clsConfigParser.UpdateUIConfig(m_struUIConfig);
|
||||
//m_clsWidget.GetSettings(m_struUIConfig);
|
||||
//m_clsConfigParser.UpdateUIConfig(m_struUIConfig);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VehicleController::GetOneDataFrame(M300RTKDataFrame& M300RTKDataFrame)
|
||||
int VehicleController::GetOneDataFrame(M350RTKDataFrame& M350RTKDataFrame)
|
||||
{
|
||||
T_DjiReturnCode tDjiReturnCode;
|
||||
T_DjiFcSubscriptionVelocity tDjiVelocity = { 0 };
|
||||
@ -372,29 +388,29 @@ int VehicleController::GetOneDataFrame(M300RTKDataFrame& M300RTKDataFrame)
|
||||
//return 4;
|
||||
}
|
||||
|
||||
M300RTKDataFrame.stVelocity.x = tDjiVelocity.data.x;
|
||||
M300RTKDataFrame.stVelocity.y = tDjiVelocity.data.y;
|
||||
M300RTKDataFrame.stVelocity.z = tDjiVelocity.data.z;
|
||||
M350RTKDataFrame.stVelocity.x = tDjiVelocity.data.x;
|
||||
M350RTKDataFrame.stVelocity.y = tDjiVelocity.data.y;
|
||||
M350RTKDataFrame.stVelocity.z = tDjiVelocity.data.z;
|
||||
|
||||
M300RTKDataFrame.stQuaternion.w_q0 = tDjiQuaternion.q0;
|
||||
M300RTKDataFrame.stQuaternion.x_q1 = tDjiQuaternion.q1;
|
||||
M300RTKDataFrame.stQuaternion.y_q2 = tDjiQuaternion.q2;
|
||||
M300RTKDataFrame.stQuaternion.z_q3 = tDjiQuaternion.q3;
|
||||
M350RTKDataFrame.stQuaternion.w_q0 = tDjiQuaternion.q0;
|
||||
M350RTKDataFrame.stQuaternion.x_q1 = tDjiQuaternion.q1;
|
||||
M350RTKDataFrame.stQuaternion.y_q2 = tDjiQuaternion.q2;
|
||||
M350RTKDataFrame.stQuaternion.z_q3 = tDjiQuaternion.q3;
|
||||
|
||||
M300RTKDataFrame.stGPSPosition.x = tDjiGpsPosition.x;
|
||||
M300RTKDataFrame.stGPSPosition.y = tDjiGpsPosition.y;
|
||||
M300RTKDataFrame.stGPSPosition.z = tDjiGpsPosition.z;
|
||||
M350RTKDataFrame.stGPSPosition.x = tDjiGpsPosition.x;
|
||||
M350RTKDataFrame.stGPSPosition.y = tDjiGpsPosition.y;
|
||||
M350RTKDataFrame.stGPSPosition.z = tDjiGpsPosition.z;
|
||||
|
||||
M300RTKDataFrame.fAltitudeFused = tDjiAltFused;
|
||||
M350RTKDataFrame.fAltitudeFused = tDjiAltFused;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////Calc Euler From Quaternion 20230428
|
||||
M300RTKDataFrame.stEulerAngle.pitch = (dji_f64_t)asinf(-2 * tDjiQuaternion.q1 * tDjiQuaternion.q3 + 2 * tDjiQuaternion.q0 * tDjiQuaternion.q2) * 57.3;
|
||||
M350RTKDataFrame.stEulerAngle.pitch = (dji_f64_t)asinf(-2 * tDjiQuaternion.q1 * tDjiQuaternion.q3 + 2 * tDjiQuaternion.q0 * tDjiQuaternion.q2) * 57.3;
|
||||
|
||||
M300RTKDataFrame.stEulerAngle.roll = (dji_f64_t)atan2f(2 * tDjiQuaternion.q2 * tDjiQuaternion.q3 + 2 * tDjiQuaternion.q0 * tDjiQuaternion.q1,
|
||||
M350RTKDataFrame.stEulerAngle.roll = (dji_f64_t)atan2f(2 * tDjiQuaternion.q2 * tDjiQuaternion.q3 + 2 * tDjiQuaternion.q0 * tDjiQuaternion.q1,
|
||||
-2 * tDjiQuaternion.q1 * tDjiQuaternion.q1 - 2 * tDjiQuaternion.q2 * tDjiQuaternion.q2 + 1) * 57.3;
|
||||
|
||||
M300RTKDataFrame.stEulerAngle.yaw = (dji_f64_t)atan2f(2 * tDjiQuaternion.q1 * tDjiQuaternion.q2 + 2 * tDjiQuaternion.q0 * tDjiQuaternion.q3,
|
||||
M350RTKDataFrame.stEulerAngle.yaw = (dji_f64_t)atan2f(2 * tDjiQuaternion.q1 * tDjiQuaternion.q2 + 2 * tDjiQuaternion.q0 * tDjiQuaternion.q3,
|
||||
-2 * tDjiQuaternion.q2 * tDjiQuaternion.q2 - 2 * tDjiQuaternion.q3 * tDjiQuaternion.q3 + 1) * 57.3;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -410,24 +426,24 @@ int VehicleController::SetupSubscriptions()
|
||||
{
|
||||
T_DjiReturnCode tDjiReturnCode;
|
||||
|
||||
// tDjiReturnCode = DjiFcSubscription_Init();
|
||||
// if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
// {
|
||||
// qDebug() << "init data subscription module error.";
|
||||
// return 0;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// qDebug() << "init data subscription module finished.";
|
||||
// }
|
||||
tDjiReturnCode = DjiFcSubscription_Init();
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "init data subscription module error.";
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "init data subscription module finished.";
|
||||
}
|
||||
|
||||
tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_HEIGHT_FUSION, DJI_DATA_SUBSCRIPTION_TOPIC_1_HZ, DjiTest_FcSubscriptionReceiveHeightCallback);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
// tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_HEIGHT_FUSION, DJI_DATA_SUBSCRIPTION_TOPIC_1_HZ, DjiTest_FcSubscriptionReceiveHeightCallback);
|
||||
//if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
//{
|
||||
|
||||
qDebug() << "Subscribe topic DJI_FC_SUBSCRIPTION_TOPIC_HEIGHT_FUSION error.";
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
// qDebug() << "Subscribe topic DJI_FC_SUBSCRIPTION_TOPIC_HEIGHT_FUSION error.";
|
||||
// return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
//}
|
||||
|
||||
tDjiReturnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_VELOCITY, DJI_DATA_SUBSCRIPTION_TOPIC_5_HZ, NULL);
|
||||
if (tDjiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
@ -492,7 +508,7 @@ int VehicleController::SetupWaypointStatusCallback()
|
||||
|
||||
int VehicleController::LoadUserAppInfo(T_DjiUserInfo* struDjiUserInfo)
|
||||
{
|
||||
using namespace ZZ::Device::DJI::M300RTK;
|
||||
//using namespace ZZ::Device::DJI::M300RTK;
|
||||
|
||||
memset(struDjiUserInfo->appName, 0, sizeof(struDjiUserInfo->appName));
|
||||
memset(struDjiUserInfo->appId, 0, sizeof(struDjiUserInfo->appId));
|
||||
@ -501,22 +517,38 @@ int VehicleController::LoadUserAppInfo(T_DjiUserInfo* struDjiUserInfo)
|
||||
memset(struDjiUserInfo->developerAccount, 0, sizeof(struDjiUserInfo->developerAccount));
|
||||
memset(struDjiUserInfo->baudRate, 0, sizeof(struDjiUserInfo->baudRate));
|
||||
|
||||
if (m_struAppRegInfo.qstrUserAppName.length() >= sizeof(struDjiUserInfo->appName) ||
|
||||
m_struAppRegInfo.qstrUserAppID.length() > sizeof(struDjiUserInfo->appId) ||
|
||||
m_struAppRegInfo.qstrUserAppKey.length() > sizeof(struDjiUserInfo->appKey) ||
|
||||
m_struAppRegInfo.qstrUserAppLic.length() > sizeof(struDjiUserInfo->appLicense) ||
|
||||
m_struAppRegInfo.qstrUserAppAcc.length() >= sizeof(struDjiUserInfo->developerAccount) ||
|
||||
m_struHardwareInfo.qstrBaudRate.length() > sizeof(struDjiUserInfo->baudRate))
|
||||
{
|
||||
qDebug()<<"VehicleController:LoadUserAppInfo.Length of user information string is beyond limit,Please check";
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
//struDjiUserInfo->appName = "Project_Fiora";
|
||||
//struDjiUserInfo->appId = "151266";
|
||||
//struDjiUserInfo->appKey = "d8bc685458ca5dca9280abcdc992d93";
|
||||
//struDjiUserInfo->appLicense = "lXcHSZDwjws7SQnm3TjUINbKIyCC7438vJqiRBBhGe/ckOg3WmhhbYJC5aS/uKSRRMnB2UrqmiE6z+Ta+fBbUOmQUObSQJFrn/VHAsgGKR9nOMdrRNDDSwBbfLcheDIbJwjVmBAgk8RPcTZPH3WNtCohlRcpxuLIrG7oUWaawbLDwwwJ11hx5RqKKHn31I/CXTrbYQbJOm2Da32l/U7/BPF22eBUIJKts7aNfBBbFESNJI3p/xosmxfALkuXYKXMGBiIHk9bu+u0dT53Ddhz++tHh/oFyNQuyhCH4EtecvZu0PR3aMsmxyXbvXhAIocB5+AKZN+kykxhF8ToQS61bQ==";
|
||||
//struDjiUserInfo->developerAccount = "1033584732@qq.com";
|
||||
//struDjiUserInfo->baudRate = "460800";
|
||||
|
||||
//strncpy(struDjiUserInfo->appName, "Project_Fiora", sizeof(struDjiUserInfo->appName));
|
||||
//strncpy(struDjiUserInfo->appId, "151266", sizeof(struDjiUserInfo->appId));
|
||||
//strncpy(struDjiUserInfo->appKey, "d8bc685458ca5dca9280abcdc992d93", sizeof(struDjiUserInfo->appKey));
|
||||
//strncpy(struDjiUserInfo->appLicense, "lXcHSZDwjws7SQnm3TjUINbKIyCC7438vJqiRBBhGe/ckOg3WmhhbYJC5aS/uKSRRMnB2UrqmiE6z+Ta+fBbUOmQUObSQJFrn/VHAsgGKR9nOMdrRNDDSwBbfLcheDIbJwjVmBAgk8RPcTZPH3WNtCohlRcpxuLIrG7oUWaawbLDwwwJ11hx5RqKKHn31I/CXTrbYQbJOm2Da32l/U7/BPF22eBUIJKts7aNfBBbFESNJI3p/xosmxfALkuXYKXMGBiIHk9bu+u0dT53Ddhz++tHh/oFyNQuyhCH4EtecvZu0PR3aMsmxyXbvXhAIocB5+AKZN+kykxhF8ToQS61bQ==", sizeof(struDjiUserInfo->appLicense));
|
||||
//strncpy(struDjiUserInfo->developerAccount, "1033584732@qq.com", sizeof(struDjiUserInfo->developerAccount));
|
||||
//strncpy(struDjiUserInfo->baudRate, "921600", sizeof(struDjiUserInfo->baudRate));
|
||||
|
||||
|
||||
|
||||
|
||||
//if (m_struAppRegInfo.qstrUserAppName.length() >= sizeof(struDjiUserInfo->appName) ||
|
||||
// m_struAppRegInfo.qstrUserAppID.length() > sizeof(struDjiUserInfo->appId) ||
|
||||
// m_struAppRegInfo.qstrUserAppKey.length() > sizeof(struDjiUserInfo->appKey) ||
|
||||
// m_struAppRegInfo.qstrUserAppLic.length() > sizeof(struDjiUserInfo->appLicense) ||
|
||||
// m_struAppRegInfo.qstrUserAppAcc.length() >= sizeof(struDjiUserInfo->developerAccount) ||
|
||||
// m_struHardwareInfo.qstrBaudRate.length() > sizeof(struDjiUserInfo->baudRate))
|
||||
// {
|
||||
// qDebug()<<"VehicleController:LoadUserAppInfo.Length of user information string is beyond limit,Please check";
|
||||
// return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
//}
|
||||
|
||||
strncpy(struDjiUserInfo->appName, m_struAppRegInfo.qstrUserAppName.toLatin1().data(), m_struAppRegInfo.qstrUserAppName.length());
|
||||
memcpy(struDjiUserInfo->appId, m_struAppRegInfo.qstrUserAppID.toLatin1().data(), ZZ_MIN(sizeof(struDjiUserInfo->appId), m_struAppRegInfo.qstrUserAppID.length()));
|
||||
memcpy(struDjiUserInfo->appKey, m_struAppRegInfo.qstrUserAppKey.toLatin1().data(), ZZ_MIN(sizeof(struDjiUserInfo->appKey), m_struAppRegInfo.qstrUserAppKey.length()));
|
||||
memcpy(struDjiUserInfo->appLicense, m_struAppRegInfo.qstrUserAppLic.toLatin1().data(),
|
||||
ZZ_MIN(sizeof(struDjiUserInfo->appLicense), m_struAppRegInfo.qstrUserAppLic.length()));
|
||||
memcpy(struDjiUserInfo->appLicense, m_struAppRegInfo.qstrUserAppLic.toLatin1().data(),ZZ_MIN(sizeof(struDjiUserInfo->appLicense), m_struAppRegInfo.qstrUserAppLic.length()));
|
||||
memcpy(struDjiUserInfo->baudRate, m_struHardwareInfo.qstrBaudRate.toLatin1().data(), ZZ_MIN(sizeof(struDjiUserInfo->baudRate), m_struHardwareInfo.qstrBaudRate.length()));
|
||||
strncpy(struDjiUserInfo->developerAccount, m_struAppRegInfo.qstrUserAppAcc.toLatin1().data(), sizeof(struDjiUserInfo->developerAccount) - 1);
|
||||
|
||||
@ -532,22 +564,22 @@ T_DjiReturnCode VehicleController::DjiUser_PrintMessage(const uint8_t* data, uin
|
||||
|
||||
int VehicleController::SetupMessagePipe()
|
||||
{
|
||||
connect(&m_clsWidget, &ZZ_Widget_M300RTK::Signal_UpdateCaptureMode, this, &VehicleController::Slot_OnChangeCaptureMode);
|
||||
// connect(&m_clsWidget, &ZZ_Widget_M300RTK::Signal_UpdateCaptureMode, this, &VehicleController::Slot_OnChangeCaptureMode);
|
||||
connect(&m_clsWidget, &ZZ_Widget_M300RTK::Signal_StartCapture, this, &VehicleController::Signal_StartCapture);
|
||||
connect(&m_clsWidget, &ZZ_Widget_M300RTK::Signal_StopCapture, this, &VehicleController::Signal_StopCapture);
|
||||
connect(&m_clsWidget, &ZZ_Widget_M300RTK::Signal_StopCapture, this, &VehicleController::Signal_StopCapture);
|
||||
connect(this, &VehicleController::Signal_UpdateVehicleMessage, &m_clsWidget, &ZZ_Widget_M300RTK::Slot_UpdatePSDKFloatMessage);
|
||||
/// for test
|
||||
#ifdef ZZ_FLAG_TEST
|
||||
connect(this, &VehicleController::Signal_StartCapture, this, &VehicleController::Slot_TestStartCapture);
|
||||
connect(this, &VehicleController::Signal_StopCapture, this, &VehicleController::Slot_TestStopCapture);
|
||||
#endif
|
||||
// /// for test
|
||||
//#ifdef ZZ_FLAG_TEST
|
||||
// connect(this, &VehicleController::Signal_StartCapture, this, &VehicleController::Slot_TestStartCapture);
|
||||
// connect(this, &VehicleController::Signal_StopCapture, this, &VehicleController::Slot_TestStopCapture);
|
||||
//#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VehicleController::SetupWidget()
|
||||
{
|
||||
m_clsWidget.SetUIFilePath("/home/DJI/Widget",100);
|
||||
m_clsWidget.SetSettings(m_struUIConfig);
|
||||
m_clsWidget.SetUIFilePath(const_cast<char*>("/home/DJI/Widget"),100);
|
||||
// m_clsWidget.SetSettings(m_struUIConfig);
|
||||
m_clsWidget.PreparteEnvironment();
|
||||
|
||||
return 0;
|
||||
|
||||
@ -7,14 +7,15 @@
|
||||
#include "dji_core.h"
|
||||
#include "dji_waypoint_v2.h"
|
||||
|
||||
//#include "ConfigParser_DJI.h"
|
||||
#include "pch.h"
|
||||
|
||||
#include "ConfigParser_M300RTK.h"
|
||||
#include "Widget_M300RTK.h"
|
||||
#include "ZZ_Types.h"
|
||||
using namespace std;
|
||||
using namespace ZZ_DATA_DEF::M300RTK;
|
||||
using namespace ZZ_DATA_DEF::MainConfig;
|
||||
using namespace ZZ_DATA_DEF::DJI;
|
||||
//using namespace ZZ_DATA_DEF::MainConfig;
|
||||
|
||||
class VehicleController :public QObject
|
||||
{
|
||||
@ -28,15 +29,19 @@ public:
|
||||
static int m_siFlagIsStartCaptureSignalEmitted;
|
||||
static VehicleController* spCaller;
|
||||
static char m_scCaptureMode;
|
||||
SensorPort m_struSensorPort;
|
||||
private:
|
||||
///////////Config need modify
|
||||
ZZ_ConfigParser_M300RTK m_clsConfigParser;
|
||||
ZZ_Widget_M300RTK m_clsWidget;
|
||||
|
||||
M300RTKSettings m_struM300RTKSs;
|
||||
ZZ_ConfigParser_M350RTK m_clsConfigParser;
|
||||
AppRegInfo m_struAppRegInfo;
|
||||
HardwareInfo m_struHardwareInfo;
|
||||
UIConfig m_struUIConfig;
|
||||
//ZZ_ConfigParser_M300RTK m_clsConfigParser;
|
||||
ZZ_Widget_M300RTK m_clsWidget;
|
||||
|
||||
//M300RTKSettings m_struM300RTKSs;
|
||||
//AppRegInfo m_struAppRegInfo;
|
||||
//HardwareInfo m_struHardwareInfo;
|
||||
//UIConfig m_struUIConfig;
|
||||
|
||||
int m_iFlagIsVehicleTakeoff;
|
||||
int m_iFlagIsVehicleCapturing;
|
||||
@ -53,15 +58,15 @@ public:
|
||||
public:
|
||||
/// call First
|
||||
int Initialize();
|
||||
int SetupEnvironment_M300RTK();
|
||||
int SetupEnvironment();
|
||||
/// call Seconde
|
||||
int StartupPSDK_M300RTK();
|
||||
int StartupPSDK_M350RTK();
|
||||
|
||||
///call to save Settings
|
||||
int UpdateUIConfig();
|
||||
|
||||
/// data call
|
||||
int GetOneDataFrame(M300RTKDataFrame &M300RTKDataFrame);
|
||||
int GetOneDataFrame(M350RTKDataFrame &M350RTKDataFrame);
|
||||
private:
|
||||
///
|
||||
int SetupMessagePipe();
|
||||
|
||||
@ -42,7 +42,7 @@ extern "C" {
|
||||
#ifdef PLATFORM_ARCH_x86_64
|
||||
#define LINUX_NETWORK_DEV "enxf8e43b7bbc2c"
|
||||
#else
|
||||
#define LINUX_NETWORK_DEV "l4tbr0"
|
||||
#define LINUX_NETWORK_DEV "pi4br0"
|
||||
#endif
|
||||
/**
|
||||
* @attention
|
||||
|
||||
@ -68,7 +68,7 @@ T_DjiReturnCode HalUart_Init(E_DjiHalUartNum uartNum, uint32_t baudRate, T_DjiUa
|
||||
} else {
|
||||
goto free_uart_handle;
|
||||
}
|
||||
|
||||
// #define USE_CLION_DEBUG;
|
||||
#ifdef USE_CLION_DEBUG
|
||||
sprintf(systemCmd, "ls -l %s", uartName);
|
||||
fp = popen(systemCmd, "r");
|
||||
|
||||
@ -45,8 +45,8 @@ extern "C" {
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
//User can config dev based on there environmental conditions
|
||||
#define LINUX_UART_DEV1 "/dev/ttyUSB0"
|
||||
#define LINUX_UART_DEV2 "/dev/ttyACM0"
|
||||
#define LINUX_UART_DEV1 "/dev/ttyAirborn"
|
||||
#define LINUX_UART_DEV2 "/dev/ttyUSB2"
|
||||
|
||||
//global
|
||||
extern char gvpcM300RTK_UART1[128];
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "hal_usb_bulk.h"
|
||||
#include "dji_logger.h"
|
||||
#include "utils/dji_config_manager.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define LINUX_USB_BULK_TRANSFER_TIMEOUT_MS (50)
|
||||
@ -52,6 +53,13 @@ T_DjiReturnCode HalUsbBulk_Init(T_DjiHalUsbBulkInfo usbBulkInfo, T_DjiUsbBulkHan
|
||||
{
|
||||
int32_t ret;
|
||||
struct libusb_device_handle *handle = NULL;
|
||||
T_DjiUserLinkConfig linkConfig = {0};
|
||||
char usbBulk1EpInFd[USER_DEVICE_NAME_STR_MAX_SIZE];
|
||||
char usbBulk1EpOutFd[USER_DEVICE_NAME_STR_MAX_SIZE];
|
||||
char usbBulk2EpInFd[USER_DEVICE_NAME_STR_MAX_SIZE];
|
||||
char usbBulk2EpOutFd[USER_DEVICE_NAME_STR_MAX_SIZE];
|
||||
uint8_t usbBulk1InterfaceNum;
|
||||
uint8_t usbBulk2InterfaceNum;
|
||||
|
||||
*usbBulkHandle = malloc(sizeof(T_HalUsbBulkObj));
|
||||
if (*usbBulkHandle == NULL) {
|
||||
@ -67,7 +75,7 @@ T_DjiReturnCode HalUsbBulk_Init(T_DjiHalUsbBulkInfo usbBulkInfo, T_DjiUsbBulkHan
|
||||
}
|
||||
|
||||
handle = libusb_open_device_with_vid_pid(NULL, usbBulkInfo.vid, usbBulkInfo.pid);
|
||||
if(handle == NULL) {
|
||||
if (handle == NULL) {
|
||||
USER_LOG_ERROR("open usb device failed");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
@ -87,23 +95,44 @@ T_DjiReturnCode HalUsbBulk_Init(T_DjiHalUsbBulkInfo usbBulkInfo, T_DjiUsbBulkHan
|
||||
memcpy(&((T_HalUsbBulkObj *) *usbBulkHandle)->usbBulkInfo, &usbBulkInfo, sizeof(usbBulkInfo));
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->interfaceNum = usbBulkInfo.channelInfo.interfaceNum;
|
||||
|
||||
if (usbBulkInfo.channelInfo.interfaceNum == LINUX_USB_BULK1_INTERFACE_NUM) {
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep1 = open(LINUX_USB_BULK1_EP_OUT_FD, O_RDWR);
|
||||
if (DjiUserConfigManager_IsEnable()) {
|
||||
DjiUserConfigManager_GetLinkConfig(&linkConfig);
|
||||
usbBulk1InterfaceNum = linkConfig.usbBulkConfig.usbBulk1InterfaceNum;
|
||||
usbBulk2InterfaceNum = linkConfig.usbBulkConfig.usbBulk2InterfaceNum;
|
||||
snprintf(usbBulk1EpOutFd, sizeof(usbBulk1EpOutFd), "%s/ep1",
|
||||
linkConfig.usbBulkConfig.usbBulk1DeviceName);
|
||||
snprintf(usbBulk1EpInFd, sizeof(usbBulk1EpInFd), "%s/ep2",
|
||||
linkConfig.usbBulkConfig.usbBulk1DeviceName);
|
||||
snprintf(usbBulk2EpOutFd, sizeof(usbBulk2EpOutFd), "%s/ep1",
|
||||
linkConfig.usbBulkConfig.usbBulk2DeviceName);
|
||||
snprintf(usbBulk2EpInFd, sizeof(usbBulk2EpInFd), "%s/ep2",
|
||||
linkConfig.usbBulkConfig.usbBulk2DeviceName);
|
||||
} else {
|
||||
usbBulk1InterfaceNum = LINUX_USB_BULK1_INTERFACE_NUM;
|
||||
usbBulk2InterfaceNum = LINUX_USB_BULK2_INTERFACE_NUM;
|
||||
strcpy(usbBulk1EpInFd, LINUX_USB_BULK1_EP_IN_FD);
|
||||
strcpy(usbBulk1EpOutFd, LINUX_USB_BULK1_EP_OUT_FD);
|
||||
strcpy(usbBulk2EpInFd, LINUX_USB_BULK2_EP_IN_FD);
|
||||
strcpy(usbBulk2EpOutFd, LINUX_USB_BULK2_EP_OUT_FD);
|
||||
}
|
||||
|
||||
if (usbBulkInfo.channelInfo.interfaceNum == usbBulk1InterfaceNum) {
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep1 = open(usbBulk1EpOutFd, O_RDWR);
|
||||
if (((T_HalUsbBulkObj *) *usbBulkHandle)->ep1 < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 = open(LINUX_USB_BULK1_EP_IN_FD, O_RDWR);
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 = open(usbBulk1EpInFd, O_RDWR);
|
||||
if (((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
} else if (usbBulkInfo.channelInfo.interfaceNum == LINUX_USB_BULK2_INTERFACE_NUM) {
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep1 = open(LINUX_USB_BULK2_EP_OUT_FD, O_RDWR);
|
||||
} else if (usbBulkInfo.channelInfo.interfaceNum == usbBulk2InterfaceNum) {
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep1 = open(usbBulk2EpOutFd, O_RDWR);
|
||||
if (((T_HalUsbBulkObj *) *usbBulkHandle)->ep1 < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 = open(LINUX_USB_BULK2_EP_IN_FD, O_RDWR);
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 = open(usbBulk2EpInFd, O_RDWR);
|
||||
if (((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
@ -127,8 +156,9 @@ T_DjiReturnCode HalUsbBulk_DeInit(T_DjiUsbBulkHandle usbBulkHandle)
|
||||
|
||||
if (((T_HalUsbBulkObj *) usbBulkHandle)->usbBulkInfo.isUsbHost == true) {
|
||||
#ifdef LIBUSB_INSTALLED
|
||||
ret = libusb_release_interface(handle, ((T_HalUsbBulkObj *) usbBulkHandle)->usbBulkInfo.channelInfo.interfaceNum);
|
||||
if(ret != 0) {
|
||||
ret = libusb_release_interface(handle,
|
||||
((T_HalUsbBulkObj *) usbBulkHandle)->usbBulkInfo.channelInfo.interfaceNum);
|
||||
if (ret != 0) {
|
||||
USER_LOG_ERROR("release usb bulk interface failed, errno = %d", ret);
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
@ -151,7 +181,8 @@ T_DjiReturnCode HalUsbBulk_WriteData(T_DjiUsbBulkHandle usbBulkHandle, const uin
|
||||
int32_t actualLen;
|
||||
struct libusb_device_handle *handle = NULL;
|
||||
|
||||
if (usbBulkHandle == NULL) {
|
||||
if (usbBulkHandle == NULL)
|
||||
{
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
@ -208,19 +239,39 @@ T_DjiReturnCode HalUsbBulk_ReadData(T_DjiUsbBulkHandle usbBulkHandle, uint8_t *b
|
||||
|
||||
T_DjiReturnCode HalUsbBulk_GetDeviceInfo(T_DjiHalUsbBulkDeviceInfo *deviceInfo)
|
||||
{
|
||||
//attention: this interface only be called in usb device mode.
|
||||
deviceInfo->vid = LINUX_USB_VID;
|
||||
deviceInfo->pid = LINUX_USB_PID;
|
||||
T_DjiUserLinkConfig linkConfig = {0};
|
||||
|
||||
// This bulk channel is used to obtain DJI camera video stream and push 3rd-party camera video stream.
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_0].interfaceNum = LINUX_USB_BULK1_INTERFACE_NUM;
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_0].endPointIn = LINUX_USB_BULK1_END_POINT_IN;
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_0].endPointOut = LINUX_USB_BULK1_END_POINT_OUT;
|
||||
if (DjiUserConfigManager_IsEnable()) {
|
||||
DjiUserConfigManager_GetLinkConfig(&linkConfig);
|
||||
|
||||
// This bulk channel is used to obtain DJI perception image and download camera media file.
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_1].interfaceNum = LINUX_USB_BULK2_INTERFACE_NUM;
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_1].endPointIn = LINUX_USB_BULK2_END_POINT_IN;
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_1].endPointOut = LINUX_USB_BULK2_END_POINT_OUT;
|
||||
//attention: this interface only be called in usb device mode.
|
||||
deviceInfo->vid = linkConfig.usbBulkConfig.usbDeviceVid;
|
||||
deviceInfo->pid = linkConfig.usbBulkConfig.usbDevicePid;
|
||||
|
||||
// This bulk channel is used to obtain DJI camera video stream and push 3rd-party camera video stream.
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_0].interfaceNum = linkConfig.usbBulkConfig.usbBulk1InterfaceNum;
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_0].endPointIn = linkConfig.usbBulkConfig.usbBulk1EndpointIn;
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_0].endPointOut = linkConfig.usbBulkConfig.usbBulk1EndpointOut;
|
||||
|
||||
// This bulk channel is used to obtain DJI perception image and download camera media file.
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_1].interfaceNum = linkConfig.usbBulkConfig.usbBulk2InterfaceNum;
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_1].endPointIn = linkConfig.usbBulkConfig.usbBulk2EndpointIn;
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_1].endPointOut = linkConfig.usbBulkConfig.usbBulk2EndpointOut;
|
||||
} else {
|
||||
//attention: this interface only be called in usb device mode.
|
||||
deviceInfo->vid = LINUX_USB_VID;
|
||||
deviceInfo->pid = LINUX_USB_PID;
|
||||
|
||||
// This bulk channel is used to obtain DJI camera video stream and push 3rd-party camera video stream.
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_0].interfaceNum = LINUX_USB_BULK1_INTERFACE_NUM;
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_0].endPointIn = LINUX_USB_BULK1_END_POINT_IN;
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_0].endPointOut = LINUX_USB_BULK1_END_POINT_OUT;
|
||||
|
||||
// This bulk channel is used to obtain DJI perception image and download camera media file.
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_1].interfaceNum = LINUX_USB_BULK2_INTERFACE_NUM;
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_1].endPointIn = LINUX_USB_BULK2_END_POINT_IN;
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_1].endPointOut = LINUX_USB_BULK2_END_POINT_OUT;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@ -27,7 +27,8 @@ int CMainAcqThread::SetupContext()
|
||||
{
|
||||
m_ctrlConfigParser.SetFilePath("/home/data/Settings/MainSettings.ini");
|
||||
m_ctrlConfigParser.GetParams(m_struMiscCtrls,m_struM300RTKSs,m_struSensorPort);
|
||||
|
||||
m_ctrlVehicle.Initialize();
|
||||
m_ctrlVehicle.SetupEnvironment();
|
||||
#ifdef ZZ_FLAG_TEST
|
||||
qDebug() << m_struSensorPort.qstrGasSensorPort;
|
||||
qDebug() << m_struSensorPort.qstrWindSensorPort;
|
||||
@ -35,8 +36,8 @@ int CMainAcqThread::SetupContext()
|
||||
qDebug() << m_struM300RTKSs.qstrM300RTKSettingsFilePath;
|
||||
qDebug() << m_struM300RTKSs.qstrM300RTKWidgetFilePath;
|
||||
#endif
|
||||
|
||||
m_ctrlVehicle.SetupEnvironment_M300RTK();
|
||||
// m_ctrlVehicle.SetupEnvironment_M300RTK();
|
||||
m_ctrlVehicle.SetupEnvironment();
|
||||
SetupMessagePipe();
|
||||
return 0;
|
||||
}
|
||||
@ -45,9 +46,10 @@ int CMainAcqThread::StartUp()
|
||||
{
|
||||
///pump control
|
||||
system("sudo gpio mode 7 out");
|
||||
system("sudo gpio write 7 0");
|
||||
// m_ctrlVehicle.StartupPSDK_M300RTK();
|
||||
|
||||
m_ctrlVehicle.StartupPSDK_M300RTK();
|
||||
|
||||
m_ctrlVehicle.StartupPSDK_M350RTK();
|
||||
QString qstrMessage = "Initializing sensors,Please wait...";
|
||||
emit Signal_UpdateVehicleMessage(qstrMessage);
|
||||
|
||||
@ -141,10 +143,10 @@ int CMainAcqThread::FormFixedWindData()
|
||||
m_fTempFixedWindVecY = m_fTempFixedWindVecY - m_struM300RTKDataFrame.stVelocity.y;
|
||||
m_fTempFixedWindVecZ = m_fTempFixedWindVecZ - m_struM300RTKDataFrame.stVelocity.z;
|
||||
|
||||
double dDotProduct = m_fTempFixedWindVecX; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
double dVectorLength = sqrt(m_fTempFixedWindVecX * m_fTempFixedWindVecX + m_fTempFixedWindVecY * m_fTempFixedWindVecY + m_fTempFixedWindVecZ * m_fTempFixedWindVecZ); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
||||
double dAngleInRadians = acos(dDotProduct / dVectorLength); // <20><><EFBFBD><EFBFBD><EFBFBD>нǵĻ<EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
double angleInDegrees = dAngleInRadians * (180.0 / M_PI); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
||||
double dDotProduct = m_fTempFixedWindVecX; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
double dVectorLength = sqrt(m_fTempFixedWindVecX * m_fTempFixedWindVecX + m_fTempFixedWindVecY * m_fTempFixedWindVecY + m_fTempFixedWindVecZ * m_fTempFixedWindVecZ); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
||||
double dAngleInRadians = acos(dDotProduct / dVectorLength); // <20><><EFBFBD><EFBFBD>нǵĻ<C7B5><C4BB><EFBFBD>ֵ
|
||||
double angleInDegrees = dAngleInRadians * (180.0 / M_PI); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
||||
|
||||
m_struUASDataFrame.fFixedWindDirection = angleInDegrees;
|
||||
m_struUASDataFrame.fFixedWindSpeed = dVectorLength;
|
||||
@ -198,7 +200,7 @@ int CMainAcqThread::GetData()
|
||||
m_struUASDataFrame.fWindSpeed = fSpeed;
|
||||
m_struUASDataFrame.fWindTemperature = fWindTemp;
|
||||
|
||||
m_ctrlVehicle.GetOneDataFrame(m_struM300RTKDataFrame);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_ctrlVehicle.GetOneDataFrame(m_struM300RTKDataFrame);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
int CMainAcqThread::OnTimerCapture()
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
#include "DataFileManager.h"
|
||||
#include "MainConfigParser.h"
|
||||
|
||||
using namespace ZZ_DATA_DEF::M300RTK;
|
||||
using namespace ZZ_DATA_DEF::DJI;
|
||||
using namespace ZZ_DATA_DEF::CO2_GAS_SENSOR;
|
||||
using namespace ZZ_DATA_DEF::UA_SENSOR;
|
||||
using namespace ZZ_DATA_DEF::MainConfig;
|
||||
@ -35,7 +35,7 @@ private:
|
||||
M300RTKSettings m_struM300RTKSs;
|
||||
SensorPort m_struSensorPort;
|
||||
|
||||
M300RTKDataFrame m_struM300RTKDataFrame;
|
||||
M350RTKDataFrame m_struM300RTKDataFrame;
|
||||
GSDataFrame m_struGSDataFrame;
|
||||
UASDataFrame m_struUASDataFrame;
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
namespace ZZ_DATA_DEF
|
||||
{
|
||||
namespace M300RTK
|
||||
namespace DJI
|
||||
{
|
||||
typedef struct tagVector3f
|
||||
{
|
||||
@ -36,10 +36,10 @@ namespace ZZ_DATA_DEF
|
||||
|
||||
typedef struct tagM300RTKDataFrame
|
||||
{
|
||||
// ZZ_U32 usExposureTimeInMS;
|
||||
// ZZ_S32 lData[4096];
|
||||
// float fTemperature = 0;
|
||||
// double dTimes = 0;
|
||||
// ZZ_U32 usExposureTimeInMS;
|
||||
// ZZ_S32 lData[4096];
|
||||
// float fTemperature = 0;
|
||||
// double dTimes = 0;
|
||||
ZZVector3d stGPSPosition = { 0 };
|
||||
ZZVector3f stVelocity = { 0 };
|
||||
ZZQuaternion stQuaternion = { 0 };
|
||||
@ -47,10 +47,69 @@ namespace ZZ_DATA_DEF
|
||||
ZZDegOrientation stEulerAngle = { 0 };
|
||||
}M300RTKDataFrame;
|
||||
|
||||
typedef struct tagM350RTKDataFrame
|
||||
{
|
||||
// ZZ_U32 usExposureTimeInMS;
|
||||
// ZZ_S32 lData[4096];
|
||||
// float fTemperature = 0;
|
||||
// double dTimes = 0;
|
||||
ZZVector3d stGPSPosition = { 0 };
|
||||
ZZVector3f stVelocity = { 0 };
|
||||
ZZQuaternion stQuaternion = { 0 };
|
||||
float fAltitudeFused;
|
||||
ZZDegOrientation stEulerAngle = { 0 };
|
||||
}M350RTKDataFrame;
|
||||
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
// namespace M300RTK
|
||||
// {
|
||||
// typedef struct tagVector3f
|
||||
// {
|
||||
// float x; /*!< Specifies float value of x for vector. */
|
||||
// float y; /*!< Specifies float value of y for vector. */
|
||||
// float z; /*!< Specifies float value of z for vector. */
|
||||
// }ZZVector3f;
|
||||
//
|
||||
//
|
||||
// typedef struct tagVector3d {
|
||||
// int32_t x; /*!< Specifies int32 value of x for vector. */
|
||||
// int32_t y; /*!< Specifies int32 value of y for vector. */
|
||||
// int32_t z; /*!< Specifies int32 value of z for vector. */
|
||||
// } ZZVector3d;
|
||||
//
|
||||
// typedef struct tagDegOrientation
|
||||
// {
|
||||
// float roll;
|
||||
// float pitch;
|
||||
// float yaw;
|
||||
// }ZZDegOrientation;
|
||||
//
|
||||
// typedef struct tagQuaternion
|
||||
// {
|
||||
// float w_q0;
|
||||
// float x_q1;
|
||||
// float y_q2;
|
||||
// float z_q3;
|
||||
// }ZZQuaternion;
|
||||
//
|
||||
// typedef struct tagM300RTKDataFrame
|
||||
// {
|
||||
// // ZZ_U32 usExposureTimeInMS;
|
||||
// // ZZ_S32 lData[4096];
|
||||
// // float fTemperature = 0;
|
||||
// // double dTimes = 0;
|
||||
// ZZVector3d stGPSPosition = { 0 };
|
||||
// ZZVector3f stVelocity = { 0 };
|
||||
// ZZQuaternion stQuaternion = { 0 };
|
||||
// float fAltitudeFused;
|
||||
// ZZDegOrientation stEulerAngle = { 0 };
|
||||
// }M300RTKDataFrame;
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// };
|
||||
|
||||
namespace CO2_GAS_SENSOR
|
||||
{
|
||||
|
||||
171
mountdjirndis.sh
Normal file
171
mountdjirndis.sh
Normal file
@ -0,0 +1,171 @@
|
||||
#!/bin/bash
|
||||
apt install -y bridge-utils
|
||||
# The IP address shared by the USB network interface creatoedd by this script.
|
||||
NET_IP="192.168.55.1"
|
||||
# The associated netmask.
|
||||
NET_MASK="255.255.0.0"
|
||||
|
||||
# 定义USB Gadget的根目录,使用官网脚本的通用名称 "pi4"
|
||||
GADGET_NAME="pi4"
|
||||
GADGET_ROOT="/sys/kernel/config/usb_gadget/${GADGET_NAME}"
|
||||
|
||||
# --- UDC DEVICE 提示 ---
|
||||
# 通常 Raspberry Pi (或类似SoC) 的 dwc2/ci_hdrc 等驱动会自动作为 UDC 设备出现。
|
||||
# 官网脚本在绑定时直接使用 'UDC' 文件,不需要显式指定 UDC_DEVICE 变量。
|
||||
# 系统会自动查找可用的 UDC 设备进行绑定。
|
||||
|
||||
# 确保脚本以root权限运行
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "This script must be run as root. Please run with 'sudo'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "--------------------------------------"
|
||||
echo "Configuring USB Gadget for RNDIS ONLY."
|
||||
echo "--------------------------------------"
|
||||
|
||||
|
||||
|
||||
# 1. 检查RNDIS所需的内核模块并确保 g_ether 未加载
|
||||
echo "Checking and ensuring 'g_mass_storage' and 'g_ether' are not loaded, then loading 'libcomposite'..."
|
||||
|
||||
# 卸载 g_mass_storage
|
||||
if lsmod | grep -q g_mass_storage; then
|
||||
echo "Unloading g_mass_storage module..."
|
||||
modprobe -r g_mass_storage || { echo "WARNING: Failed to unload g_mass_storage. This might cause issues."; }
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
# 卸载 g_ether
|
||||
if lsmod | grep -q g_ether; then
|
||||
echo "Unloading g_ether module..."
|
||||
modprobe -r g_ether || { echo "WARNING: Failed to unload g_ether. This might cause issues."; }
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
# libcomposite 是 gadget 框架的基础
|
||||
if ! lsmod | grep -q libcomposite; then
|
||||
echo "Loading libcomposite module..."
|
||||
modprobe libcomposite || { echo "ERROR: Failed to load libcomposite. Exiting."; exit 1; }
|
||||
fi
|
||||
|
||||
# 2. 卸载并清理旧的 gadget 配置 (可选,但推荐在测试时使用以确保干净状态)
|
||||
if [ -d "${GADGET_ROOT}" ]; then
|
||||
echo "Disabling existing gadget '${GADGET_NAME}'..."
|
||||
# 尝试解绑当前的 UDC (如果已经绑定)
|
||||
if [ -f "${GADGET_ROOT}/UDC" ]; then
|
||||
current_udc=$(cat "${GADGET_ROOT}/UDC")
|
||||
if [ -n "$current_udc" ]; then
|
||||
echo "Unbinding ${current_udc} from previous gadget..."
|
||||
echo "" > "${GADGET_ROOT}/UDC" # 解绑 UDC
|
||||
sleep 1
|
||||
fi
|
||||
fi
|
||||
rm -rf "${GADGET_ROOT}" # 删除所有旧的配置
|
||||
echo "Old gadget configuration removed."
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
# 3. 创建新的 gadget 配置
|
||||
echo "Creating new gadget configuration at ${GADGET_ROOT}..."
|
||||
mkdir -p "${GADGET_ROOT}"
|
||||
cd "${GADGET_ROOT}" || { echo "ERROR: Failed to cd to ${GADGET_ROOT}. Exiting."; exit 1; }
|
||||
|
||||
# 4. 设置设备描述符 (参考官网脚本的值)
|
||||
echo "Setting device descriptors..."
|
||||
echo 0x0955 > idVendor # Linux Foundation (官网脚本值)
|
||||
echo 0x7020 > idProduct # Multifunction Composite Gadget (官网脚本中 RNDIS 启用时使用的值)
|
||||
echo 0x0001 > bcdDevice # v1.0.0
|
||||
echo 0x0200 > bcdUSB # USB2
|
||||
|
||||
echo 0xEF > bDeviceClass # Miscellaneous Device Class
|
||||
echo 0x02 > bDeviceSubClass # Common Class
|
||||
echo 0x01 > bDeviceProtocol # Interface Association Descriptor (IAD)
|
||||
|
||||
# 5. 设置字符串描述符 (参考官网脚本的值)
|
||||
echo "Setting string descriptors (Manufacturer, Product, Serial)..."
|
||||
mkdir -p strings/0x409 # English (0x409)
|
||||
|
||||
echo "NVIDIA" > strings/0x409/manufacturer
|
||||
echo "Linux for Tegra" > strings/0x409/product
|
||||
cat /proc/device-tree/serial-number > strings/0x409/serialnumber
|
||||
|
||||
# 6. 创建配置 c.1
|
||||
echo "Creating configuration 'c.1'..."
|
||||
cfg="configs/c.1"
|
||||
mkdir -p "${cfg}/strings/0x409"
|
||||
echo 0x80 > "${cfg}/bmAttributes" # Self-powered
|
||||
echo 250 > "${cfg}/MaxPower" # Max power consumption (250mA)
|
||||
echo "RNDIS" > "${cfg}/strings/0x409/configuration" # Configuration description
|
||||
|
||||
# 7. 配置 RNDIS 功能
|
||||
echo "Enabling RNDIS function (rndis.usb0)..."
|
||||
func_rndis="functions/rndis.usb0"
|
||||
mkdir -p "${func_rndis}"
|
||||
ln -sf "${func_rndis}" "${cfg}" # Link RNDIS function to configuration c.1
|
||||
|
||||
# RNDIS OS Descriptors for Windows auto-detection (参考官网脚本的值)
|
||||
echo "Setting RNDIS OS Descriptors..."
|
||||
echo 1 > os_desc/use
|
||||
echo 0xcd > os_desc/b_vendor_code
|
||||
echo MSFT100 > os_desc/qw_sign
|
||||
echo "RNDIS" > "${func_rndis}/os_desc/interface.rndis/compatible_id"
|
||||
echo "5162001" > "${func_rndis}/os_desc/interface.rndis/sub_compatible_id"
|
||||
ln -sf "${cfg}" os_desc
|
||||
|
||||
# 8. 绑定到 UDC 以激活 Gadget
|
||||
echo "Activating USB Gadget..."
|
||||
# 使用 udevadm settle 确保所有设备节点都已创建
|
||||
udevadm settle -t 5 || :
|
||||
# 直接将可用的 UDC 设备名称写入 UDC 文件。
|
||||
# 如果系统有多个 UDC,通常会选择第一个可用的。
|
||||
# 官网脚本也是直接 'ls /sys/class/udc > UDC' 来完成。
|
||||
UDC_LIST=$(ls /sys/class/udc)
|
||||
if [ -z "$UDC_LIST" ]; then
|
||||
echo "ERROR: No USB Device Controller (UDC) found in /sys/class/udc/. Cannot activate gadget."
|
||||
exit 1
|
||||
fi
|
||||
echo "${UDC_LIST%% *}" > UDC # 取第一个 UDC 设备名称
|
||||
echo "USB Gadget successfully activated on ${UDC_LIST%% *}."
|
||||
|
||||
# 9. 配置 RNDIS 网络接口
|
||||
echo "Configuring RNDIS network interface (usb0)..."
|
||||
|
||||
# 等待 usb0 接口出现
|
||||
echo "Waiting for 'usb0' interface to appear..."
|
||||
interface_ready=0
|
||||
for i in $(seq 1 15); do # 等待最多15秒,给系统更多时间
|
||||
if ip link show usb0 &> /dev/null; then
|
||||
echo "'usb0' interface found."
|
||||
interface_ready=1
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ "$interface_ready" -eq 0 ]; then
|
||||
echo "ERROR: 'usb0' interface did not appear after 15 seconds. RNDIS network configuration failed."
|
||||
echo " Check kernel modules ('libcomposite' and 'usb_f_rndis' which is part of g_ether function) and dmesg for errors."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 清理旧的桥接设备 (如果存在)
|
||||
if ip link show pi4br0 &> /dev/null; then
|
||||
echo "Removing existing bridge 'pi4br0'..."
|
||||
brctl delbr pi4br0
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
/sbin/brctl addbr pi4br0 # 创建一个名为 pi4br0 的网络桥接
|
||||
/sbin/ifconfig pi4br0 "${NET_IP}" netmask "${NET_MASK}" up # 配置桥接接口的IP地址
|
||||
/sbin/brctl addif pi4br0 usb0 # 将 RNDIS 接口 usb0 添加到桥接
|
||||
/sbin/ifconfig usb0 up # 确保 usb0 接口被激活
|
||||
|
||||
echo "RNDIS network configured to ${NET_IP} on 'pi4br0' (bridging 'usb0')."
|
||||
|
||||
echo "--------------------------------------"
|
||||
echo "USB Gadget RNDIS setup complete."
|
||||
echo "Connect your device to a PC."
|
||||
echo "--------------------------------------"
|
||||
|
||||
exit 0
|
||||
159
mountrndis.sh
Normal file
159
mountrndis.sh
Normal file
@ -0,0 +1,159 @@
|
||||
#!/bin/bash
|
||||
apt-get install bridge-utils
|
||||
rmmod g_mass_storage
|
||||
|
||||
|
||||
# 定义USB Gadget的根目录
|
||||
GADGET_ROOT="/sys/kernel/config/usb_gadget/nanopi"
|
||||
|
||||
# *** 重要:请根据你的实际情况修改这个值! ***
|
||||
# 你可以通过运行 'ls /sys/class/udc/' 命令来查看可用的 UDC 设备名称。
|
||||
# 常见的名称有:musb-hdrc.0, musb-hdrc.4.auto, ci_hdrc.0, 20a00000.usb
|
||||
UDC_DEVICE="musb-hdrc.4.auto"
|
||||
|
||||
# 确保脚本以root权限运行
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "This script must be run as root. Please run with 'sudo'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "--------------------------------------"
|
||||
echo "Configuring USB Gadget for RNDIS Only"
|
||||
echo "--------------------------------------"
|
||||
|
||||
# 1. 卸载并清理旧的 gadget 配置 (可选,但推荐在测试时使用以确保干净状态)
|
||||
if [ -d "${GADGET_ROOT}" ]; then
|
||||
echo "Disabling existing gadget '${GADGET_ROOT##*/}'..."
|
||||
# 尝试解绑当前的 UDC (如果已经绑定)
|
||||
# 这需要先进入 gadget 目录,然后才能 echo "" > UDC
|
||||
if [ -f "${GADGET_ROOT}/UDC" ]; then
|
||||
current_udc=$(cat "${GADGET_ROOT}/UDC")
|
||||
if [ -n "$current_udc" ]; then
|
||||
echo "Unbinding ${current_udc} from previous gadget..."
|
||||
echo "" > "${GADGET_ROOT}/UDC" # 解绑 UDC
|
||||
sleep 1
|
||||
fi
|
||||
fi
|
||||
rm -rf "${GADGET_ROOT}" # 删除所有旧的配置
|
||||
echo "Old gadget configuration removed."
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
# 2. 进入 gadget 根目录并创建
|
||||
echo "Creating new gadget configuration at ${GADGET_ROOT}..."
|
||||
mkdir -p "${GADGET_ROOT}"
|
||||
cd "${GADGET_ROOT}" || { echo "ERROR: Failed to cd to ${GADGET_ROOT}. Exiting."; exit 1; }
|
||||
|
||||
# 3. 设置设备描述符
|
||||
echo "Setting device descriptors..."
|
||||
echo 0x0955 > idVendor # FriendlyElec's Vendor ID (or your preferred)
|
||||
echo 0x7020 > idProduct # Product ID for NanoPi-NEO-Core (or your preferred)
|
||||
echo 0x0100 > bcdDevice # Device Version 1.0 (0x0100)
|
||||
echo 0x0200 > bcdUSB # USB 2.0 (0x0200)
|
||||
|
||||
# RNDIS 复合设备通常使用特定的设备类/子类/协议
|
||||
echo 0xEF > bDeviceClass # Miscellaneous Device Class
|
||||
echo 0x02 > bDeviceSubClass # Common Class
|
||||
echo 0x01 > bDeviceProtocol # Interface Association Descriptor (IAD)
|
||||
|
||||
# 4. 设置字符串描述符
|
||||
echo "Setting string descriptors (Manufacturer, Product, Serial)..."
|
||||
mkdir -p strings/0x409 # English (0x409)
|
||||
|
||||
# 获取设备树中的序列号,如果没有则使用默认值
|
||||
if [ -f /proc/device-tree/serial-number ]; then
|
||||
serialnumber="$(cat /proc/device-tree/serial-number|tr -d '\000')"
|
||||
else
|
||||
serialnumber="1234567890ABCD" # Default serial number
|
||||
fi
|
||||
echo "${serialnumber}" > strings/0x409/serialnumber
|
||||
echo "FriendlyElec" > strings/0x409/manufacturer
|
||||
echo "NanoPi-NEO-Core" > strings/0x409/product
|
||||
|
||||
# 5. 创建配置 c.1
|
||||
echo "Creating configuration 'c.1'..."
|
||||
cfg="configs/c.1"
|
||||
mkdir -p "${cfg}/strings/0x409"
|
||||
echo 0x80 > "${cfg}/bmAttributes" # Self-powered
|
||||
echo 250 > "${cfg}/MaxPower" # Max power consumption (250mA)
|
||||
echo "RNDIS Ethernet" > "${cfg}/strings/0x409/configuration" # Configuration description
|
||||
|
||||
# 6. 配置 RNDIS 功能
|
||||
echo "Enabling RNDIS function (rndis.usb0)..."
|
||||
func_rndis="functions/rndis.usb0"
|
||||
mkdir -p "${func_rndis}"
|
||||
ln -sf "${func_rndis}" "${cfg}" # Link RNDIS function to configuration c.1
|
||||
|
||||
# RNDIS OS Descriptors for Windows auto-detection
|
||||
echo "Setting RNDIS OS Descriptors..."
|
||||
echo 1 > os_desc/use
|
||||
echo 0xcd > os_desc/b_vendor_code
|
||||
echo MSFT100 > os_desc/qw_sign
|
||||
echo "RNDIS" > "${func_rndis}/os_desc/interface.rndis/compatible_id"
|
||||
echo "5162001" > "${func_rndis}/os_desc/interface.rndis/sub_compatible_id"
|
||||
ln -sf "${cfg}" os_desc # Link configuration c.1 to os_desc
|
||||
|
||||
# 7. 绑定到 UDC 以激活 Gadget
|
||||
echo "Activating USB Gadget on UDC: ${UDC_DEVICE}..."
|
||||
# Check if UDC device exists in /sys/class/udc/
|
||||
if [ -e "/sys/class/udc/${UDC_DEVICE}" ]; then
|
||||
echo "${UDC_DEVICE}" > UDC
|
||||
echo "USB Gadget successfully activated."
|
||||
else
|
||||
echo "ERROR: UDC device '${UDC_DEVICE}' not found in /sys/class/udc/."
|
||||
echo " Please check your UDC_DEVICE variable and 'ls /sys/class/udc/' output."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 8. 配置 RNDIS 网络接口
|
||||
echo "Configuring RNDIS network interface (usb0)..."
|
||||
NET_IP="192.168.55.1"
|
||||
NET_MASK="255.255.255.0"
|
||||
|
||||
# 等待 usb0 接口出现
|
||||
echo "Waiting for 'usb0' interface to appear..."
|
||||
interface_ready=0
|
||||
for i in $(seq 1 10); do # 等待最多10秒
|
||||
if ip link show usb0 &> /dev/null; then
|
||||
echo "'usb0' interface found."
|
||||
interface_ready=1
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ "$interface_ready" -eq 0 ]; then
|
||||
echo "ERROR: 'usb0' interface did not appear after 10 seconds. RNDIS network configuration failed."
|
||||
echo " Check kernel modules (g_ether, usb_f_rndis) and dmesg for errors."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查并安装 bridge-utils (如果需要)
|
||||
if ! command -v brctl &> /dev/null; then
|
||||
echo "WARNING: 'brctl' command not found. Please install 'bridge-utils' package."
|
||||
echo " (e.g., 'sudo apt install bridge-utils' on Debian/Ubuntu)"
|
||||
# 如果没有 brctl,尝试直接配置 usb0 接口,但不推荐
|
||||
echo "Attempting to configure 'usb0' directly (without bridge)..."
|
||||
ifconfig usb0 "${NET_IP}" netmask "${NET_MASK}" up
|
||||
echo "RNDIS network configured to ${NET_IP} on usb0 directly."
|
||||
else
|
||||
# 清理旧的桥接设备 (如果存在)
|
||||
if ip link show zzbr0 &> /dev/null; then
|
||||
echo "Removing existing bridge 'zzbr0'..."
|
||||
brctl delbr zzbr0
|
||||
fi
|
||||
|
||||
brctl addbr zzbr0 # 创建一个名为 zzbr0 的网络桥接
|
||||
ifconfig zzbr0 "${NET_IP}" netmask "${NET_MASK}" up # 配置桥接接口的IP地址
|
||||
brctl addif zzbr0 usb0 # 将 RNDIS 接口 usb0 添加到桥接
|
||||
ifconfig usb0 up # 确保 usb0 接口被激活
|
||||
|
||||
echo "RNDIS network configured to ${NET_IP} on 'zzbr0' (bridging 'usb0')."
|
||||
fi
|
||||
|
||||
echo "--------------------------------------"
|
||||
echo "USB Gadget RNDIS setup complete."
|
||||
echo "Connect your device to a PC."
|
||||
echo "--------------------------------------"
|
||||
|
||||
exit 0
|
||||
109
rasp.sh
Normal file
109
rasp.sh
Normal file
@ -0,0 +1,109 @@
|
||||
#!/bin/bash
|
||||
|
||||
# The IP address shared by all USB network interfaces created by this script.
|
||||
net_ip=192.168.42.120
|
||||
# The associated netmask.
|
||||
net_mask=255.255.0.0
|
||||
|
||||
enable_vcom=0
|
||||
enable_rndis=1
|
||||
enable_bulk=0
|
||||
|
||||
startup_bulk_dir=$(dirname "$0")
|
||||
startup_bulk_exe=${startup_bulk_dir}/build/startup_bulk
|
||||
#
|
||||
#if [ ! -d /sys/kernel/config/usb_gadget ]; then
|
||||
# if ! $(grep -q dtoverlay=dwc2 /boot/config.txt) ; then
|
||||
# echo -e "\n\n\n## customized\n# for op-sdk enable USB device RNDIS\n[all]\ndtoverlay=dwc2" >> /boot/config.txt
|
||||
# init 6
|
||||
# fi
|
||||
#
|
||||
# if ! $(grep -q modules-load=dwc2 /boot/cmdline.txt) ; then
|
||||
# sed -i 's/rootwait /&modules-load=dwc2 /' /boot/cmdline.txt
|
||||
# init 6
|
||||
# fi
|
||||
#
|
||||
# if ! $(grep -q libcomposite /etc/modules) ; then
|
||||
# echo -e "\n\n\n## customized\n# for op-sdk enable USB device RNDIS\nlibcomposite" >> /etc/modules
|
||||
# init 6
|
||||
# fi
|
||||
#
|
||||
# exit 1
|
||||
#fi
|
||||
|
||||
|
||||
rmmod g_mass_storage
|
||||
sleep 1
|
||||
|
||||
if [ ! -d /sys/kernel/config/usb_gadget/pi4 ]; then
|
||||
mkdir -p /sys/kernel/config/usb_gadget/pi4
|
||||
cd /sys/kernel/config/usb_gadget/pi4
|
||||
echo 0x2ca3 > idVendor # Linux Foundation
|
||||
echo 0xF001 > idProduct # Multifunction Composite Gadget
|
||||
|
||||
if [ ${enable_vcom} -eq 1 ]; then
|
||||
echo 0xF002 > idProduct # Multifunction Composite Gadget
|
||||
fi
|
||||
|
||||
if [ ${enable_rndis} -eq 1 ]; then
|
||||
echo 0xF003 > idProduct # Multifunction Composite Gadget
|
||||
fi
|
||||
|
||||
if [ ${enable_bulk} -eq 1 ]; then
|
||||
echo 0xF001 > idProduct # Multifunction Composite Gadget
|
||||
fi
|
||||
|
||||
echo 0x0001 > bcdDevice # v1.0.0
|
||||
echo 0x0200 > bcdUSB # USB2
|
||||
|
||||
echo 0xEF > bDeviceClass
|
||||
echo 0x02 > bDeviceSubClass
|
||||
echo 0x01 > bDeviceProtocol
|
||||
|
||||
mkdir -p strings/0x409
|
||||
echo "psdk-rpi4b" > strings/0x409/serialnumber
|
||||
echo "raspberry" > strings/0x409/manufacturer
|
||||
echo "PI4" > strings/0x409/product
|
||||
|
||||
cfg=configs/c.1
|
||||
|
||||
mkdir -p "${cfg}"
|
||||
echo 0x80 > ${cfg}/bmAttributes
|
||||
echo 250 > ${cfg}/MaxPower
|
||||
|
||||
cfg_str=""
|
||||
|
||||
if [ ${enable_rndis} -eq 1 ]; then
|
||||
cfg_str="${cfg_str}+RNDIS"
|
||||
func=functions/rndis.usb0
|
||||
mkdir -p "${func}"
|
||||
ln -sf "${func}" "${cfg}"
|
||||
|
||||
# Informs Windows that this device is compatible with the built-in RNDIS
|
||||
# driver. This allows automatic driver installation without any need for
|
||||
# a .inf file or manual driver selection.
|
||||
echo 1 > os_desc/use
|
||||
echo 0xcd > os_desc/b_vendor_code
|
||||
echo MSFT100 > os_desc/qw_sign
|
||||
echo RNDIS > "${func}/os_desc/interface.rndis/compatible_id"
|
||||
echo 5162001 > "${func}/os_desc/interface.rndis/sub_compatible_id"
|
||||
|
||||
ln -sf "${cfg}" os_desc
|
||||
fi
|
||||
mkdir -p "${cfg}/strings/0x409"
|
||||
echo "${cfg_str:1}" > "${cfg}/strings/0x409/configuration"
|
||||
# cd -
|
||||
|
||||
fi
|
||||
udevadm settle -t 5 || :
|
||||
ls /sys/class/udc > UDC
|
||||
|
||||
if [ ${enable_rndis} -eq 1 ]; then
|
||||
/sbin/brctl addbr pi4br0
|
||||
/sbin/ifconfig pi4br0 ${net_ip} netmask ${net_mask} up
|
||||
|
||||
/sbin/brctl addif pi4br0 usb0
|
||||
/sbin/ifconfig usb0 down
|
||||
/sbin/ifconfig usb0 up
|
||||
fi
|
||||
exit 0
|
||||
Reference in New Issue
Block a user