M350b版本
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
#include "ConfigParser_M300RTK.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////M300
|
||||
ZZ_ConfigParser_M300RTK::ZZ_ConfigParser_M300RTK(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_bInit = false;
|
||||
@ -92,7 +93,7 @@ int ZZ_ConfigParser_M300RTK::Initialize(QString qstrConfigFolderPath)
|
||||
}
|
||||
++i;
|
||||
} while (i < qfList.size());
|
||||
|
||||
|
||||
if (j != 3)
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M300:Func Initialize. File count not match";
|
||||
@ -198,6 +199,183 @@ int ZZ_ConfigParser_M300RTK::LoadParams()
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////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::UartAndNetwork)
|
||||
//
|
||||
// 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*/ 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user