M350b版本
This commit is contained in:
@ -62,7 +62,7 @@ int DataFileManager::GenerateFile()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DataFileManager::WriteData(M350RTKDataFrame struM300RTKDataFrame, GSDataFrame struGSDataFrame, UASDataFrame struUASDataFrame)
|
||||
int DataFileManager::WriteData(M300RTKDataFrame struM300RTKDataFrame, GSDataFrame struGSDataFrame, UASDataFrame struUASDataFrame)
|
||||
{
|
||||
// QFile qfData(m_qstrFullFileName);
|
||||
// bool bRes = qfData.open(QFile::WriteOnly | QFile::Text | QIODevice::Append);
|
||||
|
||||
@ -16,7 +16,7 @@ public:
|
||||
public:
|
||||
void GenerateFilePath();
|
||||
int GenerateFile();
|
||||
int WriteData(M350RTKDataFrame struM300RTKDataFrame,GSDataFrame struGSDataFrame,UASDataFrame struUASDataFrame);
|
||||
int WriteData(M300RTKDataFrame struM300RTKDataFrame,GSDataFrame struGSDataFrame,UASDataFrame struUASDataFrame);
|
||||
int CloseData();
|
||||
private:
|
||||
|
||||
|
||||
@ -96,6 +96,8 @@ int IrisSensor_Gas_P0::ParseMeasuredData_Chk()
|
||||
else
|
||||
{
|
||||
unsigned char uc12, uc13, uc14, uc15, uc16,uc17,uc18,uc19,uc28,uc29,uc30,uc31,uc32, uc33;
|
||||
char aaaa[34];
|
||||
memcpy(aaaa,m_sRecv.c_str(),m_sRecv.size());
|
||||
|
||||
uc32 = m_sRecv[32];
|
||||
uc33 = m_sRecv[33];
|
||||
@ -199,6 +201,9 @@ int IrisSensor_Gas_P0::ZeroCalibration_N2()
|
||||
qbSend.append((const char) 0x00);
|
||||
qbSend.append((unsigned char)0xfa); //chksum
|
||||
|
||||
SendData_Chk(qbSend.toStdString());
|
||||
|
||||
qDebug()<<"finish zero calirbation n2";
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -213,6 +218,8 @@ int IrisSensor_Gas_P0::ZeroCalibration_Air()
|
||||
qbSend.append((unsigned char)0xf9); //chksum
|
||||
|
||||
SendData_Chk(qbSend.toStdString());
|
||||
|
||||
qDebug()<<"finish zero calirbation air";
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -285,3 +292,4 @@ int IrisSensor_Gas_P0::StopAutoSending()
|
||||
int iRes = SendData_Chk(qbSend.toStdString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -31,5 +31,6 @@ public:
|
||||
int SpanCalibration(char cChannel, unsigned int uiPPM);
|
||||
int ResetCalibration(char cChannel);//FF means all channel
|
||||
int StopAutoSending();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -176,3 +176,16 @@ int IrisSensor_WDA_P0::GetSA_NChk(float &fSpeed, float &fAngle,float& fTemp)
|
||||
fTemp = m_fWindTemp;
|
||||
return 0;
|
||||
}
|
||||
int IrisSensor_WDA_P0::CalibrateWDA(double dTemperature)
|
||||
{
|
||||
if (!m_pSerialPort || !m_pSerialPort->isOpen())
|
||||
{
|
||||
qDebug() << "Err:CalibrateCO2 - Serial port not open.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 调用WDACalibration类执行校正
|
||||
return m_calibration.ExecuteCalibration(m_pSerialPort, dTemperature);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include "WDACalibration.h"
|
||||
class IrisSensor_WDA_P0
|
||||
{
|
||||
public:
|
||||
@ -19,9 +20,11 @@ private:
|
||||
int SendData_NChk(std::string sSend);
|
||||
int RecvData_NChk(/*std::string sRecv*/);
|
||||
int ParseData_NChk();
|
||||
WDACalibration m_calibration;
|
||||
public:
|
||||
int Initialize(std::string sPortNumber);
|
||||
int GetSA_NChk(float &fSpeed,float &fAngle,float& fTemp);
|
||||
int CalibrateWDA(double dTemperature);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
#include "ConfigParser_M300RTK.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////M300
|
||||
ZZ_ConfigParser_M300RTK::ZZ_ConfigParser_M300RTK(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_bInit = false;
|
||||
@ -202,180 +201,3 @@ 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,36 +1,10 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#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);
|
||||
};
|
||||
|
||||
|
||||
using namespace ZZ::Device::DJI::M300RTK;
|
||||
#define CONFIG_HARDWARE_CONNECTION DJI_USE_ONLY_NETWORK_DEVICE
|
||||
class ZZ_ConfigParser_M300RTK :public QObject
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
ZZ_ConfigParser_M300RTK(QObject* parent = nullptr);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[DJI]
|
||||
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
|
||||
USER_APP_NAME=M400device
|
||||
USER_APP_ID=176035
|
||||
USER_APP_KEY=4889bbeb0092089889b4f3180167202
|
||||
USER_APP_LICENSE=VVfdaxQA6j5aX6zy/C6S2PFoSUqdcj5PeQ1GG8aRMuy+SegA1y9iYtQLOLu7CprNwwBN6X6wdwzSn8lOHJuXb6TfvRsakVCsXQ6A9qWmBB8IKzAKcQ60EJlZ71h5cLthXzNNq1ERQpBM5w9b+FebKF29XzozZCF2ZYWSgoGb/nEWxlm23Gp0EB3ZwbP31yRyLQUCY3iDdLYByOe3xSGLtJOlu3OJuujzY80T3eqWonwYsl4Hb4hWJODXJYWzLGFA1irjVJdle//7WZ0F17fEo/xGgPb7W36twDU80QFfpwagEqtacoo6bp+qij6Db10wF9Z8VWlAkY+59lLbyV3gnw==
|
||||
USER_DEVELOPER_ACCOUNT=rlxlixin1@163.com
|
||||
|
||||
@ -14,13 +14,13 @@
|
||||
#include "hal_network.h"
|
||||
|
||||
#include "time.h"
|
||||
//#include "ZZ_Types_M300.h"
|
||||
#include "ZZ_Types_DJI.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))
|
||||
|
||||
#include "dji_low_speed_data_channel.h"
|
||||
#include "dji_high_speed_data_channel.h"
|
||||
int VehicleController::m_siFlagIsPumpWorking = 0;
|
||||
int VehicleController::m_siFlagIsStartCaptureSignalEmitted = 0;
|
||||
VehicleController* VehicleController::spCaller = NULL;
|
||||
@ -34,7 +34,7 @@ VehicleController::VehicleController(QObject* parent /*= nullptr*/)
|
||||
|
||||
m_fHeightOfHomePoint_BM = -1;
|
||||
//m_cCaptureMode = 0;
|
||||
|
||||
|
||||
}
|
||||
VehicleController::~VehicleController()
|
||||
{
|
||||
@ -50,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;
|
||||
}
|
||||
|
||||
@ -83,126 +83,152 @@ 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()
|
||||
static T_DjiReturnCode DjiUser_LocalWrite(const uint8_t *data, uint16_t dataLen)
|
||||
{
|
||||
// using namespace ZZ::Device::DJI::M300RTK;
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
|
||||
}
|
||||
#include<dji_power_management.h>
|
||||
#include<test_power_management.h>
|
||||
static T_DjiReturnCode DjiTest_HighPowerApplyPinInit()
|
||||
{
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiTest_WriteHighPowerApplyPin(E_DjiPowerManagementPinState pinState)
|
||||
{
|
||||
//attention: please pull up the HWPR pin state by hardware.
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
int VehicleController::SetupEnvironment_M300RTK()
|
||||
{
|
||||
using namespace ZZ::Device::DJI;
|
||||
|
||||
spCaller = this;
|
||||
|
||||
//for test
|
||||
//ZZ_ConfigParser_M300RTK clsConfigParser;
|
||||
//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);
|
||||
|
||||
T_DjiReturnCode returnCode;
|
||||
|
||||
/*********************** OSAL HANDLER *************************/
|
||||
T_DjiOsalHandler osalHandler;
|
||||
memset(&osalHandler, 0, sizeof(T_DjiOsalHandler));
|
||||
T_DjiHalUsbBulkHandler usbBulkHandler = { 0 };
|
||||
osalHandler.TaskCreate = Osal_TaskCreate;
|
||||
osalHandler.TaskDestroy = Osal_TaskDestroy;
|
||||
osalHandler.TaskSleepMs = Osal_TaskSleepMs;
|
||||
osalHandler.MutexCreate = Osal_MutexCreate;
|
||||
osalHandler.MutexDestroy = Osal_MutexDestroy;
|
||||
osalHandler.MutexLock = Osal_MutexLock;
|
||||
osalHandler.MutexUnlock = Osal_MutexUnlock;
|
||||
osalHandler.SemaphoreCreate = Osal_SemaphoreCreate;
|
||||
osalHandler.SemaphoreDestroy = Osal_SemaphoreDestroy;
|
||||
osalHandler.SemaphoreWait = Osal_SemaphoreWait;
|
||||
osalHandler.SemaphoreTimedWait = Osal_SemaphoreTimedWait;
|
||||
osalHandler.SemaphorePost = Osal_SemaphorePost;
|
||||
osalHandler.Malloc = Osal_Malloc;
|
||||
osalHandler.Free = Osal_Free;
|
||||
osalHandler.GetRandomNum = Osal_GetRandomNum;
|
||||
osalHandler.GetTimeMs = Osal_GetTimeMs;
|
||||
osalHandler.GetTimeUs = Osal_GetTimeUs;
|
||||
|
||||
///////////
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler osalHandler = { 0 };
|
||||
T_DjiHalUartHandler uartHandler = { 0 };
|
||||
T_DjiHalUsbBulkHandler usbBulkHandler = { 0 };
|
||||
T_DjiLoggerConsole printConsole;
|
||||
T_DjiLoggerConsole localRecordConsole;
|
||||
T_DjiFileSystemHandler fileSystemHandler = { 0 };
|
||||
T_DjiSocketHandler socketHandler{ 0 };
|
||||
T_DjiHalNetworkHandler networkHandler = { 0 };
|
||||
/*********************** LOGGER *************************/
|
||||
T_DjiLoggerConsole loggerConsole;
|
||||
memset(&loggerConsole, 0, sizeof(T_DjiLoggerConsole));
|
||||
|
||||
networkHandler.NetworkInit = HalNetWork_Init;
|
||||
networkHandler.NetworkDeInit = HalNetWork_DeInit;
|
||||
loggerConsole.func = DjiUser_PrintMessage;
|
||||
loggerConsole.consoleLevel = DJI_LOGGER_CONSOLE_LOG_LEVEL_INFO;
|
||||
loggerConsole.isSupportColor = true;
|
||||
|
||||
/*********************** UART *************************/
|
||||
T_DjiHalUartHandler uartHandler;
|
||||
memset(&uartHandler, 0, sizeof(T_DjiHalUartHandler));
|
||||
|
||||
uartHandler.UartInit = HalUart_Init;
|
||||
uartHandler.UartDeInit = HalUart_DeInit;
|
||||
uartHandler.UartWriteData = HalUart_WriteData;
|
||||
uartHandler.UartReadData = HalUart_ReadData;
|
||||
uartHandler.UartGetStatus = HalUart_GetStatus;
|
||||
uartHandler.UartGetDeviceInfo = HalUart_GetDeviceInfo;
|
||||
|
||||
/*********************** NETWORK *************************/
|
||||
T_DjiHalNetworkHandler networkHandler;
|
||||
memset(&networkHandler, 0, sizeof(T_DjiHalNetworkHandler));
|
||||
|
||||
networkHandler.NetworkInit = HalNetWork_Init;
|
||||
networkHandler.NetworkDeInit = HalNetWork_DeInit;
|
||||
networkHandler.NetworkGetDeviceInfo = HalNetWork_GetDeviceInfo;
|
||||
|
||||
socketHandler.Socket = Osal_Socket;
|
||||
socketHandler.Bind = Osal_Bind;
|
||||
socketHandler.Close = Osal_Close;
|
||||
socketHandler.UdpSendData = Osal_UdpSendData;
|
||||
socketHandler.UdpRecvData = Osal_UdpRecvData;
|
||||
socketHandler.TcpListen = Osal_TcpListen;
|
||||
socketHandler.TcpAccept = Osal_TcpAccept;
|
||||
socketHandler.TcpConnect = Osal_TcpConnect;
|
||||
socketHandler.TcpSendData = Osal_TcpSendData;
|
||||
socketHandler.TcpRecvData = Osal_TcpRecvData;
|
||||
/*********************** FILE SYSTEM *************************/
|
||||
T_DjiFileSystemHandler fileSystemHandler;
|
||||
memset(&fileSystemHandler, 0, sizeof(T_DjiFileSystemHandler));
|
||||
|
||||
osalHandler.TaskCreate = Osal_TaskCreate;
|
||||
osalHandler.TaskDestroy = Osal_TaskDestroy;
|
||||
osalHandler.TaskSleepMs = Osal_TaskSleepMs;
|
||||
osalHandler.MutexCreate = Osal_MutexCreate;
|
||||
osalHandler.MutexDestroy = Osal_MutexDestroy;
|
||||
osalHandler.MutexLock = Osal_MutexLock;
|
||||
osalHandler.MutexUnlock = Osal_MutexUnlock;
|
||||
osalHandler.SemaphoreCreate = Osal_SemaphoreCreate;
|
||||
osalHandler.SemaphoreDestroy = Osal_SemaphoreDestroy;
|
||||
osalHandler.SemaphoreWait = Osal_SemaphoreWait;
|
||||
osalHandler.SemaphoreTimedWait = Osal_SemaphoreTimedWait;
|
||||
osalHandler.SemaphorePost = Osal_SemaphorePost;
|
||||
osalHandler.Malloc = Osal_Malloc;
|
||||
osalHandler.Free = Osal_Free;
|
||||
osalHandler.GetTimeMs = Osal_GetTimeMs;
|
||||
osalHandler.GetTimeUs = Osal_GetTimeUs;
|
||||
osalHandler.GetRandomNum = Osal_GetRandomNum;
|
||||
fileSystemHandler.FileOpen = Osal_FileOpen;
|
||||
fileSystemHandler.FileClose = Osal_FileClose;
|
||||
fileSystemHandler.FileWrite = Osal_FileWrite;
|
||||
fileSystemHandler.FileRead = Osal_FileRead;
|
||||
fileSystemHandler.FileSync = Osal_FileSync;
|
||||
fileSystemHandler.FileSeek = Osal_FileSeek;
|
||||
fileSystemHandler.DirOpen = Osal_DirOpen;
|
||||
fileSystemHandler.DirClose = Osal_DirClose;
|
||||
fileSystemHandler.DirRead = Osal_DirRead;
|
||||
fileSystemHandler.Mkdir = Osal_Mkdir;
|
||||
fileSystemHandler.Unlink = Osal_Unlink;
|
||||
fileSystemHandler.Rename = Osal_Rename;
|
||||
fileSystemHandler.Stat = Osal_Stat;
|
||||
|
||||
uartHandler.UartInit = HalUart_Init;
|
||||
uartHandler.UartDeInit = HalUart_DeInit;
|
||||
uartHandler.UartWriteData = HalUart_WriteData;
|
||||
uartHandler.UartReadData = HalUart_ReadData;
|
||||
uartHandler.UartGetStatus = HalUart_GetStatus;
|
||||
/*********************** SOCKET *************************/
|
||||
T_DjiSocketHandler socketHandler;
|
||||
memset(&socketHandler, 0, sizeof(T_DjiSocketHandler));
|
||||
|
||||
usbBulkHandler.UsbBulkInit = HalUsbBulk_Init;
|
||||
usbBulkHandler.UsbBulkDeInit = HalUsbBulk_DeInit;
|
||||
usbBulkHandler.UsbBulkWriteData = HalUsbBulk_WriteData;
|
||||
usbBulkHandler.UsbBulkReadData = HalUsbBulk_ReadData;
|
||||
usbBulkHandler.UsbBulkGetDeviceInfo = HalUsbBulk_GetDeviceInfo;
|
||||
|
||||
fileSystemHandler.FileOpen = Osal_FileOpen,
|
||||
fileSystemHandler.FileClose = Osal_FileClose,
|
||||
fileSystemHandler.FileWrite = Osal_FileWrite,
|
||||
fileSystemHandler.FileRead = Osal_FileRead,
|
||||
fileSystemHandler.FileSync = Osal_FileSync,
|
||||
fileSystemHandler.FileSeek = Osal_FileSeek,
|
||||
fileSystemHandler.DirOpen = Osal_DirOpen,
|
||||
fileSystemHandler.DirClose = Osal_DirClose,
|
||||
fileSystemHandler.DirRead = Osal_DirRead,
|
||||
fileSystemHandler.Mkdir = Osal_Mkdir,
|
||||
fileSystemHandler.Unlink = Osal_Unlink,
|
||||
fileSystemHandler.Rename = Osal_Rename,
|
||||
fileSystemHandler.Stat = Osal_Stat,
|
||||
|
||||
printConsole.func = DjiUser_PrintMessage;
|
||||
printConsole.consoleLevel = DJI_LOGGER_CONSOLE_LOG_LEVEL_INFO;
|
||||
printConsole.isSupportColor = false;
|
||||
socketHandler.Socket = Osal_Socket;
|
||||
socketHandler.Bind = Osal_Bind;
|
||||
socketHandler.Close = Osal_Close;
|
||||
socketHandler.UdpSendData = Osal_UdpSendData;
|
||||
socketHandler.UdpRecvData = Osal_UdpRecvData;
|
||||
socketHandler.TcpListen = Osal_TcpListen;
|
||||
socketHandler.TcpAccept = Osal_TcpAccept;
|
||||
socketHandler.TcpConnect = Osal_TcpConnect;
|
||||
socketHandler.TcpSendData = Osal_TcpSendData;
|
||||
socketHandler.TcpRecvData = Osal_TcpRecvData;
|
||||
usbBulkHandler.UsbBulkInit = HalUsbBulk_Init;
|
||||
usbBulkHandler.UsbBulkDeInit = HalUsbBulk_DeInit;
|
||||
usbBulkHandler.UsbBulkWriteData = HalUsbBulk_WriteData;
|
||||
usbBulkHandler.UsbBulkReadData = HalUsbBulk_ReadData;
|
||||
usbBulkHandler.UsbBulkGetDeviceInfo = HalUsbBulk_GetDeviceInfo;
|
||||
|
||||
returnCode = DjiPlatform_RegOsalHandler(&osalHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
@ -217,50 +243,41 @@ int VehicleController::SetupEnvironment()
|
||||
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)
|
||||
|
||||
// if (m_struHardwareInfo.enumHCM == HardwareConnectionMode::UartAndNetwork)
|
||||
// {
|
||||
// returnCode = DjiPlatform_RegHalUsbBulkHandler(&usbBulkHandler);
|
||||
// returnCode = DjiPlatform_RegHalNetworkHandler(&networkHandler);
|
||||
// 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.");
|
||||
// qDebug() << "VehicleController: Func DjiPlatform_RegHalNetworkHandler. Register hal network handler error";
|
||||
// throw std::runtime_error("Register hal network handler error");
|
||||
// }
|
||||
// }
|
||||
|
||||
if (/*m_struHardwareInfo.enumHCM == HardwareConnectionMode::UartAndNetwork*/ 1)
|
||||
{
|
||||
returnCode = DjiPlatform_RegHalNetworkHandler(&networkHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "VehicleController: Func DjiPlatform_RegHalNetworkHandler. Register hal network handler error";
|
||||
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");
|
||||
//}
|
||||
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
returnCode = DjiPlatform_RegHalNetworkHandler(&networkHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
printf("register hal network handler error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
//
|
||||
// //Attention: if you want to use camera stream view function, please uncomment it.
|
||||
returnCode = DjiPlatform_RegSocketHandler(&socketHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
printf("register osal socket handler error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// {
|
||||
// returnCode = DjiPlatform_RegHalUsbBulkHandler(&usbBulkHandler);
|
||||
// if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
// printf("register hal usb bulk handler error");
|
||||
// return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
returnCode = DjiPlatform_RegFileSystemHandler(&fileSystemHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
@ -268,7 +285,7 @@ int VehicleController::SetupEnvironment()
|
||||
throw std::runtime_error("Register osal filesystem handler error.");
|
||||
}
|
||||
|
||||
returnCode = DjiLogger_AddConsole(&printConsole);
|
||||
returnCode = DjiLogger_AddConsole(&loggerConsole);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << "VehicleController: Func DjiPlatform_RegFileSystemHandler. Register osal filesystem handler error";
|
||||
@ -276,12 +293,19 @@ int VehicleController::SetupEnvironment()
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// returnCode = DjiLogger_AddConsole(&localRecordConsole);
|
||||
// if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
// printf("add printf console error");
|
||||
// return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
// }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VehicleController::StartupPSDK_M350RTK()
|
||||
{
|
||||
|
||||
int VehicleController::StartupPSDK_M300RTK()
|
||||
{
|
||||
T_DjiUserInfo userInfo;
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiAircraftInfoBaseInfo aircraftInfoBaseInfo;
|
||||
@ -290,19 +314,19 @@ int VehicleController::StartupPSDK_M350RTK()
|
||||
//signal(SIGTERM, DjiUser_NormalExitHandler);
|
||||
|
||||
returnCode = LoadUserAppInfo(&userInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
throw std::runtime_error("Fill user info error, please check user info config.");
|
||||
}
|
||||
|
||||
returnCode = DjiCore_SetSerialNumber("IRIS00001");
|
||||
returnCode = DjiCore_Init(&userInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
throw std::runtime_error("Core init error.");
|
||||
}
|
||||
|
||||
returnCode = DjiAircraftInfo_GetBaseInfo(&aircraftInfoBaseInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
throw std::runtime_error("Get aircraft base info error.");
|
||||
}
|
||||
@ -313,39 +337,54 @@ int VehicleController::StartupPSDK_M350RTK()
|
||||
// }
|
||||
|
||||
returnCode = DjiCore_SetAlias("PSDK_APPALIAS");
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
throw std::runtime_error("Set alias error.");
|
||||
}
|
||||
|
||||
returnCode = DjiCore_ApplicationStart();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
throw std::runtime_error("Start sdk application error.");
|
||||
}
|
||||
|
||||
// T_DjiTestApplyHighPowerHandler applyHighPowerHandler = {
|
||||
// .pinInit = DjiTest_HighPowerApplyPinInit,
|
||||
// .pinWrite = DjiTest_WriteHighPowerApplyPin,
|
||||
// };
|
||||
//
|
||||
// returnCode = DjiTest_RegApplyHighPowerHandler(&applyHighPowerHandler);
|
||||
// if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
// USER_LOG_ERROR("regsiter apply high power handler error");
|
||||
// }
|
||||
//
|
||||
// returnCode = DjiTest_PowerManagementStartService();
|
||||
// if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
// USER_LOG_ERROR("power management init error");
|
||||
// }
|
||||
osalHandler->TaskSleepMs(5000);
|
||||
SetupWidget();
|
||||
SetupWidget();//<2F>?<EFBFBD><C9BC>?<EFBFBD><DFBC><3E><><EFBFBD>
|
||||
osalHandler->TaskSleepMs(5000);
|
||||
SetupMessagePipe();
|
||||
//SetupWaypointStatusCallback();
|
||||
//InitSystemParams();
|
||||
SetupSubscriptions();
|
||||
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>
|
||||
|
||||
|
||||
qDebug()<<"M350RTK PSDK Channel Started.";
|
||||
qDebug()<<"M300RTK 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(M350RTKDataFrame& M350RTKDataFrame)
|
||||
int VehicleController::GetOneDataFrame(M300RTKDataFrame& M300RTKDataFrame)
|
||||
{
|
||||
|
||||
T_DjiReturnCode tDjiReturnCode;
|
||||
T_DjiFcSubscriptionVelocity tDjiVelocity = { 0 };
|
||||
T_DjiFcSubscriptionQuaternion tDjiQuaternion = { 0 };
|
||||
@ -388,29 +427,29 @@ int VehicleController::GetOneDataFrame(M350RTKDataFrame& M350RTKDataFrame)
|
||||
//return 4;
|
||||
}
|
||||
|
||||
M350RTKDataFrame.stVelocity.x = tDjiVelocity.data.x;
|
||||
M350RTKDataFrame.stVelocity.y = tDjiVelocity.data.y;
|
||||
M350RTKDataFrame.stVelocity.z = tDjiVelocity.data.z;
|
||||
M300RTKDataFrame.stVelocity.x = tDjiVelocity.data.x;
|
||||
M300RTKDataFrame.stVelocity.y = tDjiVelocity.data.y;
|
||||
M300RTKDataFrame.stVelocity.z = tDjiVelocity.data.z;
|
||||
|
||||
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.stQuaternion.w_q0 = tDjiQuaternion.q0;
|
||||
M300RTKDataFrame.stQuaternion.x_q1 = tDjiQuaternion.q1;
|
||||
M300RTKDataFrame.stQuaternion.y_q2 = tDjiQuaternion.q2;
|
||||
M300RTKDataFrame.stQuaternion.z_q3 = tDjiQuaternion.q3;
|
||||
|
||||
M350RTKDataFrame.stGPSPosition.x = tDjiGpsPosition.x;
|
||||
M350RTKDataFrame.stGPSPosition.y = tDjiGpsPosition.y;
|
||||
M350RTKDataFrame.stGPSPosition.z = tDjiGpsPosition.z;
|
||||
M300RTKDataFrame.stGPSPosition.x = tDjiGpsPosition.x;
|
||||
M300RTKDataFrame.stGPSPosition.y = tDjiGpsPosition.y;
|
||||
M300RTKDataFrame.stGPSPosition.z = tDjiGpsPosition.z;
|
||||
|
||||
M350RTKDataFrame.fAltitudeFused = tDjiAltFused;
|
||||
M300RTKDataFrame.fAltitudeFused = tDjiAltFused;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////Calc Euler From Quaternion 20230428
|
||||
M350RTKDataFrame.stEulerAngle.pitch = (dji_f64_t)asinf(-2 * tDjiQuaternion.q1 * tDjiQuaternion.q3 + 2 * tDjiQuaternion.q0 * tDjiQuaternion.q2) * 57.3;
|
||||
M300RTKDataFrame.stEulerAngle.pitch = (dji_f64_t)asinf(-2 * tDjiQuaternion.q1 * tDjiQuaternion.q3 + 2 * tDjiQuaternion.q0 * tDjiQuaternion.q2) * 57.3;
|
||||
|
||||
M350RTKDataFrame.stEulerAngle.roll = (dji_f64_t)atan2f(2 * tDjiQuaternion.q2 * tDjiQuaternion.q3 + 2 * tDjiQuaternion.q0 * tDjiQuaternion.q1,
|
||||
M300RTKDataFrame.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;
|
||||
|
||||
M350RTKDataFrame.stEulerAngle.yaw = (dji_f64_t)atan2f(2 * tDjiQuaternion.q1 * tDjiQuaternion.q2 + 2 * tDjiQuaternion.q0 * tDjiQuaternion.q3,
|
||||
M300RTKDataFrame.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;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -426,24 +465,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 +531,7 @@ int VehicleController::SetupWaypointStatusCallback()
|
||||
}
|
||||
|
||||
returnCode = DjiWaypointV2_RegisterMissionEventCallback(ZZ_DjiWaypointV2EventCallback);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() <<"Register waypoint V2 event failed, error code:" << returnCode;
|
||||
return returnCode;
|
||||
@ -508,7 +547,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));
|
||||
@ -517,38 +556,22 @@ int VehicleController::LoadUserAppInfo(T_DjiUserInfo* struDjiUserInfo)
|
||||
memset(struDjiUserInfo->developerAccount, 0, sizeof(struDjiUserInfo->developerAccount));
|
||||
memset(struDjiUserInfo->baudRate, 0, sizeof(struDjiUserInfo->baudRate));
|
||||
|
||||
//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;
|
||||
//}
|
||||
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);
|
||||
|
||||
@ -564,22 +587,25 @@ 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(const_cast<char*>("/home/DJI/Widget"),100);
|
||||
// m_clsWidget.SetSettings(m_struUIConfig);
|
||||
m_clsWidget.SetUIFilePath("/home/DJI/Widget",100);
|
||||
// m_clsWidget.SetUIFilePath("/home/pi/airborn/configfile/DJI/Widget",100);
|
||||
|
||||
|
||||
m_clsWidget.SetSettings(m_struUIConfig);
|
||||
m_clsWidget.PreparteEnvironment();
|
||||
|
||||
return 0;
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
#include "dji_core.h"
|
||||
#include "dji_waypoint_v2.h"
|
||||
|
||||
//#include "ConfigParser_DJI.h"
|
||||
#include "pch.h"
|
||||
|
||||
#include "ConfigParser_M300RTK.h"
|
||||
@ -15,7 +14,7 @@
|
||||
#include "ZZ_Types.h"
|
||||
using namespace std;
|
||||
using namespace ZZ_DATA_DEF::DJI;
|
||||
//using namespace ZZ_DATA_DEF::MainConfig;
|
||||
using namespace ZZ_DATA_DEF::MainConfig;
|
||||
|
||||
class VehicleController :public QObject
|
||||
{
|
||||
@ -29,19 +28,16 @@ public:
|
||||
static int m_siFlagIsStartCaptureSignalEmitted;
|
||||
static VehicleController* spCaller;
|
||||
static char m_scCaptureMode;
|
||||
SensorPort m_struSensorPort;
|
||||
ZZ_Widget_M300RTK m_clsWidget;
|
||||
private:
|
||||
///////////Config need modify
|
||||
ZZ_ConfigParser_M350RTK m_clsConfigParser;
|
||||
ZZ_ConfigParser_M300RTK m_clsConfigParser;
|
||||
|
||||
|
||||
M300RTKSettings m_struM300RTKSs;
|
||||
AppRegInfo m_struAppRegInfo;
|
||||
HardwareInfo m_struHardwareInfo;
|
||||
//ZZ_ConfigParser_M300RTK m_clsConfigParser;
|
||||
ZZ_Widget_M300RTK m_clsWidget;
|
||||
|
||||
//M300RTKSettings m_struM300RTKSs;
|
||||
//AppRegInfo m_struAppRegInfo;
|
||||
//HardwareInfo m_struHardwareInfo;
|
||||
//UIConfig m_struUIConfig;
|
||||
UIConfig m_struUIConfig;
|
||||
|
||||
int m_iFlagIsVehicleTakeoff;
|
||||
int m_iFlagIsVehicleCapturing;
|
||||
@ -58,15 +54,15 @@ public:
|
||||
public:
|
||||
/// call First
|
||||
int Initialize();
|
||||
int SetupEnvironment();
|
||||
int SetupEnvironment_M300RTK();
|
||||
/// call Seconde
|
||||
int StartupPSDK_M350RTK();
|
||||
int StartupPSDK_M300RTK();
|
||||
|
||||
///call to save Settings
|
||||
int UpdateUIConfig();
|
||||
|
||||
/// data call
|
||||
int GetOneDataFrame(M350RTKDataFrame &M350RTKDataFrame);
|
||||
int GetOneDataFrame(M300RTKDataFrame &M300RTKDataFrame);
|
||||
private:
|
||||
///
|
||||
int SetupMessagePipe();
|
||||
|
||||
178
Source/M300/PSDK_Qt/Main/test_power_management.c
Normal file
178
Source/M300/PSDK_Qt/Main/test_power_management.c
Normal file
@ -0,0 +1,178 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file test_power_management.c
|
||||
* @brief
|
||||
*
|
||||
* @copyright (c) 2021 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "test_power_management.h"
|
||||
#include "dji_logger.h"
|
||||
#include "dji_aircraft_info.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
static T_DjiReturnCode DjiTest_PowerOffNotificationCallback(bool *powerOffPreparationFlag);
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
static T_DjiTestApplyHighPowerHandler s_applyHighPowerHandler;
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
/**
|
||||
* @brief Register handler function for applying high power. This function have to be called before calling
|
||||
* DjiTest_PowerManagementInit(), except for in Linux, because DjiTest_PowerManagementInit() do not apply high power
|
||||
* in Linux OS.
|
||||
* @param applyHighPowerHandler: pointer to handler function for applying high power.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiTest_RegApplyHighPowerHandler(T_DjiTestApplyHighPowerHandler *applyHighPowerHandler)
|
||||
{
|
||||
if (applyHighPowerHandler->pinInit == NULL) {
|
||||
USER_LOG_ERROR("reg apply high power handler pinInit error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (applyHighPowerHandler->pinWrite == NULL) {
|
||||
USER_LOG_ERROR("reg apply high power handler pinWrite error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
memcpy(&s_applyHighPowerHandler, applyHighPowerHandler, sizeof(T_DjiTestApplyHighPowerHandler));
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialise power management module, including apply high power (only RTOS) and register power off notification
|
||||
* callback function.
|
||||
* @note DJI development board 1.0 can not accept high power, so do not call this function in DJI development board
|
||||
* 1.0 project.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiTest_PowerManagementStartService(void)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiAircraftInfoBaseInfo baseInfo = {0};
|
||||
|
||||
returnCode = DjiPowerManagement_Init();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("power management init error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
returnCode = DjiAircraftInfo_GetBaseInfo(&baseInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get aircraft base info error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
if (baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V2 ||
|
||||
baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_XPORT ||
|
||||
baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V3 ||
|
||||
baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_EPORT_V2_RIBBON_CABLE ||
|
||||
baseInfo.aircraftType == DJI_AIRCRAFT_TYPE_FC30) {
|
||||
// apply high power
|
||||
if (s_applyHighPowerHandler.pinInit == NULL) {
|
||||
USER_LOG_ERROR("apply high power pin init interface is NULL error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
if (s_applyHighPowerHandler.pinWrite == NULL) {
|
||||
USER_LOG_ERROR("apply high power pin write interface is NULL error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
returnCode = s_applyHighPowerHandler.pinInit();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("apply high power pin init error");
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
returnCode = DjiPowerManagement_RegWriteHighPowerApplyPinCallback(s_applyHighPowerHandler.pinWrite);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("register WriteHighPowerApplyPinCallback error.");
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
if (baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V3 ||
|
||||
baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_EPORT_V2_RIBBON_CABLE) {
|
||||
E_DjiHighPowerVoltage voltage = E_DJI_HIGH_POWER_VOLTAGE_17V;
|
||||
|
||||
USER_LOG_INFO("Start to apply high power.");
|
||||
|
||||
returnCode = DjiPowerManagement_ApplyHighPowerSyncV2(voltage);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("apply high power error");
|
||||
return returnCode;
|
||||
}
|
||||
USER_LOG_INFO("Success to apply high power %s.",
|
||||
voltage == E_DJI_HIGH_POWER_VOLTAGE_13V6 ? "13V6" :
|
||||
voltage == E_DJI_HIGH_POWER_VOLTAGE_17V ? "17V" :
|
||||
voltage == E_DJI_HIGH_POWER_VOLTAGE_24V ? "24V" : "???");
|
||||
} else {
|
||||
USER_LOG_INFO("Start to apply high power.");
|
||||
|
||||
returnCode = DjiPowerManagement_ApplyHighPowerSync();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("apply high power error");
|
||||
return returnCode;
|
||||
}
|
||||
USER_LOG_INFO("Success to apply high power.");
|
||||
}
|
||||
}
|
||||
|
||||
// register power off notification callback function
|
||||
returnCode = DjiPowerManagement_RegPowerOffNotificationCallback(DjiTest_PowerOffNotificationCallback);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("register power off notification callback function error");
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiTest_PowerManagementStopService(void)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
|
||||
returnCode = DjiPowerManagement_DeInit();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("power management deinit error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
static T_DjiReturnCode DjiTest_PowerOffNotificationCallback(bool *powerOffPreparationFlag)
|
||||
{
|
||||
USER_LOG_INFO("aircraft will power off soon.");
|
||||
|
||||
*powerOffPreparationFlag = true;
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
||||
58
Source/M300/PSDK_Qt/Main/test_power_management.h
Normal file
58
Source/M300/PSDK_Qt/Main/test_power_management.h
Normal file
@ -0,0 +1,58 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file test_power_management.h
|
||||
* @brief This is the header file for "test_power_management.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2021 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef TEST_POWER_MANAGEMENT_H
|
||||
#define TEST_POWER_MANAGEMENT_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_typedef.h"
|
||||
#include "dji_power_management.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
T_DjiReturnCode (*pinInit)(void);
|
||||
T_DjiReturnCode (*pinWrite)(E_DjiPowerManagementPinState pinState);
|
||||
} T_DjiTestApplyHighPowerHandler;
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
T_DjiReturnCode DjiTest_PowerManagementStartService(void);
|
||||
T_DjiReturnCode DjiTest_PowerManagementStopService(void);
|
||||
T_DjiReturnCode DjiTest_RegApplyHighPowerHandler(T_DjiTestApplyHighPowerHandler *applyHighPowerHandler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_POWER_MANAGEMENT_H
|
||||
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
||||
@ -1,9 +1,23 @@
|
||||
#include "Widget_M300RTK.h"
|
||||
enum AireType
|
||||
{
|
||||
Aire_Aire = 1,
|
||||
Aire_N2=0,
|
||||
};
|
||||
|
||||
enum Target_Gas {
|
||||
Target_CO2 = 0,
|
||||
Target_H2O = 1,
|
||||
};
|
||||
int32_t CuttrentGasValue = 0;
|
||||
int32_t ZZ_Widget_M300RTK::m_siDjiWidgetValueBtn = 0;
|
||||
int32_t ZZ_Widget_M300RTK::m_siDjiWidgetValueList_CaptureMode = 1;
|
||||
int32_t ZZ_Widget_M300RTK::m_siDjiWidgetValueList_DecisionHeight = 1;
|
||||
int32_t ZZ_Widget_M300RTK::m_siDjiWidgetValueList_SamplingRate = 0;
|
||||
AireType CurrentAireType = Aire_Aire;
|
||||
Target_Gas CurrentTargetGas = Target_CO2;
|
||||
float NowTempreature = 0;
|
||||
bool isnowsystemWorking = false;
|
||||
|
||||
ZZ_Widget_M300RTK::ZZ_Widget_M300RTK(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
@ -71,7 +85,14 @@ int ZZ_Widget_M300RTK::PreparteEnvironment()
|
||||
{0, DJI_WIDGET_TYPE_SWITCH, ZZ_Widget_M300RTK::OnUpdateWidgetValue, ZZ_Widget_M300RTK::OnLoadWidgetValue, this},
|
||||
{1, DJI_WIDGET_TYPE_LIST, ZZ_Widget_M300RTK::OnUpdateWidgetValue, ZZ_Widget_M300RTK::OnLoadWidgetValue, this},
|
||||
{2, DJI_WIDGET_TYPE_LIST, ZZ_Widget_M300RTK::OnUpdateWidgetValue, ZZ_Widget_M300RTK::OnLoadWidgetValue, this},
|
||||
{3, DJI_WIDGET_TYPE_LIST, ZZ_Widget_M300RTK::OnUpdateWidgetValue, ZZ_Widget_M300RTK::OnLoadWidgetValue, this}
|
||||
{3, DJI_WIDGET_TYPE_LIST, ZZ_Widget_M300RTK::OnUpdateWidgetValue, ZZ_Widget_M300RTK::OnLoadWidgetValue, this},
|
||||
{4, DJI_WIDGET_TYPE_INT_INPUT_BOX, ZZ_Widget_M300RTK::OnUpdateWidgetValue, ZZ_Widget_M300RTK::OnLoadWidgetValue, this},
|
||||
{5, DJI_WIDGET_TYPE_BUTTON, ZZ_Widget_M300RTK::OnUpdateWidgetValue, ZZ_Widget_M300RTK::OnLoadWidgetValue, this},
|
||||
{6, DJI_WIDGET_TYPE_LIST, ZZ_Widget_M300RTK::OnUpdateWidgetValue, ZZ_Widget_M300RTK::OnLoadWidgetValue, this},
|
||||
{7, DJI_WIDGET_TYPE_BUTTON, ZZ_Widget_M300RTK::OnUpdateWidgetValue, ZZ_Widget_M300RTK::OnLoadWidgetValue, this},
|
||||
{8, DJI_WIDGET_TYPE_LIST, ZZ_Widget_M300RTK::OnUpdateWidgetValue, ZZ_Widget_M300RTK::OnLoadWidgetValue, this},
|
||||
{9, DJI_WIDGET_TYPE_INT_INPUT_BOX, ZZ_Widget_M300RTK::OnUpdateWidgetValue, ZZ_Widget_M300RTK::OnLoadWidgetValue, this},
|
||||
{10, DJI_WIDGET_TYPE_BUTTON, ZZ_Widget_M300RTK::OnUpdateWidgetValue, ZZ_Widget_M300RTK::OnLoadWidgetValue, this}
|
||||
};
|
||||
|
||||
djiStat = DjiWidget_Init();
|
||||
@ -82,7 +103,7 @@ int ZZ_Widget_M300RTK::PreparteEnvironment()
|
||||
}
|
||||
|
||||
djiStat = DjiWidget_RegDefaultUiConfigByDirPath(m_qstrFilePath.toLatin1());
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
qDebug() << m_qstrFilePath.toLatin1();
|
||||
qDebug() << "ZZ_Widget_M300RTK: Func DjiWidget_RegDefaultUiConfigByDirPath.Add default widget ui config error";
|
||||
@ -120,11 +141,91 @@ int ZZ_Widget_M300RTK::test_UpdatePSDKFloatMessage(QString qstrMessage)
|
||||
T_DjiReturnCode ZZ_Widget_M300RTK::OnUpdateWidgetValue(E_DjiWidgetType widgetType, uint32_t index, int32_t value, void* userData)
|
||||
{
|
||||
ZZ_Widget_M300RTK* pCaller = (ZZ_Widget_M300RTK*)userData;
|
||||
|
||||
|
||||
|
||||
if (pCaller->m_iFlagIsVehicleCapturing)
|
||||
{
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
if (widgetType == DJI_WIDGET_TYPE_INT_INPUT_BOX) {
|
||||
if (index == 4)
|
||||
{
|
||||
qDebug()<<"now tempreatrue is "<<value;
|
||||
NowTempreature=value;
|
||||
}
|
||||
if (index == 9)
|
||||
{
|
||||
qDebug() << "now gas value is " << value;
|
||||
CuttrentGasValue = value;
|
||||
}
|
||||
}
|
||||
if (widgetType== DJI_WIDGET_TYPE_BUTTON) {
|
||||
if (index==5)
|
||||
{
|
||||
//qDebug()<<"now value is "<<value;
|
||||
|
||||
|
||||
|
||||
if (value==1)
|
||||
{
|
||||
if (isnowsystemWorking==true) return 0;
|
||||
if (NowTempreature==0) {
|
||||
pCaller->emit Signal_UpdatePSDKFloatMessage("please set correct temperature first");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
isnowsystemWorking= true;
|
||||
pCaller->emit Signal_UpdatePSDKFloatMessage("calibrating wind Sensor temperature:"+QString::number(NowTempreature*1.0/10));
|
||||
pCaller->emit SendCommand("WDA", "StartCalibrate#"+QString::number(NowTempreature*1.0/10));
|
||||
|
||||
}
|
||||
}
|
||||
if (index==7) {
|
||||
if (value==1)
|
||||
{
|
||||
if (isnowsystemWorking==true) return 0;
|
||||
isnowsystemWorking= true;
|
||||
QString AiretypeStr;
|
||||
if (CurrentAireType==Aire_Aire) {
|
||||
AiretypeStr="Air";
|
||||
}
|
||||
else {
|
||||
AiretypeStr="N2";
|
||||
}
|
||||
qDebug()<<"start gas sensor zero calibrate with "+AiretypeStr;
|
||||
pCaller->emit Signal_UpdatePSDKFloatMessage("ZeroCalibrate with "+AiretypeStr);
|
||||
pCaller->emit SendCommand("GAS", "ZeroCalibrate#"+AiretypeStr);
|
||||
}
|
||||
}
|
||||
if (index==10) {
|
||||
if (value==1)
|
||||
{
|
||||
if (isnowsystemWorking==true) return 0;
|
||||
isnowsystemWorking= true;
|
||||
QString TargetGasStr;
|
||||
if (CurrentTargetGas==Target_CO2) {
|
||||
TargetGasStr="CO2";
|
||||
}
|
||||
else {
|
||||
TargetGasStr="H2O";
|
||||
}
|
||||
//确保当前气体值不为0
|
||||
if (CuttrentGasValue==0) {
|
||||
pCaller->emit Signal_UpdatePSDKFloatMessage("please set correct gas value first");
|
||||
isnowsystemWorking=false;
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
qDebug()<<"start gas sensor span calibrate with "+TargetGasStr+" value is "+QString::number(CuttrentGasValue);
|
||||
pCaller->emit Signal_UpdatePSDKFloatMessage(TargetGasStr+" Span Calibrating gas value is "+QString::number(CuttrentGasValue));
|
||||
pCaller->emit SendCommand("GAS", "SpanCalibrate#"+TargetGasStr+"#"+QString::number(CuttrentGasValue));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (widgetType == DJI_WIDGET_TYPE_SWITCH )
|
||||
{
|
||||
@ -135,17 +236,29 @@ T_DjiReturnCode ZZ_Widget_M300RTK::OnUpdateWidgetValue(E_DjiWidgetType widgetTyp
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (value==1)
|
||||
{
|
||||
if (isnowsystemWorking==true) {
|
||||
// ZZ_Widget_M300RTK::m_siDjiWidgetValueBtn = !value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
isnowsystemWorking= true;
|
||||
pCaller->emit Signal_UpdatePSDKFloatMessage("start capture");
|
||||
pCaller->emit Signal_StartCapture();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isnowsystemWorking==false) {
|
||||
// ZZ_Widget_M300RTK::m_siDjiWidgetValueBtn = !value;
|
||||
return 0;
|
||||
}
|
||||
isnowsystemWorking= false;
|
||||
pCaller->emit Signal_UpdatePSDKFloatMessage("capture stopped");
|
||||
pCaller->emit Signal_StopCapture();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
ZZ_Widget_M300RTK::m_siDjiWidgetValueBtn = value;
|
||||
|
||||
@ -156,12 +269,12 @@ T_DjiReturnCode ZZ_Widget_M300RTK::OnUpdateWidgetValue(E_DjiWidgetType widgetTyp
|
||||
//pCaller->test_UpdatePSDKFloatMessage(qstrTest);
|
||||
//qstrTest = "12345";
|
||||
//pCaller->emit Signal_UpdatePSDKFloatMessage(qstrTest);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (widgetType == DJI_WIDGET_TYPE_LIST )
|
||||
if (widgetType == DJI_WIDGET_TYPE_LIST )
|
||||
{
|
||||
if (index==1)
|
||||
{
|
||||
@ -176,14 +289,22 @@ T_DjiReturnCode ZZ_Widget_M300RTK::OnUpdateWidgetValue(E_DjiWidgetType widgetTyp
|
||||
{
|
||||
ZZ_Widget_M300RTK::m_siDjiWidgetValueList_SamplingRate = value;
|
||||
}
|
||||
|
||||
else if (index==6)
|
||||
{
|
||||
CurrentAireType = (AireType)value;
|
||||
}
|
||||
else if (index==8)
|
||||
{
|
||||
CurrentTargetGas = (Target_Gas)value;
|
||||
}
|
||||
|
||||
|
||||
#ifdef ZZ_FLAG_TEST
|
||||
qDebug() << "OnUpdateWidgetValue " << "widgetType " << widgetType << "index " << index << "value " << value;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@ -193,7 +314,7 @@ T_DjiReturnCode ZZ_Widget_M300RTK::OnLoadWidgetValue(E_DjiWidgetType widgetType,
|
||||
if (widgetType == DJI_WIDGET_TYPE_SWITCH)
|
||||
{
|
||||
//qDebug() << "OnLoadWidgetValue " << "widgetType " << widgetType << "index " << index << "value " << value;
|
||||
|
||||
|
||||
*value= ZZ_Widget_M300RTK::m_siDjiWidgetValueBtn;
|
||||
}
|
||||
|
||||
@ -212,8 +333,27 @@ T_DjiReturnCode ZZ_Widget_M300RTK::OnLoadWidgetValue(E_DjiWidgetType widgetType,
|
||||
{
|
||||
*value = ZZ_Widget_M300RTK::m_siDjiWidgetValueList_SamplingRate;
|
||||
}
|
||||
|
||||
else if (index == 6)
|
||||
{
|
||||
*value = (int32_t)CurrentAireType;
|
||||
} else if (index == 8)
|
||||
{
|
||||
*value = (int32_t)CurrentTargetGas;
|
||||
}
|
||||
|
||||
}
|
||||
if (widgetType==DJI_WIDGET_TYPE_INT_INPUT_BOX)
|
||||
{
|
||||
if (index == 4)
|
||||
{
|
||||
*value = NowTempreature;
|
||||
}
|
||||
if (index == 9)
|
||||
{
|
||||
*value = CuttrentGasValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
@ -231,4 +371,21 @@ int ZZ_Widget_M300RTK::Slot_UpdatePSDKFloatMessage(QString qstrMessage)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ZZ_Widget_M300RTK::BackCommand(QString Worker, QString Command) {
|
||||
if (Worker=="WDA") {
|
||||
if (Command=="Finish") {
|
||||
isnowsystemWorking= false;
|
||||
qDebug()<<"wind calibrate finished";
|
||||
emit Signal_UpdatePSDKFloatMessage("wind calibrate finished");
|
||||
}
|
||||
}
|
||||
else if (Worker == "GAS") {
|
||||
if (Command == "Finish") {
|
||||
isnowsystemWorking = false;
|
||||
qDebug() << "gas zero calibrate finished";
|
||||
emit Signal_UpdatePSDKFloatMessage("gas zero calibrate finished");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ public:
|
||||
static T_DjiReturnCode OnLoadWidgetValue (E_DjiWidgetType widgetType, uint32_t index, int32_t* value,void* userData);
|
||||
public slots:
|
||||
int Slot_UpdatePSDKFloatMessage(QString qstrMessage);
|
||||
void BackCommand(QString Worker, QString Command);
|
||||
signals:
|
||||
void Signal_UpdatePSDKFloatMessage(QString qstrMessage);
|
||||
///0:Auto 1:Manual
|
||||
@ -47,4 +48,5 @@ signals:
|
||||
|
||||
void Signal_StartCapture();
|
||||
void Signal_StopCapture();
|
||||
void SendCommand(QString Worker, QString Command);
|
||||
};
|
||||
|
||||
@ -7,43 +7,40 @@ namespace ZZ
|
||||
{
|
||||
namespace DJI
|
||||
{
|
||||
enum HardwareConnectionMode
|
||||
namespace M300RTK
|
||||
{
|
||||
UartOnly = 0,
|
||||
UartAndUSBBulk,
|
||||
UartAndNetwork
|
||||
enum HardwareConnectionMode
|
||||
{
|
||||
UartOnly = 0,
|
||||
UartAndUSBBulk,
|
||||
UartAndNetwork
|
||||
};
|
||||
|
||||
typedef struct tagAppRegInfo
|
||||
{
|
||||
QString qstrUserAppName;
|
||||
QString qstrUserAppID;
|
||||
QString qstrUserAppKey;
|
||||
QString qstrUserAppLic;
|
||||
QString qstrUserAppAcc;
|
||||
}AppRegInfo;
|
||||
|
||||
typedef struct tagHardwareInfo
|
||||
{
|
||||
HardwareConnectionMode enumHCM;
|
||||
QString qstrBaudRate;
|
||||
}HardwareInfo;
|
||||
|
||||
typedef struct tagUIConfig
|
||||
{
|
||||
short sCaptureMode=0;
|
||||
short sSamplingRate=0;
|
||||
short sDecisionHeight=1;
|
||||
}UIConfig;
|
||||
|
||||
};
|
||||
|
||||
typedef struct tagAppRegInfo
|
||||
{
|
||||
QString qstrUserAppName;
|
||||
QString qstrUserAppID;
|
||||
QString qstrUserAppKey;
|
||||
QString qstrUserAppLic;
|
||||
QString qstrUserAppAcc;
|
||||
}AppRegInfo;
|
||||
|
||||
typedef struct tagHardwareInfo
|
||||
{
|
||||
HardwareConnectionMode enumHCM;
|
||||
QString qstrBaudRate;
|
||||
}HardwareInfo;
|
||||
|
||||
// typedef struct tagSensorPort
|
||||
// {
|
||||
// QString qstrWindSensorPort;
|
||||
// QString qstrGasSensorPort;
|
||||
// }SensorPort;
|
||||
|
||||
typedef struct tagUIConfig
|
||||
{
|
||||
short sCaptureMode = 0;
|
||||
short sSamplingRate = 0;
|
||||
short sDecisionHeight = 1;
|
||||
}UIConfig;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
176
Source/M300/PSDK_Qt/hal/hal_i2c.c
Normal file
176
Source/M300/PSDK_Qt/hal/hal_i2c.c
Normal file
@ -0,0 +1,176 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file hal_i2c.c
|
||||
* @brief
|
||||
*
|
||||
* @copyright (c) 2018 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "hal_i2c.h"
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
#include <linux/i2c.h>
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define I2C_DEVICE_RESET_TIME_US (25 * 1000)
|
||||
#define I2C_DEVICE_RESET_GPIO_NUM (4)
|
||||
#define DJI_SYSTEM_CMD_STR_MAX_SIZE (64)
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
int32_t i2cFd;
|
||||
} T_I2cHandleStruct;
|
||||
|
||||
/* Private values -------------------------------------------------------------*/
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
static void HalI2c_ResetDevice(void);
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
T_DjiReturnCode HalI2c_Init(T_DjiHalI2cConfig i2cConfig, T_DjiI2cHandle *i2cHandle)
|
||||
{
|
||||
T_I2cHandleStruct *i2CHandleStruct = NULL;
|
||||
|
||||
//attention: suggest reset the i2c device before init it.
|
||||
HalI2c_ResetDevice();
|
||||
|
||||
i2CHandleStruct = malloc(sizeof(T_I2cHandleStruct));
|
||||
if (i2CHandleStruct == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED;
|
||||
}
|
||||
|
||||
i2CHandleStruct->i2cFd = open(LINUX_I2C_DEV1, O_RDWR);
|
||||
if (i2CHandleStruct->i2cFd < 0) {
|
||||
printf("Open i2c device failed, fd: %d\r\n", i2CHandleStruct->i2cFd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*i2cHandle = i2CHandleStruct;
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode HalI2c_DeInit(T_DjiI2cHandle i2cHandle)
|
||||
{
|
||||
T_I2cHandleStruct *i2CHandleStruct = (T_I2cHandleStruct *) i2cHandle;
|
||||
|
||||
close(i2CHandleStruct->i2cFd);
|
||||
free(i2CHandleStruct);
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode HalI2c_WriteData(T_DjiI2cHandle i2cHandle, uint16_t devAddress, const uint8_t *buf,
|
||||
uint32_t len, uint32_t *realLen)
|
||||
{
|
||||
struct i2c_rdwr_ioctl_data data;
|
||||
struct i2c_msg messages;
|
||||
int32_t ret = 0;
|
||||
T_I2cHandleStruct *i2CHandleStruct = (T_I2cHandleStruct *) i2cHandle;
|
||||
|
||||
messages.addr = devAddress;
|
||||
messages.flags = 0;
|
||||
messages.len = len;
|
||||
messages.buf = (uint8_t *) buf;
|
||||
|
||||
data.msgs = &messages;
|
||||
data.nmsgs = 1;
|
||||
|
||||
ret = ioctl(i2CHandleStruct->i2cFd, I2C_RDWR, &data);
|
||||
if (ret < 0) {
|
||||
*realLen = 0;
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
*realLen = ret;
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode HalI2c_ReadData(T_DjiI2cHandle i2cHandle, uint16_t devAddress, uint8_t *buf,
|
||||
uint32_t len, uint32_t *realLen)
|
||||
{
|
||||
struct i2c_rdwr_ioctl_data data;
|
||||
struct i2c_msg messages;
|
||||
int32_t ret = 0;
|
||||
T_I2cHandleStruct *i2CHandleStruct = (T_I2cHandleStruct *) i2cHandle;
|
||||
|
||||
messages.addr = devAddress;
|
||||
messages.flags = I2C_M_RD;
|
||||
messages.len = len;
|
||||
messages.buf = buf;
|
||||
|
||||
data.msgs = &messages;
|
||||
data.nmsgs = 1;
|
||||
|
||||
ret = ioctl(i2CHandleStruct->i2cFd, I2C_RDWR, &data);
|
||||
if (ret < 0) {
|
||||
*realLen = 0;
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
*realLen = ret;
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
static void HalI2c_ResetDevice(void)
|
||||
{
|
||||
char systemCmd[DJI_SYSTEM_CMD_STR_MAX_SIZE] = {0};
|
||||
int32_t ret;
|
||||
|
||||
sprintf(systemCmd, "echo %d > /sys/class/gpio/export", I2C_DEVICE_RESET_GPIO_NUM);
|
||||
ret = system(systemCmd);
|
||||
if (ret != 0) {
|
||||
printf("Export reset gpio failed, %d\r\n", ret);
|
||||
}
|
||||
|
||||
sprintf(systemCmd, "echo out > /sys/class/gpio/gpio4/direction");
|
||||
ret = system(systemCmd);
|
||||
if (ret != 0) {
|
||||
printf("Set gpio direction failed, %d\r\n", ret);
|
||||
}
|
||||
|
||||
sprintf(systemCmd, "echo 0 > /sys/class/gpio/gpio4/value");
|
||||
ret = system(systemCmd);
|
||||
if (ret != 0) {
|
||||
printf("Set gpio value failed, %d\r\n", ret);
|
||||
}
|
||||
|
||||
usleep(I2C_DEVICE_RESET_TIME_US);
|
||||
|
||||
sprintf(systemCmd, "echo 1 > /sys/class/gpio/gpio4/value");
|
||||
ret = system(systemCmd);
|
||||
if (ret != 0) {
|
||||
printf("Set gpio value failed, %d\r\n", ret);
|
||||
}
|
||||
|
||||
sprintf(systemCmd, "echo %d > /sys/class/gpio/unexport", I2C_DEVICE_RESET_GPIO_NUM);
|
||||
ret = system(systemCmd);
|
||||
if (ret != 0) {
|
||||
printf("Unexport reset gpio failed, %d\r\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
||||
55
Source/M300/PSDK_Qt/hal/hal_i2c.h
Normal file
55
Source/M300/PSDK_Qt/hal/hal_i2c.h
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file hal_i2c.h
|
||||
* @brief This is the header file for "hal_i2c.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2018 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef HAL_I2C_H
|
||||
#define HAL_I2C_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define LINUX_I2C_DEV1 "/dev/i2c-1"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
T_DjiReturnCode HalI2c_Init(T_DjiHalI2cConfig i2cConfig, T_DjiI2cHandle *i2cHandle);
|
||||
T_DjiReturnCode HalI2c_DeInit(T_DjiI2cHandle i2cHandle);
|
||||
T_DjiReturnCode HalI2c_WriteData(T_DjiI2cHandle i2cHandle, uint16_t devAddress,
|
||||
const uint8_t *buf, uint32_t len, uint32_t *realLen);
|
||||
T_DjiReturnCode HalI2c_ReadData(T_DjiI2cHandle i2cHandle, uint16_t devAddress,
|
||||
uint8_t *buf, uint32_t len, uint32_t *realLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // HAL_I2C_H
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
||||
@ -1,8 +1,6 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file hal_network.c
|
||||
* @version V2.0.0
|
||||
* @date 3/27/20
|
||||
* @brief
|
||||
*
|
||||
* @copyright (c) 2021 DJI. All rights reserved.
|
||||
@ -44,16 +42,27 @@ T_DjiReturnCode HalNetWork_Init(const char *ipAddr, const char *netMask, T_DjiNe
|
||||
{
|
||||
int32_t ret;
|
||||
char cmdStr[LINUX_CMD_STR_MAX_SIZE];
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
int32_t routeIp[4] = {0};
|
||||
int32_t genMask[4] = {0};
|
||||
|
||||
if (ipAddr == NULL || netMask == NULL) {
|
||||
USER_LOG_ERROR("hal network config param error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
sscanf(ipAddr, "%d.%d.%d.%d", &routeIp[0], &routeIp[1], &routeIp[2], &routeIp[3]);
|
||||
sscanf(netMask, "%d.%d.%d.%d", &genMask[0], &genMask[1], &genMask[2], &genMask[3]);
|
||||
routeIp[0] &= genMask[0];
|
||||
routeIp[1] &= genMask[1];
|
||||
routeIp[2] &= genMask[2];
|
||||
routeIp[3] &= genMask[3];
|
||||
|
||||
//Attention: need root permission to config ip addr and netmask.
|
||||
memset(cmdStr, 0, sizeof(cmdStr));
|
||||
|
||||
snprintf(cmdStr, sizeof(cmdStr), "ifconfig %s up", LINUX_NETWORK_DEV);
|
||||
USER_LOG_DEBUG("%s", cmdStr);
|
||||
ret = system(cmdStr);
|
||||
if (ret != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Can't open the network."
|
||||
@ -63,14 +72,34 @@ T_DjiReturnCode HalNetWork_Init(const char *ipAddr, const char *netMask, T_DjiNe
|
||||
}
|
||||
|
||||
snprintf(cmdStr, sizeof(cmdStr), "ifconfig %s %s netmask %s", LINUX_NETWORK_DEV, ipAddr, netMask);
|
||||
USER_LOG_DEBUG("%s", cmdStr);
|
||||
ret = system(cmdStr);
|
||||
if (ret != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Can't config the ip address of network."
|
||||
"Probably the program not execute with root permission."
|
||||
"Please use the root permission to execute the program.");
|
||||
USER_LOG_ERROR("cmd failed: %s", cmdStr);
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(50);
|
||||
|
||||
snprintf(cmdStr, sizeof(cmdStr), "ip route flush dev %s", LINUX_NETWORK_DEV);
|
||||
USER_LOG_DEBUG("%s", cmdStr);
|
||||
ret = system(cmdStr);
|
||||
if (ret != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("cmd failed: %s", cmdStr);
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
snprintf(cmdStr, sizeof(cmdStr), "route add -net %d.%d.%d.%d netmask %s dev %s",
|
||||
routeIp[0], routeIp[1], routeIp[2], routeIp[3], netMask, LINUX_NETWORK_DEV);
|
||||
USER_LOG_DEBUG("%s", cmdStr);
|
||||
ret = system(cmdStr);
|
||||
if (ret != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("cmd failed: %s", cmdStr);
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(50);
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ extern "C" {
|
||||
* NIC name micro define as #define 'LINUX_NETWORK_DEV "your NIC name"'.
|
||||
*/
|
||||
#ifdef PLATFORM_ARCH_x86_64
|
||||
#define LINUX_NETWORK_DEV "enxf8e43b7bbc2c"
|
||||
#define LINUX_NETWORK_DEV "enp0s31f6"
|
||||
#else
|
||||
#define LINUX_NETWORK_DEV "pi4br0"
|
||||
#endif
|
||||
@ -52,8 +52,8 @@ extern "C" {
|
||||
#define USB_NET_ADAPTER_VID (0x0B95)
|
||||
#define USB_NET_ADAPTER_PID (0x1790)
|
||||
#else
|
||||
#define USB_NET_ADAPTER_VID (0x0955)
|
||||
#define USB_NET_ADAPTER_PID (0x7020)
|
||||
#define USB_NET_ADAPTER_VID (0x2CA3)
|
||||
#define USB_NET_ADAPTER_PID (0xF003)
|
||||
#endif
|
||||
|
||||
#define LINUX_CMD_STR_MAX_SIZE (128)
|
||||
|
||||
@ -31,12 +31,9 @@
|
||||
#define DJI_SYSTEM_CMD_STR_MAX_SIZE (64)
|
||||
#define DJI_SYSTEM_RESULT_STR_MAX_SIZE (128)
|
||||
|
||||
//Global
|
||||
char gvpcM300RTK_UART1[128] = "/dev/ttyUSB0";
|
||||
char gvpcM300RTK_UART2[128] = "/dev/ttyUSB0";
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
int uartFd;
|
||||
int32_t uartFd;
|
||||
} T_UartHandleStruct;
|
||||
|
||||
/* Private values -------------------------------------------------------------*/
|
||||
@ -46,7 +43,7 @@ typedef struct {
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
T_DjiReturnCode HalUart_Init(E_DjiHalUartNum uartNum, uint32_t baudRate, T_DjiUartHandle *uartHandle)
|
||||
{
|
||||
T_UartHandleStruct *uartHandleStruct;
|
||||
T_UartHandleStruct *uartHandleStruct = NULL;
|
||||
struct termios options;
|
||||
struct flock lock;
|
||||
T_DjiReturnCode returnCode = DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
@ -68,7 +65,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");
|
||||
@ -258,6 +255,18 @@ T_DjiReturnCode HalUart_GetStatus(E_DjiHalUartNum uartNum, T_DjiUartStatus *stat
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode HalUart_GetDeviceInfo(T_DjiHalUartDeviceInfo *deviceInfo)
|
||||
{
|
||||
if (deviceInfo == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
deviceInfo->vid = USB_UART_CONNECTED_TO_UAV_VID;
|
||||
deviceInfo->pid = USB_UART_CONNECTED_TO_UAV_PID;
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
||||
|
||||
@ -46,12 +46,16 @@ extern "C" {
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
//User can config dev based on there environmental conditions
|
||||
#define LINUX_UART_DEV1 "/dev/ttyAirborn"
|
||||
#define LINUX_UART_DEV2 "/dev/ttyUSB2"
|
||||
|
||||
//global
|
||||
extern char gvpcM300RTK_UART1[128];
|
||||
extern char gvpcM300RTK_UART2[128];
|
||||
#define LINUX_UART_DEV2 "/dev/ttyAirborn"
|
||||
|
||||
/**
|
||||
* Use for Eport 2.0, specify the VID and PID of the USB serial port closest to the aircraft.
|
||||
* FT232 0x0403:0x6001
|
||||
* CP2102 0x10C4:0xEA60
|
||||
* VCOM 0x2CA3:0xF002
|
||||
*/
|
||||
#define USB_UART_CONNECTED_TO_UAV_VID (0x0403)
|
||||
#define USB_UART_CONNECTED_TO_UAV_PID (0x6001)
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
@ -61,6 +65,7 @@ T_DjiReturnCode HalUart_DeInit(T_DjiUartHandle uartHandle);
|
||||
T_DjiReturnCode HalUart_WriteData(T_DjiUartHandle uartHandle, const uint8_t *buf, uint32_t len, uint32_t *realLen);
|
||||
T_DjiReturnCode HalUart_ReadData(T_DjiUartHandle uartHandle, uint8_t *buf, uint32_t len, uint32_t *realLen);
|
||||
T_DjiReturnCode HalUart_GetStatus(E_DjiHalUartNum uartNum, T_DjiUartStatus *status);
|
||||
T_DjiReturnCode HalUart_GetDeviceInfo(T_DjiHalUartDeviceInfo *deviceInfo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "hal_usb_bulk.h"
|
||||
#include "dji_logger.h"
|
||||
#include "utils/dji_config_manager.h"
|
||||
#include <errno.h>
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define LINUX_USB_BULK_TRANSFER_TIMEOUT_MS (50)
|
||||
@ -53,13 +53,6 @@ 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) {
|
||||
@ -70,19 +63,18 @@ T_DjiReturnCode HalUsbBulk_Init(T_DjiHalUsbBulkInfo usbBulkInfo, T_DjiUsbBulkHan
|
||||
#ifdef LIBUSB_INSTALLED
|
||||
ret = libusb_init(NULL);
|
||||
if (ret < 0) {
|
||||
USER_LOG_ERROR("init usb bulk failed, errno = %d", ret);
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
handle = libusb_open_device_with_vid_pid(NULL, usbBulkInfo.vid, usbBulkInfo.pid);
|
||||
if (handle == NULL) {
|
||||
USER_LOG_ERROR("open usb device failed");
|
||||
USER_LOG_ERROR("libusb open device error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
ret = libusb_claim_interface(handle, usbBulkInfo.channelInfo.interfaceNum);
|
||||
if (ret != LIBUSB_SUCCESS) {
|
||||
USER_LOG_ERROR("libusb claim interface failed, errno = %d", ret);
|
||||
USER_LOG_ERROR("libusb claim interface error");
|
||||
libusb_close(handle);
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
@ -95,44 +87,33 @@ 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 (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 (usbBulkInfo.channelInfo.interfaceNum == LINUX_USB_BULK1_INTERFACE_NUM) {
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep1 = open(LINUX_USB_BULK1_EP_IN_FD, O_RDWR);
|
||||
if (((T_HalUsbBulkObj *) *usbBulkHandle)->ep1 < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 = open(usbBulk1EpInFd, O_RDWR);
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 = open(LINUX_USB_BULK1_EP_OUT_FD, O_RDWR);
|
||||
if (((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
} else if (usbBulkInfo.channelInfo.interfaceNum == usbBulk2InterfaceNum) {
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep1 = open(usbBulk2EpOutFd, O_RDWR);
|
||||
} else if (usbBulkInfo.channelInfo.interfaceNum == LINUX_USB_BULK2_INTERFACE_NUM) {
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep1 = open(LINUX_USB_BULK2_EP_IN_FD, O_RDWR);
|
||||
if (((T_HalUsbBulkObj *) *usbBulkHandle)->ep1 < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 = open(usbBulk2EpInFd, O_RDWR);
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 = open(LINUX_USB_BULK2_EP_OUT_FD, O_RDWR);
|
||||
if (((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
} else if (usbBulkInfo.channelInfo.interfaceNum == LINUX_USB_BULK3_INTERFACE_NUM) {
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep1 = open(LINUX_USB_BULK3_EP_IN_FD, O_RDWR);
|
||||
if (((T_HalUsbBulkObj *) *usbBulkHandle)->ep1 < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 = open(LINUX_USB_BULK3_EP_OUT_FD, O_RDWR);
|
||||
if (((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
@ -146,7 +127,6 @@ T_DjiReturnCode HalUsbBulk_DeInit(T_DjiUsbBulkHandle usbBulkHandle)
|
||||
{
|
||||
struct libusb_device_handle *handle = NULL;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
int32_t ret;
|
||||
|
||||
if (usbBulkHandle == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
@ -156,12 +136,8 @@ 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) {
|
||||
USER_LOG_ERROR("release usb bulk interface failed, errno = %d", ret);
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
libusb_release_interface(handle, ((T_HalUsbBulkObj *) usbBulkHandle)->usbBulkInfo.channelInfo.interfaceNum);
|
||||
osalHandler->TaskSleepMs(100);
|
||||
libusb_exit(NULL);
|
||||
#endif
|
||||
} else {
|
||||
@ -181,8 +157,7 @@ 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;
|
||||
}
|
||||
|
||||
@ -200,7 +175,13 @@ T_DjiReturnCode HalUsbBulk_WriteData(T_DjiUsbBulkHandle usbBulkHandle, const uin
|
||||
*realLen = actualLen;
|
||||
#endif
|
||||
} else {
|
||||
*realLen = write(((T_HalUsbBulkObj *) usbBulkHandle)->ep1, buf, len);
|
||||
ret = write(((T_HalUsbBulkObj *) usbBulkHandle)->ep1, buf, len);
|
||||
if (ret < 0) {
|
||||
USER_LOG_ERROR("write ret %d %d %s\n", ret, errno, strerror(errno));
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
} else {
|
||||
*realLen = ret;
|
||||
}
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
@ -231,7 +212,13 @@ T_DjiReturnCode HalUsbBulk_ReadData(T_DjiUsbBulkHandle usbBulkHandle, uint8_t *b
|
||||
*realLen = actualLen;
|
||||
#endif
|
||||
} else {
|
||||
*realLen = read(((T_HalUsbBulkObj *) usbBulkHandle)->ep2, buf, len);
|
||||
ret = read(((T_HalUsbBulkObj *) usbBulkHandle)->ep2, buf, len);
|
||||
if (ret < 0) {
|
||||
USER_LOG_ERROR("read ret %d %d %s\n", ret, errno, strerror(errno));
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
} else {
|
||||
*realLen = ret;
|
||||
}
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
@ -239,39 +226,23 @@ T_DjiReturnCode HalUsbBulk_ReadData(T_DjiUsbBulkHandle usbBulkHandle, uint8_t *b
|
||||
|
||||
T_DjiReturnCode HalUsbBulk_GetDeviceInfo(T_DjiHalUsbBulkDeviceInfo *deviceInfo)
|
||||
{
|
||||
T_DjiUserLinkConfig linkConfig = {0};
|
||||
//attention: this interface only be called in usb device mode.
|
||||
deviceInfo->vid = LINUX_USB_VID;
|
||||
deviceInfo->pid = LINUX_USB_PID;
|
||||
|
||||
if (DjiUserConfigManager_IsEnable()) {
|
||||
DjiUserConfigManager_GetLinkConfig(&linkConfig);
|
||||
// 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;
|
||||
|
||||
//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 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;
|
||||
|
||||
// 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;
|
||||
}
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_2].interfaceNum = LINUX_USB_BULK3_INTERFACE_NUM;
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_2].endPointIn = LINUX_USB_BULK3_END_POINT_IN;
|
||||
deviceInfo->channelInfo[DJI_HAL_USB_BULK_NUM_2].endPointOut = LINUX_USB_BULK3_END_POINT_OUT;
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@ -38,7 +38,6 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#ifdef LIBUSB_INSTALLED
|
||||
|
||||
#include <libusb-1.0/libusb.h>
|
||||
@ -52,28 +51,29 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define LINUX_USB_BULK1_EP_OUT_FD "/dev/usb-ffs/bulk1/ep1"
|
||||
#define LINUX_USB_BULK1_EP_IN_FD "/dev/usb-ffs/bulk1/ep2"
|
||||
#define LINUX_USB_BULK1_EP_IN_FD "/dev/usb-ffs/bulk1/ep1"
|
||||
#define LINUX_USB_BULK1_EP_OUT_FD "/dev/usb-ffs/bulk1/ep2"
|
||||
|
||||
#define LINUX_USB_BULK1_INTERFACE_NUM (2)
|
||||
#define LINUX_USB_BULK1_END_POINT_IN (0x83)
|
||||
#define LINUX_USB_BULK1_END_POINT_OUT (2)
|
||||
#define LINUX_USB_BULK1_INTERFACE_NUM (0)
|
||||
#define LINUX_USB_BULK1_END_POINT_IN (0x81)
|
||||
#define LINUX_USB_BULK1_END_POINT_OUT (0x01)
|
||||
|
||||
#define LINUX_USB_BULK2_EP_OUT_FD "/dev/usb-ffs/bulk2/ep1"
|
||||
#define LINUX_USB_BULK2_EP_IN_FD "/dev/usb-ffs/bulk2/ep2"
|
||||
#define LINUX_USB_BULK2_EP_IN_FD "/dev/usb-ffs/bulk2/ep1"
|
||||
#define LINUX_USB_BULK2_EP_OUT_FD "/dev/usb-ffs/bulk2/ep2"
|
||||
|
||||
#define LINUX_USB_BULK2_INTERFACE_NUM (3)
|
||||
#define LINUX_USB_BULK2_END_POINT_IN (0x84)
|
||||
#define LINUX_USB_BULK2_END_POINT_OUT (3)
|
||||
#define LINUX_USB_BULK2_INTERFACE_NUM (1)
|
||||
#define LINUX_USB_BULK2_END_POINT_IN (0x82)
|
||||
#define LINUX_USB_BULK2_END_POINT_OUT (0x02)
|
||||
|
||||
#ifdef PLATFORM_ARCH_x86_64
|
||||
#define LINUX_USB_VID (0x0B95)
|
||||
#define LINUX_USB_PID (0x1790)
|
||||
#else
|
||||
#define LINUX_USB_VID (0x0955)
|
||||
#define LINUX_USB_PID (0x7020)
|
||||
#endif
|
||||
#define LINUX_USB_BULK3_EP_IN_FD "/dev/usb-ffs/bulk3/ep1"
|
||||
#define LINUX_USB_BULK3_EP_OUT_FD "/dev/usb-ffs/bulk3/ep2"
|
||||
|
||||
#define LINUX_USB_BULK3_INTERFACE_NUM (2)
|
||||
#define LINUX_USB_BULK3_END_POINT_IN (0x83)
|
||||
#define LINUX_USB_BULK3_END_POINT_OUT (0x03)
|
||||
|
||||
#define LINUX_USB_VID (0x2CA3)
|
||||
#define LINUX_USB_PID (0xF001)
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
@ -75,6 +75,9 @@ T_DjiReturnCode Osal_TaskCreate(const char *name, void *(*taskFunc)(void *), uin
|
||||
|
||||
T_DjiReturnCode Osal_TaskDestroy(T_DjiTaskHandle task)
|
||||
{
|
||||
if (task == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
pthread_cancel(*(pthread_t *) task);
|
||||
free(task);
|
||||
|
||||
@ -320,7 +323,7 @@ T_DjiReturnCode Osal_GetTimeUs(uint64_t *us)
|
||||
if (s_localTimeUsOffset == 0) {
|
||||
s_localTimeUsOffset = *us;
|
||||
} else {
|
||||
*us = *us - s_localTimeMsOffset;
|
||||
*us = *us - s_localTimeUsOffset;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
@ -344,4 +347,4 @@ void Osal_Free(void *ptr)
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file osal.h
|
||||
* @version V2.0.0
|
||||
* @date 2019/8/28
|
||||
* @brief This is the header file for "osal.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
|
||||
@ -48,15 +48,10 @@ T_DjiReturnCode Osal_FileOpen(const char *fileName, const char *fileMode, T_DjiF
|
||||
|
||||
*fileObj = fopen(fileName, fileMode);
|
||||
if (*fileObj == NULL) {
|
||||
goto out;
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
|
||||
out:
|
||||
free(*fileObj);
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
T_DjiReturnCode Osal_FileClose(T_DjiFileHandle fileObj)
|
||||
@ -266,7 +261,7 @@ T_DjiReturnCode Osal_Stat(const char *filePath, T_DjiFileInfo *fileInfo)
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
fileTm = localtime(&(st.st_ctime));
|
||||
fileTm = localtime((const time_t *) &(st.st_mtim));
|
||||
if (fileTm == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
@ -274,7 +269,7 @@ T_DjiReturnCode Osal_Stat(const char *filePath, T_DjiFileInfo *fileInfo)
|
||||
fileInfo->size = st.st_size;
|
||||
|
||||
fileInfo->createTime.year = fileTm->tm_year + 1900 - 1980;
|
||||
fileInfo->createTime.month = fileTm->tm_mon;
|
||||
fileInfo->createTime.month = fileTm->tm_mon + 1;
|
||||
fileInfo->createTime.day = fileTm->tm_mday;
|
||||
fileInfo->createTime.hour = fileTm->tm_hour;
|
||||
fileInfo->createTime.minute = fileTm->tm_min;
|
||||
|
||||
@ -46,7 +46,7 @@ typedef struct {
|
||||
T_DjiReturnCode Osal_Socket(E_DjiSocketMode mode, T_DjiSocketHandle *socketHandle)
|
||||
{
|
||||
T_SocketHandleStruct *socketHandleStruct;
|
||||
socklen_t optlen = sizeof(int);
|
||||
socklen_t optlen = sizeof (int);
|
||||
int rcvBufSize = SOCKET_RECV_BUF_MAX_SIZE;
|
||||
int opt = 1;
|
||||
|
||||
@ -142,7 +142,7 @@ T_DjiReturnCode Osal_UdpSendData(T_DjiSocketHandle socketHandle, const char *ipA
|
||||
T_SocketHandleStruct *socketHandleStruct = (T_SocketHandleStruct *) socketHandle;
|
||||
int32_t ret;
|
||||
|
||||
if (socketHandle <= 0 || ipAddr == NULL || port == 0 || buf == NULL || len == 0 || realLen == NULL) {
|
||||
if (socketHandle == NULL || ipAddr == NULL || port == 0 || buf == NULL || len == 0 || realLen == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -176,8 +176,6 @@ T_DjiReturnCode Osal_UdpRecvData(T_DjiSocketHandle socketHandle, char *ipAddr, u
|
||||
ret = recvfrom(socketHandleStruct->socketFd, buf, len, 0, (struct sockaddr *) &addr, &addrLen);
|
||||
if (ret >= 0) {
|
||||
*realLen = ret;
|
||||
strcpy(ipAddr, inet_ntoa(addr.sin_addr));
|
||||
*port = ntohs(addr.sin_port);
|
||||
} else {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
@ -66,6 +66,14 @@ typedef struct {
|
||||
uint8_t majorVersion;
|
||||
} T_DjiAircraftVersion;
|
||||
|
||||
/**
|
||||
* @brief enhanced transmission state.
|
||||
*/
|
||||
typedef enum {
|
||||
DJI_ENHANCEED_TRANSMISSION_STATE_DISABLED = 0, /**< Mobile app image transmission setting, Enhanced transmission disabled */
|
||||
DJI_ENHANCEED_TRANSMISSION_STATE_ENABLED = 3, /**< Mobile app image transmission setting, Enhanced transmission enabled. */
|
||||
} E_DjiEnhancedTransmissionState;
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Basic information about the aircraft system, including aircraft type and DJI adapter type.
|
||||
@ -97,6 +105,13 @@ T_DjiReturnCode DjiAircraftInfo_GetConnectionStatus(bool *isConnected);
|
||||
*/
|
||||
T_DjiReturnCode DjiAircraftInfo_GetAircraftVersion(T_DjiAircraftVersion *aircraftVersion);
|
||||
|
||||
/**
|
||||
* @brief Get Enhanced Transmission state, which is set in the mobile app image transmission setting -- Enhanced Transmission.
|
||||
* @param aircraftVersion: Enhanced Transmission state.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiAircraftInfo_GetEnhancedTransmission(E_DjiEnhancedTransmissionState *state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -682,6 +682,7 @@ typedef struct {
|
||||
E_DjiCameraManagerStreamSource streamSource[16];
|
||||
E_DjiCameraManagerStreamStorage streamStorage[16];
|
||||
E_DjiCameraManagerNightSceneMode nightSceneMode[16];
|
||||
E_DjiCameraManagerMeteringMode meteringMode[16];
|
||||
};
|
||||
uint32_t minValue;
|
||||
uint32_t maxValue;
|
||||
@ -850,7 +851,7 @@ T_DjiReturnCode DjiCameraManager_SetPhotoBurstCount(E_DjiMountPosition position,
|
||||
/**
|
||||
* @brief Set the parameters for INTERVAL shooting mode.
|
||||
* @note In this mode, the camera captures a photo, waits a specified interval
|
||||
* of time, then captures another photo, continuing until the set number of
|
||||
* of time, then captures another photo, continuing until the set number of
|
||||
* photos is reached. Supported by thermal imaging cameras, too.
|
||||
* @param position: camera mounted position
|
||||
* @param intervalSetting: refer to T_DjiCameraPhotoTimeIntervalSettings.
|
||||
@ -991,7 +992,7 @@ T_DjiReturnCode DjiCameraManager_GetTapZoomEnabled(E_DjiMountPosition position,
|
||||
|
||||
/**
|
||||
* @brief Set camera's tap-zoom multiplier of the selected camera mounted position.
|
||||
* @note The final zoom scale during a tap-zoom action will be:
|
||||
* @note The final zoom scale during a tap-zoom action will be:
|
||||
* Current Zoom Scale x Multiplier.
|
||||
* @param position: camera mounted position
|
||||
* @param tapZoomMultiplier: The multiplier range is [1,5]. A multiplier of 1 will not change the zoom.
|
||||
@ -1603,6 +1604,15 @@ T_DjiReturnCode DjiCameraManager_SetInfraredCameraGainMode(E_DjiMountPosition po
|
||||
T_DjiReturnCode DjiCameraManager_GetInfraredCameraGainModeTemperatureRange(E_DjiMountPosition position,
|
||||
T_DjiCameraManagerIrTempMeterRange *tempRange);
|
||||
|
||||
/**
|
||||
* @brief Get metergin mode range of infrared camera.
|
||||
* @param position: camera mounted position.
|
||||
* @param tempRange: returned value of metering range.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiCameraManager_GetMeteringModeRange(E_DjiMountPosition position,
|
||||
T_DjiCameraManagerRangeList *rangeList);
|
||||
|
||||
/**
|
||||
* @brief Set camera metering mode.
|
||||
* @param position: camera mounted position
|
||||
@ -1640,6 +1650,16 @@ T_DjiReturnCode DjiCameraManager_GetMeteringPointRegionRange(E_DjiMountPosition
|
||||
T_DjiReturnCode DjiCameraManager_SetMeteringPoint(E_DjiMountPosition position,
|
||||
uint8_t x, uint8_t y);
|
||||
|
||||
/**
|
||||
* @brief Set metering point normalize.
|
||||
* @param position: camera mounted position
|
||||
* @param x: Normalized horizontal coordinate, value ranges in 0 ~ 1.
|
||||
* @param y: Normalized Vertical coordinate, value ranges in 0 ~ 1.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiCameraManager_SetMeteringPointNormalized(E_DjiMountPosition position,
|
||||
dji_f32_t x, dji_f32_t y);
|
||||
|
||||
/**
|
||||
* @brief Get camera metering mode.
|
||||
* @param position: camera mounted position
|
||||
@ -1651,6 +1671,18 @@ T_DjiReturnCode DjiCameraManager_GetMeteringPoint(E_DjiMountPosition position,
|
||||
uint8_t *x, uint8_t *y);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get camera metering mode.
|
||||
* @param position: camera mounted position
|
||||
* @param x: a pointer to a float (dji_f32_t) that will receive the normalized x-coordinate of the
|
||||
* metering point.
|
||||
* @param y: a pointer to a float (dji_f32_t) that will receive the normalized y-coordinate of the
|
||||
* metering point.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiCameraManager_GetMeteringPointNormalized(E_DjiMountPosition position,
|
||||
dji_f32_t *x, dji_f32_t *y);
|
||||
|
||||
/**
|
||||
* @brief Start to record point cloud of the selected camera mounted position.
|
||||
* @param position: camera mounted position
|
||||
|
||||
@ -0,0 +1,60 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file dji_cloud_api_by_websockt.h
|
||||
* @brief This is the header file for "dji_cloud_api_by_websockt.h", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2021 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef DJI_CLOUD_API_BY_WEEBSOCKET_H
|
||||
#define DJI_CLOUD_API_BY_WEEBSOCKET_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Send data into cloud api channel over pilot2 websocket.
|
||||
* @note This interface should be called only on manifold3 application. It is recommended
|
||||
* to send more bytes of data at a time to improve read and write efficiency. Need to determine whether the send is
|
||||
* successful according to the return code and the actual sent data length.
|
||||
* @param data: pointer to data to be sent.
|
||||
* @param len: length of data to be sented to pilot2, unit: byte.
|
||||
* @param realLen: pointer to real length of data that already sent.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiCloudApi_SendDataByWebSocket(uint8_t *data, uint32_t len, uint32_t *realLen);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
||||
|
||||
@ -526,6 +526,153 @@ typedef enum {
|
||||
*/
|
||||
DJI_FC_SUBSCRIPTION_TOPIC_IMU_ATTI_NAVI_DATA_WITH_TIMESTAMP = DJI_DATA_SUBSCRIPTION_TOPIC(DJI_DATA_SUBSCRIPTION_MODULE_FC, 48),
|
||||
|
||||
/*!
|
||||
* @brief Provides postion NO.1 gimbal pitch, roll, yaw @ up to 50Hz
|
||||
* @details
|
||||
* The reference frame for gimbal angles is a NED frame attached to the gimbal.
|
||||
* This topic uses a data structure, Vector3f, that is too generic for the topic. The order of angles is :
|
||||
* |Data Structure Element| Meaning|
|
||||
* |----------------------|--------|
|
||||
* |Vector3f.x |pitch |
|
||||
* |Vector3f.y |roll |
|
||||
* |Vector3f.z |yaw |
|
||||
*
|
||||
* @perf
|
||||
* 0.1 deg accuracy in all axes
|
||||
*
|
||||
* @sensors Gimbal Encoder, IMU, Magnetometer
|
||||
* @units deg
|
||||
* @datastruct \ref T_DjiFcSubscriptionGimbalAngles
|
||||
* @also \ref TOPIC_GIMBAL_STATUS, \ref TOPIC_GIMBAL_CONTROL_MODE
|
||||
*/
|
||||
DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES_ON_POS_NO1 = DJI_DATA_SUBSCRIPTION_TOPIC(DJI_DATA_SUBSCRIPTION_MODULE_FC, 48),
|
||||
|
||||
/*!
|
||||
* @brief Provides postion NO.2 gimbal pitch, roll, yaw @ up to 50Hz
|
||||
* @details
|
||||
* The reference frame for gimbal angles is a NED frame attached to the gimbal.
|
||||
* This topic uses a data structure, Vector3f, that is too generic for the topic. The order of angles is :
|
||||
* |Data Structure Element| Meaning|
|
||||
* |----------------------|--------|
|
||||
* |Vector3f.x |pitch |
|
||||
* |Vector3f.y |roll |
|
||||
* |Vector3f.z |yaw |
|
||||
*
|
||||
* @perf
|
||||
* 0.1 deg accuracy in all axes
|
||||
*
|
||||
* @sensors Gimbal Encoder, IMU, Magnetometer
|
||||
* @units deg
|
||||
* @datastruct \ref T_DjiFcSubscriptionGimbalAngles
|
||||
* @also \ref TOPIC_GIMBAL_STATUS, \ref TOPIC_GIMBAL_CONTROL_MODE
|
||||
*/
|
||||
DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES_ON_POS_NO2 = DJI_DATA_SUBSCRIPTION_TOPIC(DJI_DATA_SUBSCRIPTION_MODULE_FC, 49),
|
||||
|
||||
/*!
|
||||
* @brief Provides postion NO.3 gimbal pitch, roll, yaw @ up to 50Hz
|
||||
* @details
|
||||
* The reference frame for gimbal angles is a NED frame attached to the gimbal.
|
||||
* This topic uses a data structure, Vector3f, that is too generic for the topic. The order of angles is :
|
||||
* |Data Structure Element| Meaning|
|
||||
* |----------------------|--------|
|
||||
* |Vector3f.x |pitch |
|
||||
* |Vector3f.y |roll |
|
||||
* |Vector3f.z |yaw |
|
||||
*
|
||||
* @perf
|
||||
* 0.1 deg accuracy in all axes
|
||||
*
|
||||
* @sensors Gimbal Encoder, IMU, Magnetometer
|
||||
* @units deg
|
||||
* @datastruct \ref T_DjiFcSubscriptionGimbalAngles
|
||||
* @also \ref TOPIC_GIMBAL_STATUS, \ref TOPIC_GIMBAL_CONTROL_MODE
|
||||
*/
|
||||
DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES_ON_POS_NO3 = DJI_DATA_SUBSCRIPTION_TOPIC(DJI_DATA_SUBSCRIPTION_MODULE_FC, 50),
|
||||
|
||||
/*!
|
||||
* @brief Provides postion NO.4 gimbal pitch, roll, yaw @ up to 50Hz
|
||||
* @details
|
||||
* The reference frame for gimbal angles is a NED frame attached to the gimbal.
|
||||
* This topic uses a data structure, Vector3f, that is too generic for the topic. The order of angles is :
|
||||
* |Data Structure Element| Meaning|
|
||||
* |----------------------|--------|
|
||||
* |Vector3f.x |pitch |
|
||||
* |Vector3f.y |roll |
|
||||
* |Vector3f.z |yaw |
|
||||
*
|
||||
* @perf
|
||||
* 0.1 deg accuracy in all axes
|
||||
*
|
||||
* @sensors Gimbal Encoder, IMU, Magnetometer
|
||||
* @units deg
|
||||
* @datastruct \ref T_DjiFcSubscriptionGimbalAngles
|
||||
* @also \ref TOPIC_GIMBAL_STATUS, \ref TOPIC_GIMBAL_CONTROL_MODE
|
||||
*/
|
||||
DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES_ON_POS_NO4 = DJI_DATA_SUBSCRIPTION_TOPIC(DJI_DATA_SUBSCRIPTION_MODULE_FC, 51),
|
||||
|
||||
/*!
|
||||
* @brief Provides postion NO.5 gimbal pitch, roll, yaw @ up to 50Hz
|
||||
* @details
|
||||
* The reference frame for gimbal angles is a NED frame attached to the gimbal.
|
||||
* This topic uses a data structure, Vector3f, that is too generic for the topic. The order of angles is :
|
||||
* |Data Structure Element| Meaning|
|
||||
* |----------------------|--------|
|
||||
* |Vector3f.x |pitch |
|
||||
* |Vector3f.y |roll |
|
||||
* |Vector3f.z |yaw |
|
||||
*
|
||||
* @perf
|
||||
* 0.1 deg accuracy in all axes
|
||||
*
|
||||
* @sensors Gimbal Encoder, IMU, Magnetometer
|
||||
* @units deg
|
||||
* @datastruct \ref T_DjiFcSubscriptionGimbalAngles
|
||||
* @also \ref TOPIC_GIMBAL_STATUS, \ref TOPIC_GIMBAL_CONTROL_MODE
|
||||
*/
|
||||
DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES_ON_POS_NO5 = DJI_DATA_SUBSCRIPTION_TOPIC(DJI_DATA_SUBSCRIPTION_MODULE_FC, 52),
|
||||
|
||||
/*!
|
||||
* @brief Provides postion NO.6 gimbal pitch, roll, yaw @ up to 50Hz
|
||||
* @details
|
||||
* The reference frame for gimbal angles is a NED frame attached to the gimbal.
|
||||
* This topic uses a data structure, Vector3f, that is too generic for the topic. The order of angles is :
|
||||
* |Data Structure Element| Meaning|
|
||||
* |----------------------|--------|
|
||||
* |Vector3f.x |pitch |
|
||||
* |Vector3f.y |roll |
|
||||
* |Vector3f.z |yaw |
|
||||
*
|
||||
* @perf
|
||||
* 0.1 deg accuracy in all axes
|
||||
*
|
||||
* @sensors Gimbal Encoder, IMU, Magnetometer
|
||||
* @units deg
|
||||
* @datastruct \ref T_DjiFcSubscriptionGimbalAngles
|
||||
* @also \ref TOPIC_GIMBAL_STATUS, \ref TOPIC_GIMBAL_CONTROL_MODE
|
||||
*/
|
||||
DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES_ON_POS_NO6 = DJI_DATA_SUBSCRIPTION_TOPIC(DJI_DATA_SUBSCRIPTION_MODULE_FC, 53),
|
||||
|
||||
/*!
|
||||
* @brief Provides postion NO.7 gimbal pitch, roll, yaw @ up to 50Hz
|
||||
* @details
|
||||
* The reference frame for gimbal angles is a NED frame attached to the gimbal.
|
||||
* This topic uses a data structure, Vector3f, that is too generic for the topic. The order of angles is :
|
||||
* |Data Structure Element| Meaning|
|
||||
* |----------------------|--------|
|
||||
* |Vector3f.x |pitch |
|
||||
* |Vector3f.y |roll |
|
||||
* |Vector3f.z |yaw |
|
||||
*
|
||||
* @perf
|
||||
* 0.1 deg accuracy in all axes
|
||||
*
|
||||
* @sensors Gimbal Encoder, IMU, Magnetometer
|
||||
* @units deg
|
||||
* @datastruct \ref T_DjiFcSubscriptionGimbalAngles
|
||||
* @also \ref TOPIC_GIMBAL_STATUS, \ref TOPIC_GIMBAL_CONTROL_MODE
|
||||
*/
|
||||
DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES_ON_POS_NO7 = DJI_DATA_SUBSCRIPTION_TOPIC(DJI_DATA_SUBSCRIPTION_MODULE_FC, 54),
|
||||
|
||||
/*! Total number of topics that can be subscribed. */
|
||||
DJI_FC_SUBSCRIPTION_TOPIC_TOTAL_NUMBER,
|
||||
} E_DjiFcSubscriptionTopic;
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -114,6 +113,7 @@ typedef enum {
|
||||
DJI_FLIGHT_CONTROLLER_LOW_BATTERY_LANDING_RESET_JOYSTICK_CTRL_AUTH_EVENT = 10, /*!< Reset the joystick control permission to RC when aircraft is executing low-battery-landing*/
|
||||
DJI_FLIGHT_CONTROLLER_OSDK_LOST_GET_JOYSTICK_CTRL_AUTH_EVENT = 11, /*!< Reset the joystick control permission to RC when PSDK is lost*/
|
||||
DJI_FLIGHT_CONTROLLER_NERA_FLIGHT_BOUNDARY_RESET_JOYSTICK_CTRL_AUTH_EVENT = 12, /*!< Reset the joystick control permission to RC when aircraft is near boundary.*/
|
||||
DJI_FLIGHT_CONTROLLER_DOCK_REQUEST_CHANGE_JOYSTICK_CTRL_AUTH_EVENT = 13, /*!< Dock request change the joystick control permission.*/
|
||||
} E_DjiFlightControllerJoystickCtrlAuthoritySwitchEvent;
|
||||
|
||||
/**
|
||||
@ -237,6 +237,17 @@ typedef enum {
|
||||
DJI_FLIGHT_CONTROLLER_DISABLE_RC_LOST_ACTION = 1,
|
||||
} E_DjiFlightControllerRCLostActionEnableStatus;
|
||||
|
||||
typedef enum {
|
||||
DJI_FLIGHT_CONTROLLER_NO_MOTOR_IN_SLOW_ROTATE_MODE = 0,
|
||||
DJI_FLIGHT_CONTROLLER_SOME_MOTOR_IN_SLOW_ROTATE_MODE = 1,
|
||||
DJI_FLIGHT_CONTROLLER_ALL_MOTOR_IN_SLOW_ROTATE_MODE = 2,
|
||||
} E_DjiFlightControllerElectronicSpeedControllerStatus;
|
||||
|
||||
typedef enum {
|
||||
DJI_FLIGHT_CONTROLLER_FTS_NOT_TRIGGERD = 0,
|
||||
DJI_FLIGHT_CONTROLLER_FTS_TRIGGERD = 1,
|
||||
} E_DjiFlightControllerFtsStatus;
|
||||
|
||||
/**
|
||||
* @brief Joystick mode.
|
||||
* @note You need to set joystick mode first before start to send joystick command to aircraft.
|
||||
@ -272,6 +283,62 @@ typedef struct {
|
||||
uint16_t altitude;
|
||||
} T_DjiFlightControllerRidInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double lat; /*!< Target point latitude, unit: rad */
|
||||
double lon; /*!< Target point longitude, unit: rad */
|
||||
float alt; /*!< Target point altitude, ellipsoidal height unit: meters */
|
||||
} T_DjiFlightControllerPointInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t version; /*!< Function version */
|
||||
int8_t operation; /*!< New upload of a target point or update of the current task's target point; 0: new order, 1: update goal */
|
||||
float mea; /*!< Minimum enroute height, in meters, relative to the takeoff point.
|
||||
If the aircraft has not started or is on the ground, it will first climb to this height before executing the task. This height is ignored if the aircraft is in the air. */
|
||||
uint8_t fly_vel; /*!< Maximum horizontal flight speed to the target point, in meters per second */
|
||||
uint8_t goal_num; /*!< Number of target points, currently only supports one point */
|
||||
T_DjiFlightControllerPointInfo cmd_mode_point_info[1]; /*!< Information of the target point */
|
||||
} T_DjiFlightControllerStartMissionReq;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t ret_code; /*!< 0: Start task successfully, 1: Start task failed */
|
||||
uint16_t error_code; /*!< Instruction flight route version reused route error code */
|
||||
uint8_t code_name; /*!< Task code, unique, will be included in the trajectory push to ensure that external modules can correlate the task with its trajectory */
|
||||
} T_DjiFlightControllerStartMissionRsp;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t mission_state_machine; /*!< Task state machine, 0 is idle, others are in progress.*/
|
||||
uint8_t mission_planning_algo; /*!< Task planning algorithm mode */
|
||||
uint8_t goal_index; /*!< Current target point index */
|
||||
float distance_remaining; /*!< Remaining task distance */
|
||||
float time_remaining; /*!< Remaining task time */
|
||||
uint8_t soe_remaining; /*!< Required SOE (State of Energy) */
|
||||
uint8_t progress; /*!< Progress, reserved unused */
|
||||
uint8_t success_rate; /*!< Task success rate, reserved unused */
|
||||
} T_DjiFlightControllerOpenMis;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t latitude; /*!< GPS latitude, unit: 1/2^32 * 180°, range: [-90°, 90°) */
|
||||
int32_t longitude; /*!< GPS longitude, unit: 1/2^32 * 360°, range: [-180°, 180°) */
|
||||
int32_t altitude; /*!< Altitude, unit: mm; Note: The type of altitude depends on the function definition.
|
||||
It could be: relative to the takeoff point, WGS84 absolute ellipsoidal height, EGM96 absolute altitude, barometric height, etc. */
|
||||
} T_DjiFlightControllerSpotlightZoomGps;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t code_name; /*!< Unique task code for this trajectory push */
|
||||
uint8_t point_num; /*!< Number of key points in the trajectory */
|
||||
uint8_t byte_per_point; /*!< Number of bytes per point */
|
||||
T_DjiFlightControllerSpotlightZoomGps points[1]; /*!< Array of key points in the trajectory */
|
||||
uint8_t last_point_type; /*!< Whether the target point can be reached
|
||||
0: Yes, the last point in the trajectory is the user's target point
|
||||
1: No, the user's target point is in an invalid area (e.g., within an NFZ or building), the last point is the closest point to the target */
|
||||
} T_DjiFlightControllerCoreTraj;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
@ -288,6 +355,81 @@ T_DjiReturnCode DjiFlightController_Init(T_DjiFlightControllerRidInfo ridInfo);
|
||||
*/
|
||||
T_DjiReturnCode DjiFlightController_DeInit(void);
|
||||
|
||||
/**
|
||||
* @brief Set planning algorithm.
|
||||
* @param algo: 0:smart height, 1:Manual height.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiFlightController_SetPlanningAlgo(uint8_t algo);
|
||||
|
||||
/**
|
||||
* @brief Set max velocity.
|
||||
* @param value: max velocity value, min:1, max:15.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiFlightController_SetMaxVelocity(uint8_t value);
|
||||
|
||||
/**
|
||||
* @brief Set min flight height.
|
||||
* @param value: min flight height value, min:1.0, max:3000.0, only SetPlanningAlgo 1 effective.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiFlightController_SetMinFlightHeight(float value);
|
||||
|
||||
/**
|
||||
* @brief Get exit reason.
|
||||
* @param reason: exit reason".
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiFlightController_GetExitReason(uint16_t *reason);
|
||||
|
||||
/**
|
||||
* @brief Prototype of callback function used to get open mis info.
|
||||
* @return Execution result.
|
||||
*/
|
||||
typedef T_DjiReturnCode (*FcCmderModeOpenMisEventCbFunc)(T_DjiFlightControllerOpenMis eventData);
|
||||
|
||||
/**
|
||||
* @brief Prototype of callback function used to get core traj info.
|
||||
* @return Execution result.
|
||||
*/
|
||||
typedef T_DjiReturnCode (*FcCmderModeCoreTrajEventCbFunc)(T_DjiFlightControllerCoreTraj eventData);
|
||||
|
||||
/**
|
||||
* @brief Register callback function for the open mis event.
|
||||
* @param callback: the callback for the open mis event.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiFlightController_RegisterOpenMisInfoCallBack(FcCmderModeOpenMisEventCbFunc callback);
|
||||
|
||||
/**
|
||||
* @brief Register callback function for the core traj event.
|
||||
* @param callback: the callback for the core traj event.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiFlightController_RegisterCoreTrajCallBack(FcCmderModeCoreTrajEventCbFunc callback);
|
||||
|
||||
/**
|
||||
* @brief antiregister callback function for the open mis event.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiFlightController_AntiRegisterOpenMisInfoCallBack(void);
|
||||
|
||||
/**
|
||||
* @brief antiregister callback function for the core traj event.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiFlightController_AntiRegisterCoreTrajCallBack(void);
|
||||
|
||||
/**
|
||||
* @brief set mode start mission.
|
||||
* @param command: cmd for start mission.
|
||||
* @param rsp: response data for set start mission.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiFlightController_SetModeStartMission(T_DjiFlightControllerStartMissionReq command,
|
||||
T_DjiFlightControllerStartMissionRsp *rsp);
|
||||
|
||||
/**
|
||||
* @brief Enable/Disable RTK position function.
|
||||
* @details Enabling RTK means that RTK data will be used instead of GPS during flight.
|
||||
@ -649,6 +791,25 @@ DjiFlightController_GetEnableRCLostActionStatus(E_DjiFlightControllerRCLostActio
|
||||
*/
|
||||
T_DjiReturnCode DjiFlightController_RegTriggerFtsEventCallback(TriggerFtsEventCallback callback);
|
||||
|
||||
/**
|
||||
* @brief Start to rotate motors slowly.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiFlightController_StartSlowRotateMotor(void);
|
||||
|
||||
/**
|
||||
* @brief Stop to rotate motors slowly.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiFlightController_StopSlowRotateMotor(void);
|
||||
|
||||
/**
|
||||
* @brief Get the status of the ESC.
|
||||
* @param status: The status of the motor on aircraft.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiFlightController_GetElectronicSpeedControllerStatus(E_DjiFlightControllerElectronicSpeedControllerStatus *status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
86
Source/M300/PSDK_Qt/psdk_lib/include/dji_fts.h
Normal file
86
Source/M300/PSDK_Qt/psdk_lib/include/dji_fts.h
Normal file
@ -0,0 +1,86 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file dji_network_rtk.h
|
||||
* @version V1.0.0
|
||||
* @date 2025/10/09
|
||||
* @brief This is the header file for "dij_core.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2021 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef DJI_NETWORK_RTK_H
|
||||
#define DJI_NETWORK_RTK_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
typedef enum {
|
||||
DJI_FTS_NOT_TRIGGERD = 0,
|
||||
DJI_FTS_TRIGGERD = 1,
|
||||
} E_DjiFtsStatus;
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
typedef struct {
|
||||
E_DjiMountPosition fts_select;
|
||||
E_DjiFtsStatus fts_status;
|
||||
uint8_t fts_pwm_cnt; /* correct number of PWM signals received */
|
||||
} T_DjiFtsPwmTriggerStatus;
|
||||
|
||||
typedef struct {
|
||||
T_DjiFtsPwmTriggerStatus ESC[4]; /* trigger status of the two ESCs */
|
||||
} T_DjiFtsPwmEscTriggerStatus;
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Select Fts pwm trigger.
|
||||
* - Notes:Timing requirement: This API must be called while the aircraft is on the ground (not airborne). Calls made during flight will fail or be rejected.
|
||||
* - Function: This call only selects/enables the PWM trigger port on the flight controller side.
|
||||
* It does NOT emit PWM signals nor perform the motor-stop action itself. The actual motor-stop must be triggered by sending PWM signals via external PWM hardware pins.
|
||||
* - Recommended flow:
|
||||
* 1) Call DjiFlightController_SelectFtsPwmTrigger(position) on ground to enable the port;
|
||||
* 2) Send the motor-stop PWM from an external PWM controller to that port;
|
||||
* @param position
|
||||
* - Supported models/ports:
|
||||
* - M400: only support DJI_MOUNT_POSITION_EXTENSION_PORT_V2_NO4.
|
||||
* @return Possible failure reasons include invalid param, aircraft not on ground, hardware unsupported, or module not initialized.
|
||||
*/
|
||||
T_DjiReturnCode DjiFts_SelectFtsPwmTrigger(E_DjiMountPosition position);
|
||||
|
||||
/**
|
||||
* @brief Get Fts pwm trigger status.
|
||||
* Notes:This API is deprecated and will be removed in a future release. It is NOT recommended for use. Supported models only: M4 serials.
|
||||
* Recommended alternative: To confirm motor-stop (FTS) effects, use DJI_FC_SUBSCRIPTION_TOPIC_ESC_DATA fc subscription
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiFts_GetFtsPwmTriggerStatus(T_DjiFtsPwmEscTriggerStatus* trigger_status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DIJ_CORE_H
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
||||
@ -44,6 +44,18 @@ typedef enum {
|
||||
DJI_HMS_ERROR_LEVEL_FATAL,
|
||||
} E_DjiHmsErrorLevel;
|
||||
|
||||
typedef enum {
|
||||
DJI_HMS_ALARM_ENHANCED_TYPE_SHAKE_MOTOR = 1, /*!< Alarm triggered by shaking the motor on the pilot; alerts the user with vibrations indicating a warning or fault. */
|
||||
DJI_HMS_ALARM_ENHANCED_PLAY_SOUND = 2, /*!< Alarm triggered by playing sound */
|
||||
DJI_HMS_ALARM_ENHANCED_PLAY_SOUND_AND_SHAKE_MOTOR =3, /*!< Alarm that alerts the user on the PILOT app with both sound and vibrations */
|
||||
} E_DjiHmsAlarmEnhancedType;
|
||||
|
||||
typedef enum {
|
||||
DJI_HMS_ALARM_ENHANCED_ACTION_STOP = 0, /*!< Action to stop a specific enhanced alarm, shake motor or play sound */
|
||||
DJI_HMS_ALARM_ENHANCED_ACTION_START = 1, /*!< Action to stop a specific enhanced alarm */
|
||||
DJI_HMS_ALARM_ENHANCED_ACTION_EXIT_ALL =2,/*!< Action to exit all enhanced alarms, both shake motor and play sound; */
|
||||
} E_DjiHmsAlarmEnhancedAction;
|
||||
|
||||
typedef struct {
|
||||
char *fileName; /*!< The file name of the hms text config file */
|
||||
uint32_t fileSize; /*!< The file size of the hms text config file, uint : byte */
|
||||
@ -55,6 +67,11 @@ typedef struct {
|
||||
T_DjiHmsFileBinaryArray *fileBinaryArrayList; /*!< Pointer to binary array list */
|
||||
} T_DjiHmsBinaryArrayConfig;
|
||||
|
||||
typedef struct {
|
||||
E_DjiHmsAlarmEnhancedType type; /*!< The type is used to specify which enhanced alarm to ACTION_STOP or ACTION_START. It is ignored when EXIT_ALL alarms.*/
|
||||
int8_t times; /* !< Specifies the number of consecutive times the alarm is to be activated.*/
|
||||
int16_t interval; /* !< Indicates the interval (in milliseconds) between consecutive activations of the alarm.*/
|
||||
} T_DjiHmsAlarmEnhancedSetting;
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/**
|
||||
@ -65,7 +82,7 @@ typedef struct {
|
||||
T_DjiReturnCode DjiHmsCustomization_Init(void);
|
||||
|
||||
/**
|
||||
* @brief DeInitialize hms manager module.
|
||||
* @brief DeInitialize hms customization module.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiHmsCustomization_DeInit(void);
|
||||
@ -125,6 +142,15 @@ T_DjiReturnCode DjiHmsCustomization_RegDefaultHmsTextConfigByBinaryArray(const T
|
||||
T_DjiReturnCode DjiHmsCustomization_RegHmsTextConfigByBinaryArray(E_DjiMobileAppLanguage appLanguage,
|
||||
const T_DjiHmsBinaryArrayConfig *binaryArrayConfig);
|
||||
|
||||
/**
|
||||
* @brief Contrl the app alram.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @param action: The action to start or stop alarm.
|
||||
* @param setting: The alarm information.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiHmsCustomization_AlarmEnhancedCtrl(E_DjiHmsAlarmEnhancedAction action, T_DjiHmsAlarmEnhancedSetting setting);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -39,16 +39,23 @@ extern "C" {
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum {
|
||||
DJI_INTEREST_POINT_MISSION_ACTION_STATE_NOT_STARTED = 0,
|
||||
DJI_INTEREST_POINT_MISSION_ACTION_STATE_PAUSE = 1,
|
||||
DJI_INTEREST_POINT_MISSION_ACTION_STATE_RUNNING = 2,
|
||||
} E_DjiInterestPointActionState;
|
||||
|
||||
typedef struct {
|
||||
dji_f32_t curSpeed;
|
||||
dji_f32_t radius;
|
||||
uint8_t state;
|
||||
uint8_t state; /*!< Refer to E_DjiInterestPointActionState.*/
|
||||
} T_DjiInterestPointMissionState;
|
||||
|
||||
typedef struct {
|
||||
dji_f64_t latitude;
|
||||
dji_f64_t longitude;
|
||||
dji_f32_t speed;
|
||||
int8_t payloadCameraIndex; /*!< Used by which aircraft that can mount payload cameras. Range starts from 1.*/
|
||||
} T_DjiInterestPointSettings;
|
||||
|
||||
typedef T_DjiReturnCode (*InterestPointMissionStateCallback)(T_DjiInterestPointMissionState missionState);
|
||||
|
||||
@ -47,6 +47,15 @@ typedef enum {
|
||||
DJI_LIVEVIEW_CAMERA_POSITION_FPV = 7
|
||||
} E_DjiLiveViewCameraPosition;
|
||||
|
||||
/**
|
||||
* @brief Image format.
|
||||
*/
|
||||
typedef enum {
|
||||
PIXFMT_NV12 = 3,
|
||||
PIXFMT_RGB_PLANAR = 4,
|
||||
PIXFMT_RGB_PACKED = 5
|
||||
} E_DjiLiveViewPixFormate;
|
||||
|
||||
/**
|
||||
* @brief Liveview camera stream source.
|
||||
*/
|
||||
@ -71,13 +80,105 @@ typedef enum {
|
||||
DJI_LIVEVIEW_CAMERA_SOURCE_M3D_VIS = 1,
|
||||
DJI_LIVEVIEW_CAMERA_SOURCE_M3TD_VIS = 1,
|
||||
DJI_LIVEVIEW_CAMERA_SOURCE_M3TD_IR = 2,
|
||||
DJI_LIVEVIEW_CAMERA_SOURCE_H30_ZOOM = 1,
|
||||
DJI_LIVEVIEW_CAMERA_SOURCE_H30_4K = 7,
|
||||
DJI_LIVEVIEW_CAMERA_SOURCE_M4E_VIS = 1,
|
||||
DJI_LIVEVIEW_CAMERA_SOURCE_M4E_4K = 3,
|
||||
DJI_LIVEVIEW_CAMERA_SOURCE_M4T_VIS = 1,
|
||||
DJI_LIVEVIEW_CAMERA_SOURCE_M4T_IR = 2,
|
||||
DJI_LIVEVIEW_CAMERA_SOURCE_M4T_4K = 3,
|
||||
DJI_LIVEVIEW_CAMERA_SOURCE_M4D_VIS = 1,
|
||||
DJI_LIVEVIEW_CAMERA_SOURCE_M4D_4K = 3,
|
||||
DJI_LIVEVIEW_CAMERA_SOURCE_M4TD_VIS = 1,
|
||||
DJI_LIVEVIEW_CAMERA_SOURCE_M4TD_IR = 2,
|
||||
DJI_LIVEVIEW_CAMERA_SOURCE_M4TD_4K = 3,
|
||||
} E_DjiLiveViewCameraSource;
|
||||
|
||||
/**
|
||||
* @brief DJI standard types of target recognition.
|
||||
*/
|
||||
typedef enum {
|
||||
DJI_LIVEVIEW_OBJ_TYPE_INVALID = 0,
|
||||
DJI_LIVEVIEW_OBJ_TYPE_UNKNOWN = 1,
|
||||
DJI_LIVEVIEW_OBJ_TYPE_PERSON = 2,
|
||||
DJI_LIVEVIEW_OBJ_TYPE_CAR = 3,
|
||||
DJI_LIVEVIEW_OBJ_TYPE_BOAT = 4,
|
||||
DJI_LIVEVIEW_OBJ_TYPE_HUMAN_FACE = 5,
|
||||
DJI_LIVEVIEW_OBJ_TYPE_BIRD = 10,
|
||||
DJI_LIVEVIEW_OBJ_TYPE_BEACON = 20,
|
||||
DJI_LIVEVIEW_OBJ_TYPE_GPS = 30,
|
||||
DJI_LIVEVIEW_OBJ_TYPE_MOVING_TARGET = 34,
|
||||
} E_DjiLiveViewTargetObjectType;
|
||||
|
||||
/**
|
||||
* @brief Target Recognition Status.
|
||||
*/
|
||||
typedef enum {
|
||||
DJI_LIVEVIEW_OBJ_STATE_INVALID = 0, /*!< invalid state */
|
||||
DJI_LIVEVIEW_OBJ_STATE_TRACKED = 1, /*!< steady state following */
|
||||
DJI_LIVEVIEW_OBJ_STATE_VISION_BEACON_FUSIONED = 2, /*!< Vision beacon fusion state */
|
||||
DJI_LIVEVIEW_OBJ_STATE_AUXILIARY_TRACKED = 3, /*!< Loss of trigger source, auxiliary observation following state */
|
||||
DJI_LIVEVIEW_OBJ_STATE_NOT_CONFIDENT = 4, /*!< unstable following state */
|
||||
DJI_LIVEVIEW_OBJ_STATE_LOST_WITH_PREDICT = 5, /*!< Target lost, forecast status maintained */
|
||||
DJI_LIVEVIEW_OBJ_STATE_LOST = 6, /*!< Target Loss Status */
|
||||
DJI_LIVEVIEW_OBJ_STATE_REDETECTED = 7, /*!< Target Loss Retrieval Status */
|
||||
} E_DjiLiveViewTargetObjectState;
|
||||
|
||||
/**
|
||||
* @brief Picture frame information for target recognition results
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t cx; /*!< X-coordinate of the center of the frame, unit: 1/10000 * screen width */
|
||||
uint16_t cy; /*!< Y-coordinate of the center of the frame, unit: 1/10000 * screen height */
|
||||
uint16_t w; /*!< Frame width, unit: 1/10000 * screen width */
|
||||
uint16_t h; /*!< Frame height, unit: 1/10000 * screen height */
|
||||
uint32_t distance; /*!< Distance in mm */
|
||||
} __attribute__((packed)) T_DjiLiveViewTarget2dBox;
|
||||
|
||||
/**
|
||||
* @brief BoundingBox information for target recognition.
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t id;
|
||||
uint8_t type; /*!< type can be an enumerated value of E_DjiLiveViewTargetObjectType or a user-defined value. */
|
||||
uint8_t state; /*!< state should be of type E_DjiLiveViewTargetObjectState enumeration */
|
||||
T_DjiLiveViewTarget2dBox box;
|
||||
} __attribute__((packed)) T_DjiLiveViewBoundingBox;
|
||||
|
||||
/**
|
||||
* @brief List of boundingBox information.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t boxCount;
|
||||
T_DjiLiveViewBoundingBox boxData[1];
|
||||
} __attribute__((packed)) T_DjiLiveViewStandardMetaData;
|
||||
|
||||
/**
|
||||
* @brief Image information.
|
||||
*/
|
||||
typedef struct {
|
||||
E_DjiLiveViewPixFormate pixFmt;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
uint32_t frameId;
|
||||
} T_DjiLiveviewImageInfo;
|
||||
|
||||
/**
|
||||
* @brief Liveview camera h264 stream callback.
|
||||
*/
|
||||
typedef void (*DjiLiveview_H264Callback)(E_DjiLiveViewCameraPosition position, const uint8_t *buf, uint32_t len);
|
||||
|
||||
/**
|
||||
* @brief Liveview camera image data callback.
|
||||
*/
|
||||
typedef void (*DjiLiveview_ImageCallback)(E_DjiLiveViewCameraPosition position, const uint8_t *buf,
|
||||
uint32_t len , T_DjiLiveviewImageInfo ImageInfo);
|
||||
|
||||
/**
|
||||
* @brief Callback for handling encoded output data
|
||||
*/
|
||||
typedef void (*DjiLiveview_EncoderCallback)(const uint8_t *buf, uint32_t len);
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Initialize the liveview module.
|
||||
@ -119,6 +220,81 @@ T_DjiReturnCode DjiLiveview_StopH264Stream(E_DjiLiveViewCameraPosition position,
|
||||
T_DjiReturnCode DjiLiveview_RequestIntraframeFrameData(E_DjiLiveViewCameraPosition position,
|
||||
E_DjiLiveViewCameraSource source);
|
||||
|
||||
/**
|
||||
* @brief Request to get the decoded image data from the specified position.
|
||||
* @param position: Camera position for the H264 stream.
|
||||
* @param source: sub-camera source for the H264 stream.
|
||||
* @param pixFmt: Requested Image Format.
|
||||
* @param callback: Callback for handling image data.
|
||||
* @return Execution result.
|
||||
* @note This interface support on DJI manifold3.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_StartImageStream(E_DjiLiveViewCameraPosition position, E_DjiLiveViewCameraSource source,
|
||||
E_DjiLiveViewPixFormate pixFmt, DjiLiveview_ImageCallback callback);
|
||||
|
||||
/**
|
||||
* @brief Stop the decoded image data from the specified position.
|
||||
* @param position: Camera position for the H264 stream.
|
||||
* @param source: sub-camera source for the H264 stream.
|
||||
* @return Execution result.
|
||||
* @note This interface support on DJI manifold3.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_StopImageStream(E_DjiLiveViewCameraPosition position, E_DjiLiveViewCameraSource source);
|
||||
|
||||
/**
|
||||
* @brief Registering encoder callback handlers.
|
||||
* @return Execution result.
|
||||
* @note This interface support on DJI manifold3.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_RegEncoderCallback(DjiLiveview_EncoderCallback callback);
|
||||
|
||||
/**
|
||||
* @brief Unregistering encoder callback handlers.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_UnregEncoderCallback();
|
||||
|
||||
/**
|
||||
* @brief Encoding image into h264 streams.
|
||||
* @param buf: raw data of image.
|
||||
* @param len: length of image data.
|
||||
* @param imageInfo: information of image.
|
||||
* @param metaData: Resulting information obtained from images for target recognition.
|
||||
* @return Execution result.
|
||||
* @note If there is no need for information related to target identification, fill in NULL for metaData.
|
||||
* @note This interface needs to be used after DjiLiveview_RegEncoderCallback.
|
||||
* @note This interface support on DJI manifold3.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_EncodeAFrameToH264(const uint8_t *buf, uint32_t len, T_DjiLiveviewImageInfo imageInfo,
|
||||
T_DjiLiveViewStandardMetaData *metaData);
|
||||
|
||||
/**
|
||||
* @brief Register user-defined target Lables
|
||||
* @param lableCount: Number of lable.
|
||||
* @param labels: lable String Array
|
||||
* @note The key-value pairs of lable and index will be recorded on the Pilot after registration
|
||||
* and will be used to parse the metaData and display the lable when rendering the boundingbox.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_RegUserAiTargetLableList(uint8_t lableCount,const char *labels[]);
|
||||
|
||||
/**
|
||||
* @brief Unregister user-defined target Lables
|
||||
* @return Execution result.
|
||||
* @note This interface support on DJI manifold3.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_UnregUserAiTargetLableList();
|
||||
|
||||
/**
|
||||
* @brief Transmits the result information of the target recognition to the pilot for display.
|
||||
* @param metaData: Resulting information obtained from images for target recognition.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_SendAiMetaToPilot(T_DjiLiveViewStandardMetaData *metaData);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -102,14 +102,24 @@ T_DjiReturnCode DjiLogger_RemoveConsole(T_DjiLoggerConsole *console);
|
||||
void DjiLogger_UserLogOutput(E_DjiLoggerConsoleLogLevel level, const char *fmt, ...);
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define __FILENAME__ (strrchr("/" __FILE__, '/') + 1)
|
||||
|
||||
#define USER_LOG_PREFIX_FMT "%25s:%-4d "
|
||||
|
||||
#ifndef SYSTEM_ARCH_RTOS
|
||||
#define USER_LOG_PREFIX_ARG __FILENAME__, __LINE__
|
||||
#else
|
||||
#define USER_LOG_PREFIX_ARG __FUNCTION__, __LINE__
|
||||
#endif
|
||||
|
||||
#define USER_LOG_DEBUG(fmt, ...) \
|
||||
DjiLogger_UserLogOutput(DJI_LOGGER_CONSOLE_LOG_LEVEL_DEBUG, "[%s:%d) " fmt, __FUNCTION__, __LINE__ , ##__VA_ARGS__)
|
||||
DjiLogger_UserLogOutput(DJI_LOGGER_CONSOLE_LOG_LEVEL_DEBUG, USER_LOG_PREFIX_FMT fmt, USER_LOG_PREFIX_ARG, ##__VA_ARGS__)
|
||||
#define USER_LOG_INFO(fmt, ...) \
|
||||
DjiLogger_UserLogOutput(DJI_LOGGER_CONSOLE_LOG_LEVEL_INFO, "[%s:%d) " fmt, __FUNCTION__, __LINE__ , ##__VA_ARGS__)
|
||||
DjiLogger_UserLogOutput(DJI_LOGGER_CONSOLE_LOG_LEVEL_INFO, USER_LOG_PREFIX_FMT fmt, USER_LOG_PREFIX_ARG, ##__VA_ARGS__)
|
||||
#define USER_LOG_WARN(fmt, ...) \
|
||||
DjiLogger_UserLogOutput(DJI_LOGGER_CONSOLE_LOG_LEVEL_WARN, "[%s:%d) " fmt, __FUNCTION__, __LINE__ , ##__VA_ARGS__)
|
||||
DjiLogger_UserLogOutput(DJI_LOGGER_CONSOLE_LOG_LEVEL_WARN, USER_LOG_PREFIX_FMT fmt, USER_LOG_PREFIX_ARG, ##__VA_ARGS__)
|
||||
#define USER_LOG_ERROR(fmt, ...) \
|
||||
DjiLogger_UserLogOutput(DJI_LOGGER_CONSOLE_LOG_LEVEL_ERROR, "[%s:%d) " fmt, __FUNCTION__, __LINE__ , ##__VA_ARGS__)
|
||||
DjiLogger_UserLogOutput(DJI_LOGGER_CONSOLE_LOG_LEVEL_ERROR, USER_LOG_PREFIX_FMT fmt, USER_LOG_PREFIX_ARG, ##__VA_ARGS__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
130
Source/M300/PSDK_Qt/psdk_lib/include/dji_network_rtk.h
Normal file
130
Source/M300/PSDK_Qt/psdk_lib/include/dji_network_rtk.h
Normal file
@ -0,0 +1,130 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file dji_network_rtk.h
|
||||
* @version V1.0.0
|
||||
* @date 2025/10/09
|
||||
* @brief This is the header file for "dij_core.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2021 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef DJI_NETWORK_RTK_H
|
||||
#define DJI_NETWORK_RTK_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/**
|
||||
* @brief The network rtk state.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DJI_LOG_IN = 0, /*! Logging in (login in progress) */
|
||||
DJI_CONNECTING = 1,/*! Connecting to remote/server */
|
||||
DJI_TRANSFER = 2, /*! Data transfer in progress */
|
||||
DJI_RECONNECT = 3, /*! Reconnecting (attempting to restore connection) */
|
||||
DJI_BROKEN = 4, /*! Connection broken / disconnected from remote server */
|
||||
DJI_STOPPING = 5, /*! Stopping (shutdown in progress) */
|
||||
DJI_REBOOTING = 6, /*! Rebooting: waiting for restart after switching source) */
|
||||
} E_DjiNetworkRtkOnboardState;
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Position of target point and other details returned by interface of requesting position.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t account[16]; /*!< RTK account (username). Null-terminated string, up to 15 chars + '\0'. */
|
||||
uint8_t password[64]; /*!< RTK password. Null-terminated string, up to 63 chars + '\0'. */
|
||||
uint8_t host[64]; /*!< IP address of the NTRIP caster/host.MUST be a valid IPv4 or IPv6 address. Domain names (e.g., "example.com") are NOT supported.*/
|
||||
|
||||
/*!< NTRIP port information. Often used to indicate coordinate system info for some providers.
|
||||
* Field MUST be a string. The string SHOULD represent an integer value in
|
||||
* the range 1 to 65535 (inclusive). Example valid values: "80", "443", "2101".*/
|
||||
uint8_t port[6];
|
||||
|
||||
/*!< NTRIP mountpoint information. Typically configures RTCM system.
|
||||
* -Allowed characters: a-z, A-Z, 0-9, '-' (hyphen), '_' (underscore), '.' (dot).
|
||||
* -Disallowed characters include (but are not limited to): space, '@', '#', '$'.
|
||||
* -Recommended validation regex: /^[A-Za-z0-9._-]+$/ */
|
||||
uint8_t mountPoint[32];
|
||||
} T_DjiNetworkRtkServiceConfig;
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Register a callback function to receive network RTK service state updates.
|
||||
* @note This callback is used to asynchronously obtain the state of the network RTK service.
|
||||
* It is recommended to register the callback before starting the network RTK service.
|
||||
* @param callback [in] Pointer to the user-implemented callback function for handling received network RTK state data.
|
||||
* @return Execution result.
|
||||
*/
|
||||
typedef void (*DjiReceiveNetworkRtkStateCallback)(E_DjiNetworkRtkOnboardState state);
|
||||
T_DjiReturnCode DjiNetworkRtk_RegReceiveNetworkRtkStateCallback(DjiReceiveNetworkRtkStateCallback callback);
|
||||
/**
|
||||
* @brief Start the network RTK service.
|
||||
* @note
|
||||
* Behavior and usage notes:
|
||||
* - RTK service state updates are delivered via
|
||||
* DjiPositioning_RegReceiveNetworkRtkStateCallback. Monitor that callback
|
||||
* to observe state transitions (e.g., DJI_REBOOTING, DJI_TRANSFER).
|
||||
* - Note: If the current RTK source is NOT a custom network source, the first call
|
||||
* to this API will require a device reboot to switch to the network RTK
|
||||
* source. After the device reboots, you must call this API again to start
|
||||
* the Network RTK service so that it takes effect.
|
||||
* - DJI_REBOOTING indicates that a reboot is required/underway to apply the
|
||||
* change of RTK source. Note: the device will NOT reboot automatically;
|
||||
* a manual reboot is required to complete the change.
|
||||
* - DJI_TRANSFER indicates that the RTK service is connected and data
|
||||
* transfer between RTK endpoints has been established. DJI_TRANSFER does
|
||||
* NOT guarantee that the RTK solution has converged to a usable fix.
|
||||
* Convergence must be verified by subscribing to RTK positioning data and
|
||||
* checking the quality/accuracy indicators provided in those data messages.
|
||||
*
|
||||
* Recommended call sequence:
|
||||
* 1. Call DjiPositioning_StartNetworkRtkService().
|
||||
* 2. If state callback reports DJI_REBOOTING, perform a MANUAL reboot of the device.
|
||||
* 3. After the manual reboot, call DjiPositioning_StartNetworkRtkService() again.
|
||||
* 4. Monitor state callback for DJI_TRANSFER and subscribe to RTK position
|
||||
* data to verify convergence.
|
||||
* @param config [in] Pointer to a T_DjiNetworkRtkServiceConfig structure containing the configuration information for the network RTK service.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiNetworkRtk_StartService(const T_DjiNetworkRtkServiceConfig* config);
|
||||
|
||||
/**
|
||||
* @brief Stop the network RTK service.
|
||||
* @note After calling this function, the device will disconnect from the network RTK service and stop receiving high-precision positioning data.
|
||||
* @param None
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiNetworkRtk_StopService(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DIJ_CORE_H
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
||||
389
Source/M300/PSDK_Qt/psdk_lib/include/dji_open_ar.h
Normal file
389
Source/M300/PSDK_Qt/psdk_lib/include/dji_open_ar.h
Normal file
@ -0,0 +1,389 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file dji_open_ar.h
|
||||
* @brief This is the header file for "dji_open_ar.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2021 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef DJI_OPEN_AR_H
|
||||
#define DJI_OPEN_AR_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
float longitude;
|
||||
float latitude;
|
||||
float altitude;
|
||||
} T_DjiOpenArCoordinate;
|
||||
|
||||
/**
|
||||
* @brief Text information definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t is_show:1; /*!< Whether to display, 0: not display, 1: display */
|
||||
uint8_t text[30]; /*!< Text information, with '\0' as the terminator */
|
||||
} T_DjiOpenArTextAttribute;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t selected:1; /*!< Whether selected, 0: not selected, 1: selected */
|
||||
uint8_t visible :1; /*!< Whether to display, 0: not display, 1: display */
|
||||
uint32_t color; /*!< Contains alpha channel */
|
||||
} T_DjiOpenArIconAttribute;
|
||||
|
||||
/**
|
||||
* @brief Click action for a point
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t action; /*!< 0: click; 1: drag along the line; 2: drag from a distance */
|
||||
T_DjiOpenArCoordinate normal_vector; /*!< Dragging direction: normal vector */
|
||||
} T_DjiOpenArTouchAttribute;
|
||||
|
||||
/**
|
||||
* @brief Represents the unique identifier for AR elements
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t uuid; /*!< uuid used for updating and deleting */
|
||||
uint32_t style_id; /*!< used to index resources config, corresponding resource is configured in widget.json */
|
||||
} T_DjiOpenArIds;
|
||||
|
||||
/**
|
||||
* @brief AR face drawing attributes
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t dist_alpha_enable :1; /*!< Enable distance-based alpha blending (1) or not (0) */
|
||||
uint8_t face_bottom_enable:1; /*!< Enable drawing bottom face (1) or not (0) */
|
||||
uint8_t face_side_enable :1; /*!< Enable drawing side face (1) or not (0) */
|
||||
uint8_t face_top_enable :1; /*!< Enable drawing top face (1) or not (0) */
|
||||
} T_DjiOpenArPolygonFaceAttribute;
|
||||
|
||||
/**
|
||||
* @brief AR border drawing attributes
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t top_show :1;
|
||||
uint8_t top_dist_alpha_enable :1;
|
||||
uint8_t side_show :1;
|
||||
uint8_t side_dist_alpha_enable :1;
|
||||
uint8_t bottom_show :1;
|
||||
uint8_t bottom_dist_alpha_enable:1;
|
||||
} T_DjiOpenArPolygonStrokeAttribute;
|
||||
|
||||
/**
|
||||
* @brief AR pint drawing attibutes
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t uuid; /*!< uuid for point , used to updating and delting */
|
||||
uint32_t style_id; /*!< dentifier for the style associated with the point, define with widget.json */
|
||||
uint32_t resource_id; /*!< Identifier for the resource associated with the point */
|
||||
uint8_t is_always_in_edge; /*!< Whether the point is always on the edge */
|
||||
T_DjiOpenArCoordinate coordinate; /*!< Physical position in the world coordinate system */
|
||||
T_DjiOpenArTextAttribute text_attr; /*!< Attributes related to the text associated with the point */
|
||||
T_DjiOpenArIconAttribute icon_attr; /*!< Attributes related to the icon associated with the point */
|
||||
T_DjiOpenArTouchAttribute touch_attr; /*!< Attributes related to touch interactions with the point */
|
||||
} T_DjiOpenArPoint;
|
||||
|
||||
/**
|
||||
* @brief Array of points
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t len; /*!< Length of the array (number of points) */
|
||||
T_DjiOpenArPoint points[0]; /*!< 0 length implies dynamic allocation */
|
||||
} T_DjiOpenArPointArray;
|
||||
|
||||
/**
|
||||
* @biref AR Drawing Line
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
T_DjiOpenArIds ids; /*!< uuids for the AR line */
|
||||
T_DjiOpenArPointArray point_array; /*!< Array of points defining the line */
|
||||
} T_DjiOpenArLine;
|
||||
|
||||
/**
|
||||
* @brief AR Drawing Polygon
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
T_DjiOpenArIds ids; /*!< Unique identifiers for the AR polygon */
|
||||
T_DjiOpenArCoordinate normal_vector; /*!< Normal vector of the polygon surface */
|
||||
T_DjiOpenArPolygonFaceAttribute face; /*!< Face attributes of the polygon */
|
||||
T_DjiOpenArPolygonStrokeAttribute stroke; /*!< Stroke attributes of the polygon */
|
||||
T_DjiOpenArPointArray point_array; /*!< Array of points defining the polygon */
|
||||
} T_DjiOpenArPolygon;
|
||||
|
||||
/**
|
||||
* @brief AR Drawing Circle
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
T_DjiOpenArIds ids; /*!< Unique identifiers for the AR circle */
|
||||
float radius; /*!< Radius of the circle */
|
||||
T_DjiOpenArCoordinate center; /*!< Center coordinates of the circle */
|
||||
T_DjiOpenArCoordinate normal_vector; /*!< Normal vector of the circle's surface */
|
||||
T_DjiOpenArPolygonFaceAttribute face; /*!< Face attributes of the circle */
|
||||
T_DjiOpenArPolygonStrokeAttribute stroke; /*!< Stroke attributes of the circle */
|
||||
} T_DjiOpenArCircle;
|
||||
|
||||
/**
|
||||
* @brief AR Drawing 3D Cone Pivot Axis
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
T_DjiOpenArIds ids; /*!< Unique identifiers for the 3D cone */
|
||||
uint8_t show_enable; /*!< Flag indicating if the cone should be displayed (1) or not (0) */
|
||||
T_DjiOpenArCoordinate pivot; /*!< Center point of the cone */
|
||||
T_DjiOpenArCoordinate normal_vector; /*!< Normal vector for the cone's surface */
|
||||
} T_DjiOpenArPivotAxis;
|
||||
|
||||
/**
|
||||
* @brief eletion Entry for Specified Point, Face, Line, etc.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t resource_id; /*!< Resource ID for the element to be deleted */
|
||||
uint32_t uuid_len; /*!< Length of the UUID array */
|
||||
uint32_t uuid_array[0]; /*!< Array of UUIDs to identify the elements to be deleted */
|
||||
} T_DjiOpenArDeletePointEntry;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t uuid;
|
||||
} T_DjiOpenArDeleteCommonEntry;
|
||||
|
||||
/**
|
||||
* @brief Typedef for deletion of line entries
|
||||
*/
|
||||
typedef T_DjiOpenArDeleteCommonEntry T_DjiOpenArDeleteLineEntry;
|
||||
|
||||
/**
|
||||
* @brief Typedef for deletion of polygon entries
|
||||
*/
|
||||
typedef T_DjiOpenArDeleteCommonEntry T_DjiOpenArDeletePolygonEntry;
|
||||
|
||||
/**
|
||||
* @brief Typedef for deletion of circle entries
|
||||
*/
|
||||
typedef T_DjiOpenArDeleteCommonEntry T_DjiOpenArDeleteCircleEntry;
|
||||
|
||||
/**
|
||||
* @brief Typedef for deletion of pivot axis entries
|
||||
*/
|
||||
typedef T_DjiOpenArDeleteCommonEntry T_DjiOpenArDeletePovixAxisEntry;
|
||||
|
||||
/**
|
||||
* @brief Set the ar point.
|
||||
* @param metaData: the information for Ar point.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArSetPoint(const T_DjiOpenArPointArray* entry);
|
||||
|
||||
/**
|
||||
* @brief Update the ar point.
|
||||
* @param metaData: the information for Ar point.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArUpdatePoint(const T_DjiOpenArPointArray* entry);
|
||||
|
||||
/**
|
||||
* @brief Delete the ar point
|
||||
* @param metaData: the information for Ar point.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArDeletePoint(const T_DjiOpenArDeletePointEntry* entry);
|
||||
|
||||
/**
|
||||
* @brief Clear the ar point
|
||||
* @param metaData: the resource id for Ar point.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArClearPoint(uint32_t resource_id);
|
||||
|
||||
/**
|
||||
* @brief Set the ar line
|
||||
* @param metaData: the ar line information for setting.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArSetLine(const T_DjiOpenArLine* entry);
|
||||
|
||||
/**
|
||||
* @brief Update the ar line
|
||||
* @param metaData: The ar line information
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArUpdateLine(const T_DjiOpenArLine* entry);
|
||||
|
||||
/**
|
||||
* @brief Delete the ar line
|
||||
* @param metaData: The ar line entry for delete
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArDeleteLine(const T_DjiOpenArDeleteLineEntry* entry, uint32_t entry_len);
|
||||
|
||||
/**
|
||||
* @brief Clear the ar line.
|
||||
* @param metaData: The ar line information for clear.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArClearLine();
|
||||
|
||||
/**
|
||||
* @brief Set the ar polygon.
|
||||
* @param metaData: The ar polygon information for setting.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArSetPolygon(const T_DjiOpenArPolygon* entry);
|
||||
|
||||
/**
|
||||
* @brief Update the ar polygon.
|
||||
* @param metaData: The ar polygon information for update.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArUpdatePolygon(const T_DjiOpenArPolygon* entry);
|
||||
|
||||
/**
|
||||
* @brief Delete the ar polygon.
|
||||
* @param metaData: The polygon entry information for delete.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArDeletePolygon(const T_DjiOpenArDeletePolygonEntry* entry, uint32_t entry_len);
|
||||
|
||||
/**
|
||||
* @brief Clear the ar polygon.
|
||||
* @param metaData: none
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArClearPolygon();
|
||||
|
||||
/**
|
||||
* @brief Set the ar circle.
|
||||
* @param metaData: The ar circle information for setting.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArSetCircle(const T_DjiOpenArCircle* entry);
|
||||
|
||||
/**
|
||||
* @brief Update the ar circle.
|
||||
* @param metaData: The ar circle information for update.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArUpdateCircle(const T_DjiOpenArCircle* entry);
|
||||
|
||||
/**
|
||||
* @brief Delete the ar circle.
|
||||
* @param metaData: The ar circle information for delete.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArDeleteCircle(const T_DjiOpenArDeleteCircleEntry* entry, uint32_t entry_len);
|
||||
|
||||
/**
|
||||
* @brief Clear the ar circle.
|
||||
* @param metaData: The ar circle information for clear.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArClearCircle();
|
||||
|
||||
/**
|
||||
* @brief Set the pivot axis.
|
||||
* @param metaData: The pivot axis information for setting.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArSetPivotAxis(const T_DjiOpenArPivotAxis* entry);
|
||||
|
||||
/**
|
||||
* @brief Update the pivot axis.
|
||||
* @param metaData: The pivot axis information for update.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArUpdatePivotAxis(const T_DjiOpenArPivotAxis* entry);
|
||||
|
||||
/**
|
||||
* @brief Delete the pivot axis.
|
||||
* @param metaData: The pivot axis information for delete.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArDeletePivotAxis(const T_DjiOpenArDeletePovixAxisEntry* entry, uint32_t entry_len);
|
||||
|
||||
/**
|
||||
* @brief Clear the pivot axis.
|
||||
* @param metaData: none
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArClearPivotAxis();
|
||||
|
||||
/**
|
||||
* @brief Once entering this callback it is necessary to reflesh all AR drawings.
|
||||
* @param metaData: none
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
typedef void (*DjiLiveview_ArRefleshAllCallback)(void);
|
||||
|
||||
/**
|
||||
* @brief Register the ar refresh function.
|
||||
* @param metaData: The ar reflesh callback function.
|
||||
* @note This interface support on DJI manifold3.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiLiveview_ArRegRefleshAllCallback(DjiLiveview_ArRefleshAllCallback callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DJI_OPEN_AR_H
|
||||
@ -173,6 +173,8 @@ typedef struct {
|
||||
bool isShootingIntervalStart; /*!< Specifies if the camera is in interval shooting start status. This parameter is boolean type. */
|
||||
uint16_t currentPhotoShootingIntervalTimeInSeconds; /*!< Specifies the current interval shoot countdown time, the value is decreasing,
|
||||
* when the value equals to zero trigger the interval take photo, uint:s. */
|
||||
uint16_t currentPhotoShootingIntervalTimeInMs; /*!< Specifies the current interval shoot countdown time of millisecond part, the value is decreasing,
|
||||
* when the value equals to zero trigger the interval take photo, uint:ms. */
|
||||
uint16_t currentPhotoShootingIntervalCount; /*!< Specifies the current interval photo count, the value is decreasing step by one from
|
||||
* the setted count when interval taking photo */
|
||||
bool isRecording; /*!< Specifies if the camera is in recording status. This parameter is boolean type. */
|
||||
@ -841,7 +843,7 @@ T_DjiReturnCode DjiPayloadCamera_RegMediaDownloadPlaybackHandler(const T_DjiCame
|
||||
* @param len: length of data to be sent via data stream, and it must be less than or equal to 65000, unit: byte.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiPayloadCamera_SendVideoStream(const uint8_t *data, uint16_t len);
|
||||
T_DjiReturnCode DjiPayloadCamera_SendVideoStream(const uint8_t *data, uint32_t len);
|
||||
|
||||
/**
|
||||
* @brief Get data transmission state of "videoStream" channel. User can use the state as base for controlling data
|
||||
|
||||
@ -39,6 +39,8 @@ extern "C" {
|
||||
#define DJI_PERCEPTION_INTRINSICS_PARAM_ARRAY_NUM 9
|
||||
#define DJI_PERCEPTION_ROTATION_PARAM_ARRAY_NUM 9
|
||||
#define DJI_PERCEPTION_TRANSLATION_PARAM_ARRAY_NUM 3
|
||||
#define DJI_PTS_NUM_PER_PKG 96
|
||||
#define DJI_LIDAR_PKG_BUFFER_NUM 564
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/**
|
||||
@ -71,6 +73,19 @@ typedef enum {
|
||||
RECTIFY_RIGHT_RIGHT = 26
|
||||
} E_DjiPerceptionCameraPosition;
|
||||
|
||||
/**
|
||||
* @bref Perception radar design location
|
||||
*/
|
||||
typedef enum {
|
||||
RADAR_POSITION_LEFT = 0,
|
||||
RADAR_POSITION_RIGHT = 1,
|
||||
RADAR_POSITION_DOWN =2,
|
||||
RADAR_POSITION_UP = 3,
|
||||
RADAR_POSITION_FRONT = 4,
|
||||
RADAR_POSITION_BACK =5,
|
||||
MAX_RADAR_NUM = 6,
|
||||
}E_DjiPerceptionRadarPosition;
|
||||
|
||||
#pragma pack(1)
|
||||
/**
|
||||
* @bref Perception camera ram image info
|
||||
@ -114,14 +129,217 @@ typedef struct {
|
||||
uint32_t directionNum;
|
||||
T_DjiPerceptionCameraParameters cameraParameters[IMAGE_MAX_DIRECTION_NUM];
|
||||
} T_DjiPerceptionCameraParametersPacket;
|
||||
|
||||
/**
|
||||
* @bref Perception Lidar data point info
|
||||
*/
|
||||
typedef struct{
|
||||
float x; /*!< unit: meters */
|
||||
float y; /*!< unit: meters */
|
||||
float z; /*!< unit: meters */
|
||||
uint8_t intensity;
|
||||
uint8_t label; /*!< Noise filtering results (0: obj; 1: noise; 2: unknow; 3: not_retuen ) */
|
||||
} T_DJIPerceptionLidarPoint;
|
||||
|
||||
/**
|
||||
* @bref Perception Lidar data header of each pkg
|
||||
*/
|
||||
typedef struct{
|
||||
uint16_t timeInterval; /*!< The point cloud sampling time (in 0.1us) */
|
||||
uint16_t dotNum; /*!< Current packet data field contains the number of points This field is not valid for non-repeat scans*/
|
||||
uint8_t dataType; /** dataType
|
||||
*
|
||||
* Bit Position (7-4) | Field Name | Description | Remarks
|
||||
* ------------------ | ------------ | -------------------- | -------------------------------------------------
|
||||
* 4-7 | echo_mode | Echo Mode | 0: Single echo mode
|
||||
* | | | 1: Dual echo mode
|
||||
* | | | 2: Triple echo mode
|
||||
* | | | 3: Quadruple echo mode
|
||||
* | | | 4: Quintuple echo mode
|
||||
*
|
||||
* Bit Position (3-0) | Field Name | Description | Remarks
|
||||
* ------------------ | ------------ | -------------------- | -------------------------------------------------
|
||||
* 0-3 | data_type | Data Type | 40: IMU Data
|
||||
* | | | 1: Point cloud data (rectangular, 32-bit)
|
||||
* | | | 2: Point cloud data (rectangular, 16-bit default)
|
||||
* | | | 3: Point cloud data (spherical)
|
||||
* | | | 4: Point cloud data (rectangular, 20-bit, in use)
|
||||
*/
|
||||
uint8_t timeType; /** timeType
|
||||
* Timestamp Type | Sync Source Type | Data Format | Description
|
||||
* -------------- | ------------------- | ------------- | -------------------------------------------------
|
||||
* 0 | No sync source, | uint64_t | Timestamp is radar uptime, unit: ns
|
||||
* | | |
|
||||
* 1 | gPTP/PTP sync, | uint64_t | Timestamp is master clock source time, unit: ns
|
||||
* | | |
|
||||
* 2 | PPS + ns time sync | uint64_t | Unit: ns
|
||||
* | | |
|
||||
* 3 | PPS + UTC | uint64_t | UTC format is:
|
||||
* | | struct | struct {
|
||||
* | | | uint8_t year;
|
||||
* | | | uint8_t mon;
|
||||
* | | | uint8_t day;
|
||||
* | | | uint8_t hour;
|
||||
* | | | uint32_t us_offset;
|
||||
* | | | };
|
||||
*/
|
||||
uint64_t timeStamp;
|
||||
}T_DJIPerceptionLidarDataHeader;
|
||||
|
||||
/**
|
||||
* @bref Perception Lidar data pkg
|
||||
*/
|
||||
typedef struct{
|
||||
T_DJIPerceptionLidarDataHeader header;
|
||||
T_DJIPerceptionLidarPoint points[DJI_PTS_NUM_PER_PKG];
|
||||
}T_DjiPerceptionLidarDecodePkg;
|
||||
|
||||
/**
|
||||
* @bref Perception Lidar data frame
|
||||
*/
|
||||
typedef struct{
|
||||
uint64_t timeStampNs; /*!< Timestamp of the first point of each packet */
|
||||
uint32_t frameCnt; /*!< in increasing order from zero */
|
||||
uint16_t pkgNum; /*!< Number of valid pkgs per frame */
|
||||
T_DjiPerceptionLidarDecodePkg pkgs[DJI_LIDAR_PKG_BUFFER_NUM];
|
||||
uint32_t poseTimeMs;
|
||||
uint16_t naviFlag; /** naviFlag:
|
||||
* Bit Position | Field Name | Description | Remarks
|
||||
* ------------ | ---------- | ------------------------------------------------ | -----------------------------------
|
||||
* 0 | vel_x | Horizontal x-axis velocity valid bit (1 valid) | 1 - valid, 0 - invalid
|
||||
* 1 | vel_y | Horizontal y-axis velocity valid bit (1 valid) | 1 - valid, 0 - invalid
|
||||
* 2 | vel_z | Vertical velocity valid bit (1 valid) | 1 - valid, 0 - invalid
|
||||
* 3 | pos_x | Horizontal x-axis position valid bit (1 valid) | 1 - valid, 0 - invalid
|
||||
* 4 | pos_y | Horizontal y-axis position valid bit (1 valid) | 1 - valid, 0 - invalid
|
||||
* 5 | pos_z | Vertical position valid bit (1 valid) | 1 - valid, 0 - invalid
|
||||
* 6 | dwn_vz | Ground speed valid bit (1 valid) | 1 - valid, 0 - invalid
|
||||
* 7 | dwn_pz | Ground elevation valid bit (1 valid) | 1 - valid, 0 - invalid
|
||||
* 8 | rtk_pxy | RTK horizontal valid flag (1 valid) | 1 - valid, 0 - invalid
|
||||
* 9 | rtk_pz | RTK vertical valid flag (1 valid) | 1 - valid, 0 - invalid
|
||||
* 10 | gns_ll | GPS horizontal valid flag (1 valid) | 1 - valid, vertical direction always invalid
|
||||
* 11 | fg_ok | FG estimate OK flag (1 valid) | 1 - valid, 0 - invalid
|
||||
* 12-15 | fg_st | FG mode (4 bits) | Modes:
|
||||
* | | | 0 - Random initialization
|
||||
* | | | 1 - Initialization with poor compass
|
||||
* | | | 2 - Initialization with good compass
|
||||
* | | | 3 - Magnetic inclination compensation
|
||||
* | | | 4 - Compass fix during takeoff
|
||||
* | | | 5 - Compass fix in the air
|
||||
* | | | 6 - Compass calibration fix
|
||||
* | | | 7 - Accelerometer alignment
|
||||
* | | | 8 - Speed alignment
|
||||
* | | | 9 - RTK heading alignment
|
||||
*/
|
||||
float naviPos[3]; /*!< UAV IMU to navigation coordinate system translation vector (xyz) */
|
||||
float naviQuat[4]; /*!< Quaternions from UAV IMU to navigation coordinate system */
|
||||
}T_DjiLidarFrame;
|
||||
|
||||
/**
|
||||
* @bref Radar data frame header
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t dataLen;
|
||||
uint8_t curPack; /*!< The current packet number, in the range of [1, pack_num]. */
|
||||
uint8_t packNum; /*!< Total number of current circle packets, starting from 1. */
|
||||
} T_DjiRadarDataHeader;
|
||||
|
||||
/**
|
||||
* @bref Radar information structure
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t velocity :16; /**
|
||||
* Calculating the actual velocity:
|
||||
*
|
||||
* Actual velocity (m/s) = (Velocity - 32767) / 100
|
||||
*
|
||||
* Interpreting the results:
|
||||
* - If the result is > 0, it indicates that the object is moving closer to the target.
|
||||
* - If the result is < 0, it indicates that the object is moving away from the target.
|
||||
*/
|
||||
uint64_t snr :7; /*!< target SNR, in db, ranging from 0 to 127, with 0 being the null point or no echo point
|
||||
(base_noise calculation base_noise = energy / snr) */
|
||||
uint64_t beamAngle:10; /**
|
||||
* Beam emission angle value:
|
||||
* - Unit: 0.01 degrees
|
||||
* - Stored range: 0~1023
|
||||
* - Actual value range: [-45°, 45°]
|
||||
*
|
||||
* Conversion method:
|
||||
* - Divide stored value x by 10
|
||||
* - If x ≤ 450, the angle remains unchanged
|
||||
* - If x > 450, the angle is adjusted by subtracting 90
|
||||
*
|
||||
* Examples:
|
||||
* - Stored value of 449 yields an angle of 44.9° (449/10 = 44.9°)
|
||||
* - Stored value of 451 yields an angle of -44.9° (451/10 - 90 = -44.9°)
|
||||
* invalid in M400
|
||||
*/
|
||||
|
||||
uint64_t radarType:3; /*!< Radar numbe,is invalid in M400*/
|
||||
|
||||
uint64_t clitterFlag:1; /*!< Flag for clutter point in planar radar: 1 indicates a clutter point, 0 indicates a valid point */
|
||||
|
||||
uint64_t reserved :27;
|
||||
} T_DjiRadarBaseInfo;
|
||||
|
||||
/**
|
||||
* @bref The single point data structure of millimeter wave radar
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t azimuth; /*!
|
||||
* Target azimuth in radar coordinate system:
|
||||
* - Unit: 0.001 radian
|
||||
* - Value range: (0 to 2π) / 0.001
|
||||
* - Calculation method (azimuth/1000 - 2π)
|
||||
*/
|
||||
uint16_t elevation; /*!
|
||||
* Target pitch angle in radar coordinate system:
|
||||
* - Unit: 0.001 radian
|
||||
* - Value range: (0 to 2π) / 0.001
|
||||
* - Calculation method (elevation/1000 - 2π)
|
||||
*/
|
||||
uint16_t radius; /*!
|
||||
* Target radial distance in radar coordinate system:
|
||||
* - Unit: 0.01 meters
|
||||
* - Value range: 0 to 65553 (in steps of 0.01 meters)
|
||||
*/
|
||||
uint16_t ene; /*!
|
||||
* Radar target energy
|
||||
* - Actual value: energy / 100
|
||||
* - invalid in M400
|
||||
*/
|
||||
T_DjiRadarBaseInfo base_info;
|
||||
}T_DjiRadarCloudUnit;
|
||||
|
||||
/**
|
||||
* @bref Perception Radar data frame
|
||||
*/
|
||||
typedef struct {
|
||||
T_DjiRadarDataHeader headInfo;
|
||||
T_DjiRadarCloudUnit data[1];
|
||||
} T_DjiRadarDataFrame;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/**
|
||||
* @bref Callback type to receive stereo camera image
|
||||
* @note It is not recommended to perform blocking operations in the callback, as it may lead to data loss.
|
||||
*/
|
||||
typedef void(*DjiPerceptionImageCallback)(T_DjiPerceptionImageInfo imageInfo, uint8_t *imageRawBuffer,
|
||||
uint32_t bufferLen);
|
||||
|
||||
/**
|
||||
* @bref Callback type to receive radar data
|
||||
* @note It is not recommended to perform blocking operations in the callback, as it may lead to data loss.
|
||||
*/
|
||||
typedef void(*DjiPerceptionRadarCallback)(E_DjiPerceptionRadarPosition radarPosition, uint8_t *radarDataBuffer,
|
||||
uint32_t bufferLen);
|
||||
/**
|
||||
* @bref Callback type to process Lidar data
|
||||
* @note It is not recommended to perform blocking operations in the callback, as it may lead to data loss.
|
||||
*/
|
||||
typedef void(*DjiPerceptionLidarDataCallback)(uint8_t* lidarDataBuffer, uint32_t bufferLen);
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Initialize the perception module.
|
||||
@ -147,18 +365,44 @@ T_DjiReturnCode DjiPerception_SubscribePerceptionImage(E_DjiPerceptionDirection
|
||||
|
||||
/**
|
||||
* @brief Unsubscribe the raw image of both stereo cameras in the same direction.
|
||||
* @param direction: direction to specify the direction of the subscription. Ref to E_DjiPerceptionDirection
|
||||
* @param direction: direction to specify the direction of the subscription. Ref to E_DjiPerceptionDirection.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiPerception_UnsubscribePerceptionImage(E_DjiPerceptionDirection direction);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the internal and external parameters of all stereo cameras.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiPerception_GetStereoCameraParameters(T_DjiPerceptionCameraParametersPacket *packet);
|
||||
|
||||
/**
|
||||
* @brief Subscribe the lidar data.
|
||||
* @param callback: callback to observer the radar data.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiPerception_SubscribeLidarData(DjiPerceptionLidarDataCallback callback);
|
||||
|
||||
/**
|
||||
* @brief Unsubscribe the lidar data.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiPerception_UnsubscribeLidarData(void);
|
||||
|
||||
/**
|
||||
* @brief Subscribe the lidar data of the position.
|
||||
* @param position: position the radar monted
|
||||
* @param callback callback to observer the radar data.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiPerception_SubscribeRadarData(E_DjiPerceptionRadarPosition position, DjiPerceptionRadarCallback callback);
|
||||
|
||||
/**
|
||||
* @brief Unsubscribe the lidar data of the position.
|
||||
* @param position: position the radar monted
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiPerception_UnsubscribeRadarData(E_DjiPerceptionRadarPosition position);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -52,6 +52,11 @@ typedef void *T_DjiUsbBulkHandle;
|
||||
*/
|
||||
typedef void *T_DjiNetworkHandle;
|
||||
|
||||
/**
|
||||
* @brief Platform handle of i2c device operation.
|
||||
*/
|
||||
typedef void *T_DjiI2cHandle;
|
||||
|
||||
/**
|
||||
* @brief Platform handle of thread task operation.
|
||||
*/
|
||||
@ -104,6 +109,7 @@ typedef enum {
|
||||
typedef enum {
|
||||
DJI_HAL_USB_BULK_NUM_0 = 0,
|
||||
DJI_HAL_USB_BULK_NUM_1,
|
||||
DJI_HAL_USB_BULK_NUM_2,
|
||||
DJI_HAL_USB_BULK_NUM_MAX,
|
||||
} E_DjiHalUsbBulkNum;
|
||||
|
||||
@ -133,6 +139,11 @@ typedef struct {
|
||||
bool isDir;
|
||||
} T_DjiFileInfo;
|
||||
|
||||
typedef struct {
|
||||
uint16_t pid;
|
||||
uint16_t vid;
|
||||
} T_DjiHalUartDeviceInfo;
|
||||
|
||||
typedef struct {
|
||||
T_DjiReturnCode (*UartInit)(E_DjiHalUartNum uartNum, uint32_t baudRate, T_DjiUartHandle *uartHandle);
|
||||
|
||||
@ -143,6 +154,13 @@ typedef struct {
|
||||
T_DjiReturnCode (*UartReadData)(T_DjiUartHandle uartHandle, uint8_t *buf, uint32_t len, uint32_t *realLen);
|
||||
|
||||
T_DjiReturnCode (*UartGetStatus)(E_DjiHalUartNum uartNum, T_DjiUartStatus *status);
|
||||
|
||||
/**
|
||||
* Get the device info of USB uart (virtual com or TTL-To-USB) which directly connected to UAV.
|
||||
* Use for SDK adapter type Eport V2 ribbon cable.
|
||||
* When using other types of interface, it is not necessary to implement this member function.
|
||||
*/
|
||||
T_DjiReturnCode (*UartGetDeviceInfo)(T_DjiHalUartDeviceInfo *deviceInfo);
|
||||
} T_DjiHalUartHandler;
|
||||
|
||||
typedef struct {
|
||||
@ -172,6 +190,11 @@ typedef struct {
|
||||
} usbNetAdapter;
|
||||
} T_DjiHalNetworkDeviceInfo;
|
||||
|
||||
typedef struct {
|
||||
uint32_t i2cSpeed;
|
||||
uint16_t devAddress;
|
||||
} T_DjiHalI2cConfig;
|
||||
|
||||
typedef struct {
|
||||
T_DjiReturnCode (*UsbBulkInit)(T_DjiHalUsbBulkInfo usbBulkInfo, T_DjiUsbBulkHandle *usbBulkHandle);
|
||||
|
||||
@ -194,6 +217,18 @@ typedef struct {
|
||||
T_DjiReturnCode (*NetworkGetDeviceInfo)(T_DjiHalNetworkDeviceInfo *deviceInfo);
|
||||
} T_DjiHalNetworkHandler;
|
||||
|
||||
typedef struct {
|
||||
T_DjiReturnCode (*I2cInit)(T_DjiHalI2cConfig i2cConfig, T_DjiI2cHandle *i2cHandle);
|
||||
|
||||
T_DjiReturnCode (*I2cDeInit)(T_DjiI2cHandle i2cHandle);
|
||||
|
||||
T_DjiReturnCode (*I2cWriteData)(T_DjiI2cHandle i2cHandle, uint16_t devAddress, const uint8_t *buf,
|
||||
uint32_t len, uint32_t *realLen);
|
||||
|
||||
T_DjiReturnCode (*I2cReadData)(T_DjiI2cHandle i2cHandle, uint16_t devAddress, uint8_t *buf,
|
||||
uint32_t len, uint32_t *realLen);
|
||||
} T_DjiHalI2cHandler;
|
||||
|
||||
typedef struct {
|
||||
T_DjiReturnCode (*TaskCreate)(const char *name, void *(*taskFunc)(void *),
|
||||
uint32_t stackSize, void *arg, T_DjiTaskHandle *task);
|
||||
@ -314,11 +349,24 @@ T_DjiReturnCode DjiPlatform_RegHalUsbBulkHandler(const T_DjiHalUsbBulkHandler *h
|
||||
* sure that the feature is available after a successful registration.
|
||||
* @attention The interface needs to be called at the beginning of the application for registration, otherwise, the
|
||||
* subsequent functions will not work properly.
|
||||
* @param osalHandler: pointer to the handler for network handler interfaces by your platform.
|
||||
* @param halNetworkHandler: pointer to the handler for network handler interfaces by your platform.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiPlatform_RegHalNetworkHandler(const T_DjiHalNetworkHandler *halNetworkHandler);
|
||||
|
||||
/**
|
||||
* @brief Register the handler for hal i2c master mode interfaces by your platform.
|
||||
* @note It should be noted that the interface in hal is written and tested well. Users need to implement all the
|
||||
* interfaces. Otherwise, the user interface cannot be successfully registered, and then the user interface is registered
|
||||
* through the interface. If the registration fails, it needs to be based on the return code. To judge the problem. Make
|
||||
* sure that the feature is available after a successful registration.
|
||||
* @attention The interface needs to be called at the beginning of the application for registration, otherwise, the
|
||||
* subsequent functions will not work properly.
|
||||
* @param halI2cHandler: pointer to the handler for hal i2c handler interfaces by your platform.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiPlatform_RegHalI2cHandler(const T_DjiHalI2cHandler *halI2cHandler);
|
||||
|
||||
/**
|
||||
* @brief Register the handler for osal interfaces by your platform.
|
||||
* @note It should be noted that the interface in osal is written and tested well. Users need to implement all the
|
||||
@ -363,6 +411,12 @@ T_DjiHalUsbBulkHandler *DjiPlatform_GetHalUsbBulkHandler(void);
|
||||
*/
|
||||
T_DjiHalNetworkHandler *DjiPlatform_GetHalNetworkHandler(void);
|
||||
|
||||
/**
|
||||
* @brief Get the handler of i2c interfaces.
|
||||
* @return Pointer to i2c handler.
|
||||
*/
|
||||
T_DjiHalI2cHandler *DjiPlatform_GetHalI2cHandler(void);
|
||||
|
||||
/**
|
||||
* @brief Get the handler of file-system interfaces.
|
||||
* @return Pointer to file-system handler.
|
||||
|
||||
@ -45,6 +45,12 @@ typedef enum {
|
||||
DJI_POWER_MANAGEMENT_PIN_STATE_SET = 1, /*!< Specifies pin is in high level state. */
|
||||
} E_DjiPowerManagementPinState;
|
||||
|
||||
typedef enum {
|
||||
E_DJI_HIGH_POWER_VOLTAGE_13V6 = 0, /*!< Specifies pin is in 13.6V of voltage */
|
||||
E_DJI_HIGH_POWER_VOLTAGE_17V = 1, /*!< Specifies pin is in 17V of voltage */
|
||||
E_DJI_HIGH_POWER_VOLTAGE_24V = 2, /*!< Specifies pin is in 24V of voltage */
|
||||
} E_DjiHighPowerVoltage;
|
||||
|
||||
/**
|
||||
* @brief Prototype of callback function used to set level of high power application pin.
|
||||
* @param pinState: level state of pin to be set.
|
||||
@ -87,6 +93,17 @@ T_DjiReturnCode DjiPowerManagement_DeInit(void);
|
||||
*/
|
||||
T_DjiReturnCode DjiPowerManagement_ApplyHighPowerSync(void);
|
||||
|
||||
/**
|
||||
* @brief Apply high power from aircraft in blocking mode.
|
||||
* @details Before applying, user should register callback function used to set level state of high power application
|
||||
* pin using DjiPowerManagement_RegWriteHighPowerApplyPinCallback() function. After applying high power, power pin of
|
||||
* DJI adapter will output high power based predetermined specification.
|
||||
* @note Max execution time of this function is slightly larger than 600ms.
|
||||
* @param voltage: The voltage value will be applied to the VCC pin.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiPowerManagement_ApplyHighPowerSyncV2(E_DjiHighPowerVoltage voltage);
|
||||
|
||||
/**
|
||||
* @brief Register callback function used to set level state of high power application pin. Must be called before
|
||||
* applying high power.
|
||||
@ -108,6 +125,15 @@ T_DjiReturnCode DjiPowerManagement_RegWriteHighPowerApplyPinCallback(DjiWriteHig
|
||||
*/
|
||||
T_DjiReturnCode DjiPowerManagement_RegPowerOffNotificationCallback(DjiPowerOffNotificationCallback callback);
|
||||
|
||||
/**
|
||||
* @brief manifold3 outputs high voltage to external devices
|
||||
* @param stat: true: output high voltage, false: output low voltage
|
||||
* @return Execution result.
|
||||
* @note The gpio12 of manifold3 should be pulled down before requesting a high voltage output.
|
||||
* @note This interface support on DJI manifold3.
|
||||
*/
|
||||
T_DjiReturnCode DjiPowerManagement_OutputHighPower(bool stat);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
77
Source/M300/PSDK_Qt/psdk_lib/include/dji_tethered_battery.h
Normal file
77
Source/M300/PSDK_Qt/psdk_lib/include/dji_tethered_battery.h
Normal file
@ -0,0 +1,77 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file dji_tethered_battery.h
|
||||
* @brief This is the header file for "dji_tethered_battery.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2024 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef DJI_TETHERED_BATTERY_H
|
||||
#define DJI_TETHERED_BATTERY_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Tether line status.
|
||||
*/
|
||||
typedef struct {
|
||||
dji_f32_t totalLength; /*!< total length of tether line, range: 0-300, unit: meters. */
|
||||
dji_f32_t usedLength; /*!< used length of tether line, range: 0-300, unit: meters.
|
||||
This value must be less than or equal to the total length of tether line. */
|
||||
} T_DjiTetherLineStatus;
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Initialise tethered battery module
|
||||
* @note User should call this function before using tethered battery features.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiTetheredBattery_Init(void);
|
||||
|
||||
/**
|
||||
* @brief DeInitialize tethered battery module.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiTetheredBattery_DeInit(void);
|
||||
|
||||
/**
|
||||
* @brief Push the real-time tether line length to the Pilot2 for display.
|
||||
* @note It is recommended that the push frequency does not exceed the data update frequency. The maximum push
|
||||
* frequency should not exceed 10Hz.
|
||||
* @param tetherLineStatus: the tether line status.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiTetheredBattery_PushTetherLineStatus(T_DjiTetherLineStatus tetherLineStatus);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DJI_TETHERED_BATTERY_H
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
||||
@ -44,8 +44,9 @@ extern "C" {
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define DJI_PI (3.14159265358979323846f)
|
||||
#define DJI_FILE_NAME_SIZE_MAX 256
|
||||
#define DJI_FILE_MD5_LENGTH 16
|
||||
#define DJI_FILE_PATH_SIZE_MAX (DJI_FILE_NAME_SIZE_MAX + 256)
|
||||
#define DJI_IP_ADDR_STR_SIZE_MAX 15
|
||||
#define DJI_IP_ADDR_STR_SIZE_MAX 16
|
||||
#define DJI_MD5_BUFFER_LEN 16
|
||||
|
||||
#define DJI_SUBSCRIPTION_MODULE_INDEX_OFFSET 24u
|
||||
@ -58,6 +59,12 @@ extern "C" {
|
||||
(((((uint32_t)(subscriptionModule)) << (DJI_SUBSCRIPTION_MODULE_INDEX_OFFSET)) & (DJI_SUBSCRIPTION_MODULE_INDEX_MASK)) | \
|
||||
((((uint32_t)(topicCode)) << (DJI_SUBSCRIPTION_TOPIC_CODE_OFFSET)) & (DJI_SUBSCRIPTION_TOPIC_CODE_MASK)))
|
||||
|
||||
#define DJI_DATA_SUBSCRIPTION_TOPIC_GET_MODULE(topic) \
|
||||
((uint32_t)((topic & DJI_SUBSCRIPTION_MODULE_INDEX_MASK) >> DJI_SUBSCRIPTION_MODULE_INDEX_OFFSET))
|
||||
|
||||
#define DJI_DATA_SUBSCRIPTION_TOPIC_GET_CODE(topic) \
|
||||
((uint32_t)((topic & DJI_SUBSCRIPTION_TOPIC_CODE_MASK) >> DJI_SUBSCRIPTION_TOPIC_CODE_OFFSET))
|
||||
|
||||
/**
|
||||
* @brief Type define double as dji_f64_t.
|
||||
*/
|
||||
@ -76,7 +83,9 @@ typedef enum {
|
||||
DJI_MOUNT_POSITION_TYPE_UNKNOWN = 0,
|
||||
DJI_MOUNT_POSITION_TYPE_PAYLOAD_PORT = 1,
|
||||
DJI_MOUNT_POSITION_TYPE_EXTENSION_PORT = 2,
|
||||
DJI_MOUNT_POSITION_TYPE_EXTENSION_LITE_PORT = 3
|
||||
DJI_MOUNT_POSITION_TYPE_EXTENSION_LITE_PORT = 3,
|
||||
DJI_MOUNT_POSITION_TYPE_EXTENSION_PORT_V2 = 4,
|
||||
DJI_MOUNT_POSITION_TYPE_MANIFOLD3_ONBOARD = 5,
|
||||
} E_DjiMountPositionType;
|
||||
|
||||
typedef enum {
|
||||
@ -84,8 +93,16 @@ typedef enum {
|
||||
DJI_MOUNT_POSITION_PAYLOAD_PORT_NO1 = 1,
|
||||
DJI_MOUNT_POSITION_PAYLOAD_PORT_NO2 = 2,
|
||||
DJI_MOUNT_POSITION_PAYLOAD_PORT_NO3 = 3,
|
||||
DJI_MOUNT_POSITION_EXTENSION_PORT = 4,
|
||||
DJI_MOUNT_POSITION_EXTENSION_LITE_PORT = 5,
|
||||
DJI_MOUNT_POSITION_EXTENSION_PORT_V2_NO1 = DJI_MOUNT_POSITION_PAYLOAD_PORT_NO1, /*!< Payload on Port: E1*/
|
||||
DJI_MOUNT_POSITION_EXTENSION_PORT_V2_NO2 = DJI_MOUNT_POSITION_PAYLOAD_PORT_NO2, /*!< Payload on Port: E2*/
|
||||
DJI_MOUNT_POSITION_EXTENSION_PORT_V2_NO3 = DJI_MOUNT_POSITION_PAYLOAD_PORT_NO3, /*!< Payload on Port: E3*/
|
||||
DJI_MOUNT_POSITION_EXTENSION_PORT_V2_NO4 = 4, /*!< Payload on Port: E4*/
|
||||
DJI_MOUNT_POSITION_EXTENSION_PORT_V2_NO5 = 5, /*!< Payload on Port: usb hub port1*/
|
||||
DJI_MOUNT_POSITION_EXTENSION_PORT_V2_NO6 = 6, /*!< Payload on Port: usb hub port2*/
|
||||
DJI_MOUNT_POSITION_EXTENSION_PORT_V2_NO7 = 7, /*!< Payload on Port: usb hub port3*/
|
||||
DJI_MOUNT_POSITION_EXTENSION_PORT,
|
||||
DJI_MOUNT_POSITION_EXTENSION_PORT_V2_NO8 = 8, /*!< Payload on Port: usb hub port4*/
|
||||
DJI_MOUNT_POSITION_EXTENSION_LITE_PORT,
|
||||
} E_DjiMountPosition;
|
||||
|
||||
typedef enum {
|
||||
@ -97,6 +114,9 @@ typedef enum {
|
||||
DJI_AIRCRAFT_SERIES_M350 = 5,
|
||||
DJI_AIRCRAFT_SERIES_M3D = 6,
|
||||
DJI_AIRCRAFT_SERIES_FC30 = 7,
|
||||
DJI_AIRCRAFT_SERIES_M4 = 8,
|
||||
DJI_AIRCRAFT_SERIES_M4D = 9,
|
||||
DJI_AIRCRAFT_SERIES_M400 = 10,
|
||||
} E_DjiAircraftSeries;
|
||||
|
||||
typedef enum {
|
||||
@ -110,9 +130,15 @@ typedef enum {
|
||||
DJI_AIRCRAFT_TYPE_M3E = 77, /*!< Aircraft type is Mavic 3E. */
|
||||
DJI_AIRCRAFT_TYPE_FC30 = 78, /* !<Aircraft type is FlyCart 30> */
|
||||
DJI_AIRCRAFT_TYPE_M3T = 79, /*!< Aircraft type is Mavic 3T. */
|
||||
DJI_AIRCRAFT_TYPE_M3TA = 80, /*!< Aircraft type is Mavic 3TA. */
|
||||
DJI_AIRCRAFT_TYPE_M350_RTK = 89, /*!< Aircraft type is Matrice 350 RTK. */
|
||||
DJI_AIRCRAFT_TYPE_M3D = 91, /*!< Aircraft type is Matrice 3D. */
|
||||
DJI_AIRCRAFT_TYPE_M3TD = 93, /*!< Aircraft type is Matrice 3TD. */
|
||||
DJI_AIRCRAFT_TYPE_M4T = 99, /*!< Aircraft type is Matrice 4T. */
|
||||
DJI_AIRCRAFT_TYPE_M4E = 990, /*!< Aircraft type is Matrice 4E. */
|
||||
DJI_AIRCRAFT_TYPE_M4TD = 100, /*!< Aircraft type is Matrice 4TD. */
|
||||
DJI_AIRCRAFT_TYPE_M4D = 1000, /*!< Aircraft type is Matrice 4D. */
|
||||
DJI_AIRCRAFT_TYPE_M400 = 103, /*!< Aircraft type is Matrice 400. */
|
||||
} E_DjiAircraftType;
|
||||
|
||||
/**
|
||||
@ -130,14 +156,20 @@ typedef enum {
|
||||
DJI_CAMERA_TYPE_P1 = 50, /*!< Camera type is P1. */
|
||||
DJI_CAMERA_TYPE_L1, /*!< Camera type is L1. */
|
||||
DJI_CAMERA_TYPE_L2 = 84, /*!< Camera type is L2. */
|
||||
DJI_CAMERA_TYPE_L3 = 117, /*!< Camera type is L3. */
|
||||
DJI_CAMERA_TYPE_M30 = 52, /*!< Camera type is M30. */
|
||||
DJI_CAMERA_TYPE_M30T = 53, /*!< Camera type is M30T. */
|
||||
DJI_CAMERA_TYPE_M3E = 66, /*!< Camera type is M3E. */
|
||||
DJI_CAMERA_TYPE_M3T = 67, /*!< Camera type is M3T. */
|
||||
DJI_CAMERA_TYPE_M3TA = 68, /*!< Camera type is M3T. */
|
||||
DJI_CAMERA_TYPE_M3D = 80, /*!< Camera type is Matrice 3D. */
|
||||
DJI_CAMERA_TYPE_M3TD = 81, /*!< Camera type is Matrice 3TD. */
|
||||
DJI_CAMERA_TYPE_H30 = 82, /*!< Camera type is H30. */
|
||||
DJI_CAMERA_TYPE_H30T = 83, /*!< Camera type is H30T. */
|
||||
DJI_CAMERA_TYPE_M4T = 89, /*!< Camera type is M4T. */
|
||||
DJI_CAMERA_TYPE_M4E = 891, /*!< Camera type is M4E. */
|
||||
DJI_CAMERA_TYPE_M4TD = 90, /*!< Camera type is M4TD. */
|
||||
DJI_CAMERA_TYPE_M4D = 91, /*!< Camera type is M4D. */
|
||||
} E_DjiCameraType;
|
||||
|
||||
/**
|
||||
@ -248,7 +280,9 @@ typedef enum {
|
||||
DJI_SDK_ADAPTER_TYPE_UNKNOWN = 0, /*!< SDK adapter type is unknown. */
|
||||
DJI_SDK_ADAPTER_TYPE_SKYPORT_V2 = 1, /*!< SDK adapter type is Skyport V2. */
|
||||
DJI_SDK_ADAPTER_TYPE_XPORT = 2, /*!< SDK adapter type is X-Port. */
|
||||
DJI_SDK_ADAPTER_TYPE_NONE = 3, /*!< No external adapter is connected. */
|
||||
DJI_SDK_ADAPTER_TYPE_NONE = 3, /*!< don't have any adapter outside */
|
||||
DJI_SDK_ADAPTER_TYPE_SKYPORT_V3 = 4, /*!< SDK adapter type is Skyport V3 */
|
||||
DJI_SDK_ADAPTER_TYPE_EPORT_V2_RIBBON_CABLE = 5, /*!< SDK adapter type is Eport V2 ribbon cable */
|
||||
} E_DjiSdkAdapterType;
|
||||
|
||||
typedef enum {
|
||||
@ -256,7 +290,15 @@ typedef enum {
|
||||
DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO1,
|
||||
DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO2,
|
||||
DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO3,
|
||||
DJI_CHANNEL_ADDRESS_EXTENSION_PORT_V2_NO1 = DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO1,
|
||||
DJI_CHANNEL_ADDRESS_EXTENSION_PORT_V2_NO2 = DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO2,
|
||||
DJI_CHANNEL_ADDRESS_EXTENSION_PORT_V2_NO3 = DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO3,
|
||||
DJI_CHANNEL_ADDRESS_EXTENSION_PORT_V2_NO4,
|
||||
DJI_CHANNEL_ADDRESS_EXTENSION_PORT_V2_NO5,
|
||||
DJI_CHANNEL_ADDRESS_EXTENSION_PORT_V2_NO6,
|
||||
DJI_CHANNEL_ADDRESS_EXTENSION_PORT_V2_NO7,
|
||||
DJI_CHANNEL_ADDRESS_EXTENSION_PORT,
|
||||
DJI_CHANNEL_ADDRESS_EXTENSION_PORT_V2_NO8 = DJI_CHANNEL_ADDRESS_EXTENSION_PORT,
|
||||
DJI_CHANNEL_ADDRESS_MASTER_RC_APP,
|
||||
DJI_CHANNEL_ADDRESS_SLAVE_RC_APP,
|
||||
DJI_CHANNEL_ADDRESS_CLOUD_API,
|
||||
@ -278,6 +320,7 @@ typedef struct {
|
||||
uint8_t captureCount; /*!< Specifies the total capture count of interval settings.
|
||||
* 0: reserved, 1-254: specific number, 255: continuous capture until stopped. */
|
||||
uint16_t timeIntervalSeconds; /*!< Specifies the interval time between two captures, unit: s*/
|
||||
uint16_t timeIntervalMilliseconds; /*!< Specifies the interval time between two captures, unit: ms*/
|
||||
} T_DjiCameraPhotoTimeIntervalSettings;
|
||||
|
||||
/**
|
||||
|
||||
@ -33,11 +33,11 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define DJI_VERSION_MAJOR 3 /*!< DJI SDK major version num, when have incompatible API changes. Range from 0 to 99. */
|
||||
#define DJI_VERSION_MINOR 9 /*!< DJI SDK minor version num, when add functionality in a backwards compatible manner changes. Range from 0 to 99. */
|
||||
#define DJI_VERSION_MODIFY 1 /*!< DJI SDK modify version num, when have backwards compatible bug fixes changes. Range from 0 to 99. */
|
||||
#define DJI_VERSION_BETA 0 /*!< DJI SDK version beta info, release version will be 0, when beta version release changes. Range from 0 to 255. */
|
||||
#define DJI_VERSION_BUILD 2090 /*!< DJI SDK version build info, when jenkins trigger build changes. Range from 0 to 65535. */
|
||||
#define DJI_VERSION_MAJOR 3 /*!< DJI SDK major version num, when have incompatible API changes. Range from 0 to 99. */
|
||||
#define DJI_VERSION_MINOR 15 /*!< DJI SDK minor version num, when add functionality in a backwards compatible manner changes. Range from 0 to 99. */
|
||||
#define DJI_VERSION_MODIFY 0 /*!< DJI SDK modify version num, when have backwards compatible bug fixes changes. Range from 0 to 99. */
|
||||
#define DJI_VERSION_BETA 0 /*!< DJI SDK version beta info, release version will be 0, when beta version release changes. Range from 0 to 255. */
|
||||
#define DJI_VERSION_BUILD 2318 /*!< DJI SDK version build info, when jenkins trigger build changes. Range from 0 to 65535. */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
|
||||
308
Source/M300/PSDK_Qt/psdk_lib/include/dji_widget_manager.h
Normal file
308
Source/M300/PSDK_Qt/psdk_lib/include/dji_widget_manager.h
Normal file
@ -0,0 +1,308 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file dji_widget_states_manager.h
|
||||
* @version V1.0.0
|
||||
* @date 2020/11/26
|
||||
* @brief This is the header file for "dji_widget_manager.h", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2021 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef DJI_WIDGET_STATES_MANNAGER_H
|
||||
#define DJI_WIDGET_STATES_MANNAGER_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_typedef.h"
|
||||
#include "dji_widget.h"
|
||||
#include "dji_camera_manager.h"
|
||||
// #include "downloader/dji_download_file.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define WIDGET_MANAGER_MAX_FILE_NAME_LEN 32
|
||||
#define WIDGET_MANAGER_MAX_FILE_PATH_LEN 128
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Speaker system states.
|
||||
*/
|
||||
typedef enum {
|
||||
DJI_WIDGET_MGR_SPEAKER_SYSTEM_STATE_IDEL = 0,
|
||||
DJI_WIDGET_MGR_SPEAKER_SYSTEM_STATE_IN_TRANSMISSION = 1,
|
||||
DJI_WIDGET_MGR_SPEAKER_SYSTEM_STATE_PLAYING = 2,
|
||||
DJI_WIDGET_MGR_SPEAKER_SYSTEM_STATE_EXCEPTION = 3,
|
||||
DJI_WIDGET_MGR_SPEAKER_SYSTEM_STATE_IN_TTS_CONVERSION = 4,
|
||||
} E_DjiWidgetManagerSpeakerStates;
|
||||
|
||||
/**
|
||||
* @brief Speaker parameters.
|
||||
*/
|
||||
typedef enum {
|
||||
DJI_WIDGET_MGR_SPEAKER_PARAM_WORK_MODE = 0, /*!< The working mode fo the speaker */
|
||||
DJI_WIDGET_MGR_SPEAKER_PARAM_PALY_ACTION = 1, /*!< The playing action of the speaker */
|
||||
DJI_WIDGET_MGR_SPEAKER_PARAM_VOLUME = 2, /*!< The volume action of the speaker */
|
||||
DJI_WIDGET_MGR_SPEAKER_PARAM_PLAY_MODE = 3, /*!< The playing mode of the speaker */
|
||||
DJI_WIDGET_MGR_SPEAKER_PARAM_PLAY_FILE_NAME = 4, /*!<The name of the file to be played */
|
||||
} E_DjiWidgetManagerSpeakerPram;
|
||||
|
||||
/**
|
||||
* @brief Speaker audio bitrate
|
||||
*/
|
||||
typedef enum {
|
||||
DJI_SPEAKER_WIDGET_AUDIO_DECODE_BITRATE_8000 = 1,
|
||||
DJI_SPEAKER_WIDGET_AUDIO_DECODE_BITRATE_16000 = 2,
|
||||
DJI_SPEAKER_WIDGET_AUDIO_DECODE_BITRATE_24000 = 3,
|
||||
DJI_SPEAKER_WIDGET_AUDIO_DECODE_BITRATE_32000 = 4,
|
||||
DJI_SPEAKER_WIDGET_AUDIO_DECODE_BITRATE_48000 = 5,
|
||||
DJI_SPEAKER_WIDGET_AUDIO_DECODE_BITRATE_64000 = 6,
|
||||
} E_DjiWidgetManagerSpeakerAudoBitrate;
|
||||
|
||||
/**
|
||||
* @brief The type of audio file
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DJI_SPEAKER_WIDGET_FILE_TYPE_TTS_TXT = 0,
|
||||
DJI_SPEAKER_WIDGET_FILE_TYPE_OPUS = 1,
|
||||
DJI_SPEAKER_WIDGET_FILE_TYPE_WAV = 2,
|
||||
} E_DjiWidgetManagerSpeakerFileType;
|
||||
|
||||
/**
|
||||
* @brief The states of widget.
|
||||
*/
|
||||
typedef struct{
|
||||
E_DjiWidgetType widgetType; /*!< The type fo the widget */
|
||||
uint8_t widgetIndex; /*!< The index fo the widget */
|
||||
int32_t widgetValue; /*!< The value fo the widget */
|
||||
} T_DjiWidgetStates;
|
||||
|
||||
/**
|
||||
* @brief The information of audio file.
|
||||
*/
|
||||
typedef struct{
|
||||
E_DjiWidgetManagerSpeakerFileType fileType; /*!< The type fo the audio file */
|
||||
E_DjiWidgetManagerSpeakerAudoBitrate fileBitrate; /*!< The bitrate fo the audio file */
|
||||
uint8_t uuid[WIDGET_MANAGER_MAX_FILE_NAME_LEN]; /*!< The uuid fo the audio file */
|
||||
uint8_t fileName[WIDGET_MANAGER_MAX_FILE_NAME_LEN]; /*!< The fileName fo the audio file */
|
||||
uint8_t filePath[WIDGET_MANAGER_MAX_FILE_PATH_LEN]; /*!< The absolute path to the audio file */
|
||||
} T_DjiSpeakerAudioFileInfo;
|
||||
|
||||
/**
|
||||
* @brief The states of the speaker's widget
|
||||
*/
|
||||
typedef struct {
|
||||
E_DjiWidgetSpeakerWorkMode workMode; /*!< The working mode of the speaker */
|
||||
E_DjiWidgetSpeakerPlayMode playMode; /*!< The playing mode of the speaker */
|
||||
uint8_t playVloume; /*!< The vloume of the speaker */
|
||||
E_DjiWidgetManagerSpeakerStates systemStates; /*!< The system states of the speaker */
|
||||
uint8_t playFileUuid[WIDGET_MANAGER_MAX_FILE_NAME_LEN]; /*!< The uuid of the playing file */
|
||||
uint8_t playFileName[WIDGET_MANAGER_MAX_FILE_NAME_LEN]; /*!< The name of the playing file */
|
||||
uint8_t playQuality; /*!< packet loss per second [0-255] mapped to 0%-100% */
|
||||
uint8_t actualVolume; /*!< The actual volume of the speaker */
|
||||
uint8_t limitVolumeOnTheGround; /*!< The limit volume when aircraft is on the ground */
|
||||
} T_DjiSpeakerWidgetStates;
|
||||
|
||||
/**
|
||||
* @brief Speaker parameters to be set
|
||||
*/
|
||||
typedef struct {
|
||||
E_DjiWidgetManagerSpeakerPram paramType; /*!< Type of speaker parameter to set */
|
||||
union {
|
||||
uint8_t value;
|
||||
uint8_t fileName[32];
|
||||
}data;
|
||||
} T_DjiSpeakerWidgetStatesParam;
|
||||
|
||||
/**
|
||||
* @brief Widget file information
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t fileSize;
|
||||
uint32_t fileIndex;
|
||||
char fileName[DJI_FILE_NAME_SIZE_MAX];
|
||||
} T_DjiWidgetManagerFileInfo;
|
||||
|
||||
/**
|
||||
* @brief The list of widget file information
|
||||
*/
|
||||
typedef struct{
|
||||
uint8_t totalCount;
|
||||
T_DjiWidgetManagerFileInfo *fileListInfo;
|
||||
} T_DjiWidgetManagerFileList;
|
||||
|
||||
/**
|
||||
* @brief Widget file download process information
|
||||
*/
|
||||
typedef struct {
|
||||
E_DjiDownloadFileEvent downloadFileEvent; /*!< Download Event Type */
|
||||
E_DjiMountPosition position; /*!< The position of the payload of the downloaded file */
|
||||
uint32_t fileIndex;
|
||||
uint32_t fileSize;
|
||||
dji_f32_t progressInPercent;
|
||||
} T_DjiDownloadWidgetFileInfo;
|
||||
|
||||
/**
|
||||
* @brief Type of callback function to receive widget states.
|
||||
* @param position: The position of the payload from which the widget states comes.
|
||||
* @param statesData: widgets states of widgets.
|
||||
* @param widgetNum: Number of widgets.
|
||||
* @note It is not recommended to perform blocking operations in the callback, as it may lead to data loss.
|
||||
* @return Execution result.
|
||||
*/
|
||||
typedef void (*RecvWidgetStatesCallback)(E_DjiMountPosition position, T_DjiWidgetStates *statesData, uint8_t widgetNum);
|
||||
|
||||
/**
|
||||
* @brief Type of callback function to receive speaker widget states.
|
||||
* @param position: The position of the speaker from which the widget states comes.
|
||||
* @param statesData: widgets states of speaker.
|
||||
* @note It is not recommended to perform blocking operations in the callback, as it may lead to data loss.
|
||||
* @return Execution result.
|
||||
*/
|
||||
typedef void (*RecvSpeakerStatesCallback)(E_DjiMountPosition position, T_DjiSpeakerWidgetStates *speakerStates);
|
||||
|
||||
/**
|
||||
* @brief Types of callback functions that handle downloading widget file data.
|
||||
* @param packetInfo: Widget file download process information.
|
||||
* @param data: Download raw data.
|
||||
* @param len: length of data.
|
||||
* @note It is not recommended to perform blocking operations in the callback, as it may lead to data loss.
|
||||
* @return Execution result.
|
||||
*/
|
||||
typedef T_DjiReturnCode (*DjiWidgetDownloadFileDataCallback)(T_DjiDownloadWidgetFileInfo packetInfo,
|
||||
const uint8_t *data,
|
||||
uint16_t dataLen);
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Initialize the widget manager module.
|
||||
* @note The interface initialization needs to be after DjiCore_Init.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWidgetManager_Init();
|
||||
|
||||
/**
|
||||
* @brief Denitialize the widget manager module.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWidgetManager_DeInit();
|
||||
|
||||
/**
|
||||
* @brief Subscribe to the widget states of a Payload.
|
||||
* @param position: the position of the target payload.
|
||||
* @param recvStatesCallback: the callback function to recv the widget states.
|
||||
* @note Use this interface to be notified when the states of the target payload's widget changes.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWidgetManager_SubscribePayloadWidgetStates(E_DjiMountPosition position,
|
||||
RecvWidgetStatesCallback recvStatesCallback);
|
||||
|
||||
/**
|
||||
* @brief Unsubscribe to the widget states of a Payload.
|
||||
* @param position: the position of the target payload.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWidgetManager_UnsubscribePayloadWidgetStates(E_DjiMountPosition position);
|
||||
|
||||
/**
|
||||
* @brief Set the widge state of the target payload.
|
||||
* @param position: the position of the target payload.
|
||||
* @param states: Widget parameters to be set.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWidgetManager_SetWidgetState(E_DjiMountPosition position, T_DjiWidgetStates states);
|
||||
|
||||
/**
|
||||
* @brief Subscribe to the widget states of a speaker.
|
||||
* @param position: the position of the target speaker.
|
||||
* @param recvStatesCallback: the callback function to recv the widget states.
|
||||
* @note Use this interface to be notified when the states of the target speaker's widget changes.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWidgetManager_SubscribeSpeakerStates(E_DjiMountPosition position,
|
||||
RecvSpeakerStatesCallback recvStatesCallback);
|
||||
|
||||
/**
|
||||
* @brief Unsubscribe to the widget states of a speaker.
|
||||
* @param position: the position of the target speaker.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWidgetManager_UnsubscribeSpeakerStates(E_DjiMountPosition position);
|
||||
|
||||
/**
|
||||
* @brief Set the widge state of the target speaker.
|
||||
* @param position: the position of the target payload.
|
||||
* @param states: Widget parameters to be set.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWidgetManager_SetSpeakertState(E_DjiMountPosition position,
|
||||
T_DjiSpeakerWidgetStatesParam *states);
|
||||
|
||||
/**
|
||||
* @brief Transferring audio files to speaker.
|
||||
* @param position: the position of the target speaker.
|
||||
* @param audioFileInfo: Audio file description information.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWidgetManager_SendSpeakerAudioData(E_DjiMountPosition position,
|
||||
T_DjiSpeakerAudioFileInfo *audioFileInfo);
|
||||
|
||||
/**
|
||||
* @brief Download the list of widget files for the target payload
|
||||
* @param position: the position of the target speaker.
|
||||
* @param fileList: Information on the list of files obtained from the download.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWidgetManager_WidgetDownloadFileList(E_DjiMountPosition position,
|
||||
T_DjiWidgetManagerFileList *fileList) ;
|
||||
|
||||
/**
|
||||
* @brief Registering callback functions for downloading widget files
|
||||
* @param position: The position of the target speaker.
|
||||
* @param recvFileCallback: The callback to receive the downloaded widget file.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWidgetManager_RegDownloadFileDataCallback(E_DjiMountPosition position,
|
||||
DjiWidgetDownloadFileDataCallback recvFileCallback);
|
||||
|
||||
/**
|
||||
* @brief Unregistering callback functions for downloading widget files.
|
||||
* @param position: The position of the target speaker.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWidgetManager_UnRegDownloadFileDataCallback(E_DjiMountPosition position);
|
||||
|
||||
/**
|
||||
* @brief Download the corresponding widget file on the target payload according to the file index.
|
||||
* @param position: The position of the target speaker.
|
||||
* @param fileIndex: The index of the file that will be downloaded
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWidgetManager_DownloadFileByIndex(E_DjiMountPosition position, uint32_t fileIndex);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DJI_WIDGET_STATES_MANNAGER_H
|
||||
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -90,6 +90,7 @@ bool DjiUserConfigManager_IsEnable(void)
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
static T_DjiReturnCode DjiUserConfigManager_GetAppInfoInner(const char *path, T_DjiUserInfo *userInfo)
|
||||
{
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
T_DjiReturnCode returnCode;
|
||||
uint32_t fileSize = 0;
|
||||
uint32_t readRealSize = 0;
|
||||
@ -99,7 +100,6 @@ static T_DjiReturnCode DjiUserConfigManager_GetAppInfoInner(const char *path, T_
|
||||
cJSON *jsonItem = NULL;
|
||||
cJSON *jsonValue = NULL;
|
||||
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
returnCode = UtilFile_GetFileSizeByPath(path, &fileSize);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get file size by path failed, stat = 0x%08llX", returnCode);
|
||||
@ -191,6 +191,7 @@ jsonDataFree:
|
||||
|
||||
static T_DjiReturnCode DjiUserConfigManager_GetLinkConfigInner(const char *path, T_DjiUserLinkConfig *linkConfig)
|
||||
{
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
T_DjiReturnCode returnCode;
|
||||
uint32_t fileSize = 0;
|
||||
uint32_t readRealSize = 0;
|
||||
@ -202,8 +203,6 @@ static T_DjiReturnCode DjiUserConfigManager_GetLinkConfigInner(const char *path,
|
||||
cJSON *jsonConfig = NULL;
|
||||
int32_t configValue;
|
||||
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
|
||||
returnCode = UtilFile_GetFileSizeByPath(path, &fileSize);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get file size by path failed, stat = 0x%08llX", returnCode);
|
||||
@ -240,6 +239,10 @@ static T_DjiReturnCode DjiUserConfigManager_GetLinkConfigInner(const char *path,
|
||||
linkConfig->type = DJI_USER_LINK_CONFIG_USE_UART_AND_NETWORK_DEVICE;
|
||||
} else if (strcmp(jsonValue->valuestring, "use_uart_and_usb_bulk_device") == 0) {
|
||||
linkConfig->type = DJI_USER_LINK_CONFIG_USE_UART_AND_USB_BULK_DEVICE;
|
||||
} else if (strcmp(jsonValue->valuestring, "use_only_usb_bulk_device") == 0) {
|
||||
linkConfig->type = DJI_USER_LINK_CONFIG_USE_ONLY_USB_BULK_DEVICE;
|
||||
} else if (strcmp(jsonValue->valuestring, "use_only_network_device") == 0) {
|
||||
linkConfig->type = DJI_USER_LINK_CONFIG_USE_ONLY_NETWORK_DEVICE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -326,6 +329,23 @@ static T_DjiReturnCode DjiUserConfigManager_GetLinkConfigInner(const char *path,
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk2_endpoint_out");
|
||||
printf("Config usb bulk2 endpoint out: %s\r\n", jsonConfig->valuestring);
|
||||
linkConfig->usbBulkConfig.usbBulk2EndpointOut = configValue;
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk3_device_name");
|
||||
printf("Config usb bulk2 device name: %s\r\n", jsonConfig->valuestring);
|
||||
strcpy(linkConfig->usbBulkConfig.usbBulk3DeviceName, jsonConfig->valuestring);
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk3_interface_num");
|
||||
printf("Config usb bulk2 interface num: %s\r\n", jsonConfig->valuestring);
|
||||
sscanf(jsonConfig->valuestring, "%X", &configValue);
|
||||
linkConfig->usbBulkConfig.usbBulk3InterfaceNum = configValue;
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk3_endpoint_in");
|
||||
printf("Config usb bulk2 endpoint in: %s\r\n", jsonConfig->valuestring);
|
||||
linkConfig->usbBulkConfig.usbBulk3EndpointIn = configValue;
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk3_endpoint_out");
|
||||
printf("Config usb bulk2 endpoint out: %s\r\n", jsonConfig->valuestring);
|
||||
linkConfig->usbBulkConfig.usbBulk3EndpointOut = configValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -43,8 +43,10 @@ typedef enum {
|
||||
DJI_USER_LINK_CONFIG_USE_ONLY_UART,
|
||||
DJI_USER_LINK_CONFIG_USE_UART_AND_NETWORK_DEVICE,
|
||||
DJI_USER_LINK_CONFIG_USE_UART_AND_USB_BULK_DEVICE,
|
||||
DJI_USER_LINK_CONFIG_USE_ONLY_USB_BULK_DEVICE,
|
||||
DJI_USER_LINK_CONFIG_USE_ONLY_NETWORK_DEVICE,
|
||||
} E_DjiUserLinkConfigType;
|
||||
|
||||
#define CONFIG_HARDWARE_CONNECTION DJI_USER_LINK_CONFIG_USE_ONLY_NETWORK_DEVICE
|
||||
typedef struct {
|
||||
E_DjiUserLinkConfigType type;
|
||||
struct {
|
||||
@ -71,6 +73,11 @@ typedef struct {
|
||||
uint8_t usbBulk2InterfaceNum;
|
||||
uint8_t usbBulk2EndpointIn;
|
||||
uint8_t usbBulk2EndpointOut;
|
||||
|
||||
char usbBulk3DeviceName[USER_DEVICE_NAME_STR_MAX_SIZE];
|
||||
uint8_t usbBulk3InterfaceNum;
|
||||
uint8_t usbBulk3EndpointIn;
|
||||
uint8_t usbBulk3EndpointOut;
|
||||
} usbBulkConfig;
|
||||
} T_DjiUserLinkConfig;
|
||||
|
||||
|
||||
@ -27,8 +27,9 @@ 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();
|
||||
m_ctrlVehicle.SetupEnvironment_M300RTK();
|
||||
#ifdef ZZ_FLAG_TEST
|
||||
qDebug() << m_struSensorPort.qstrGasSensorPort;
|
||||
qDebug() << m_struSensorPort.qstrWindSensorPort;
|
||||
@ -37,7 +38,7 @@ int CMainAcqThread::SetupContext()
|
||||
qDebug() << m_struM300RTKSs.qstrM300RTKWidgetFilePath;
|
||||
#endif
|
||||
// m_ctrlVehicle.SetupEnvironment_M300RTK();
|
||||
m_ctrlVehicle.SetupEnvironment();
|
||||
//m_ctrlVehicle.SetupEnvironment();
|
||||
SetupMessagePipe();
|
||||
return 0;
|
||||
}
|
||||
@ -49,7 +50,7 @@ int CMainAcqThread::StartUp()
|
||||
system("sudo gpio write 7 0");
|
||||
// m_ctrlVehicle.StartupPSDK_M300RTK();
|
||||
|
||||
m_ctrlVehicle.StartupPSDK_M350RTK();
|
||||
m_ctrlVehicle.StartupPSDK_M300RTK();
|
||||
QString qstrMessage = "Initializing sensors,Please wait...";
|
||||
emit Signal_UpdateVehicleMessage(qstrMessage);
|
||||
|
||||
@ -83,6 +84,8 @@ int CMainAcqThread::StartUp()
|
||||
int CMainAcqThread::SetupMessagePipe()
|
||||
{
|
||||
connect(&m_ctrlVehicle, &VehicleController::Signal_StartCapture, this, &CMainAcqThread::Slot_StartCapture);
|
||||
connect(&m_ctrlVehicle.m_clsWidget,&ZZ_Widget_M300RTK::SendCommand,this,&CMainAcqThread::GetCommand);
|
||||
connect(this, &CMainAcqThread::SendCommand, &m_ctrlVehicle.m_clsWidget, &ZZ_Widget_M300RTK::BackCommand);
|
||||
connect(&m_ctrlVehicle, &VehicleController::Signal_StopCapture, this, &CMainAcqThread::Slot_StopCapture);
|
||||
|
||||
connect(this, &CMainAcqThread::Signal_UpdateVehicleMessage, &m_ctrlVehicle, &VehicleController::Signal_UpdateVehicleMessage);
|
||||
@ -196,6 +199,7 @@ int CMainAcqThread::GetData()
|
||||
|
||||
float fSpeed=-1, fAngle=-1,fWindTemp=-1;
|
||||
m_ctrlWindSensor.GetSA_NChk(fSpeed,fAngle, fWindTemp);
|
||||
|
||||
m_struUASDataFrame.fWindDirection = fAngle;
|
||||
m_struUASDataFrame.fWindSpeed = fSpeed;
|
||||
m_struUASDataFrame.fWindTemperature = fWindTemp;
|
||||
@ -203,6 +207,8 @@ int CMainAcqThread::GetData()
|
||||
m_ctrlVehicle.GetOneDataFrame(m_struM300RTKDataFrame);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
|
||||
|
||||
int CMainAcqThread::OnTimerCapture()
|
||||
{
|
||||
#ifdef ZZ_FLAG_TEST
|
||||
@ -281,3 +287,94 @@ int CMainAcqThread::Slot_StopCapture()
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CMainAcqThread::GetCommand(QString Worker, QString Command) {
|
||||
// 用qDebug打印接收到的命令
|
||||
qDebug()<<"Received Command - Worker:" << Worker << ", Command:" << Command;
|
||||
|
||||
int waitetime=10;
|
||||
qDebug()<<"GetCommand Worker:"<<Worker<<" Command:"<<Command;
|
||||
if (Worker=="WDA") {
|
||||
//#分割字符comman
|
||||
QStringList arc=Command.split("#");
|
||||
if (arc[0]=="StartCalibrate") {
|
||||
if (arc.length()<2) {
|
||||
emit SendCommand("WDA","Finish");
|
||||
return;
|
||||
}
|
||||
m_ctrlWindSensor.CalibrateWDA(arc[1].toDouble());
|
||||
emit SendCommand("WDA","Finish");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (Worker == "GAS") {
|
||||
QStringList arc = Command.split("#");
|
||||
qDebug()<<"arc is"<<arc;
|
||||
if (arc[0] == "ZeroCalibrate") {
|
||||
|
||||
if (arc.length() < 2) {
|
||||
emit SendCommand("GAS", "Finish");
|
||||
// system("sudo gpio write 7 0");
|
||||
return;
|
||||
}
|
||||
if (arc[1]=="Air") {
|
||||
// system("sudo gpio write 7 1");
|
||||
qDebug()<<"Start Gas Motor now";
|
||||
QThread::sleep(waitetime);
|
||||
m_ctrlGasSensor.ZeroCalibration_Air();
|
||||
QThread::sleep(waitetime);
|
||||
emit SendCommand("GAS", "Finish");
|
||||
// system("sudo gpio write 7 0");
|
||||
qDebug()<<"Stop Gas Motor now";
|
||||
}
|
||||
else if (arc[1] == "N2") {
|
||||
// system("sudo gpio write 7 1");
|
||||
qDebug()<<"Start Gas Motor now";
|
||||
QThread::sleep(waitetime);
|
||||
m_ctrlGasSensor.ZeroCalibration_N2();
|
||||
QThread::sleep(waitetime);
|
||||
emit SendCommand("GAS", "Finish");
|
||||
// system("sudo gpio write 7 0");
|
||||
qDebug()<<"Stop Gas Motor now";
|
||||
}
|
||||
else {
|
||||
emit SendCommand("GAS", "Finish");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (arc[0] == "SpanCalibrate") {
|
||||
|
||||
if (arc.size()<3) {
|
||||
emit SendCommand("GAS", "Finish");
|
||||
|
||||
return;
|
||||
}
|
||||
char cChannel=0;
|
||||
if (arc[1]=="CO2") {
|
||||
cChannel=0x03;
|
||||
} else if(arc[1]=="H2O") {
|
||||
cChannel=0x02;
|
||||
}
|
||||
else {
|
||||
emit SendCommand("GAS", "Finish");
|
||||
|
||||
return;
|
||||
}
|
||||
unsigned int uiPPM=arc[2].toUInt();
|
||||
// system("sudo gpio write 7 1");
|
||||
qDebug()<<"Start Gas Motor now";
|
||||
QThread::sleep(waitetime);
|
||||
m_ctrlGasSensor.SpanCalibration(cChannel,uiPPM);
|
||||
QThread::sleep(waitetime);
|
||||
emit SendCommand("GAS", "Finish");
|
||||
// system("sudo gpio write 7 0");
|
||||
qDebug()<<"Stop Gas Motor now";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ private:
|
||||
M300RTKSettings m_struM300RTKSs;
|
||||
SensorPort m_struSensorPort;
|
||||
|
||||
M350RTKDataFrame m_struM300RTKDataFrame;
|
||||
M300RTKDataFrame m_struM300RTKDataFrame;
|
||||
GSDataFrame m_struGSDataFrame;
|
||||
UASDataFrame m_struUASDataFrame;
|
||||
|
||||
@ -66,9 +66,11 @@ private:
|
||||
int FormFixedWindData();
|
||||
signals:
|
||||
void Signal_UpdateVehicleMessage(QString qstrMessage);
|
||||
void SendCommand(QString Worker, QString Command);
|
||||
public slots:
|
||||
void OnTestTimer();
|
||||
int OnTimerCapture();
|
||||
int Slot_StartCapture();
|
||||
int Slot_StopCapture();
|
||||
void GetCommand(QString Worker, QString Command);
|
||||
};
|
||||
@ -81,7 +81,7 @@ int MainConfigParser::Initialize(QString qstrPath)
|
||||
return 5;
|
||||
}
|
||||
m_struM300RTKSs.qstrM300RTKUDEV1= qstrUART1;
|
||||
strcpy(gvpcM300RTK_UART1, qstrUART1.toLatin1().data());
|
||||
// strcpy(gvpcM300RTK_UART1, qstrUART1.toLatin1().data());
|
||||
|
||||
QString qstrUART2 = qsMainSettings.value(QString("M300RTK/UART2"), "Error").toString();
|
||||
if (qstrUART2 == "Error")
|
||||
@ -90,7 +90,7 @@ int MainConfigParser::Initialize(QString qstrPath)
|
||||
return 6;
|
||||
}
|
||||
m_struM300RTKSs.qstrM300RTKUDEV2 = qstrUART2;
|
||||
strcpy(gvpcM300RTK_UART2, qstrUART2.toLatin1().data());
|
||||
// strcpy(gvpcM300RTK_UART2, qstrUART2.toLatin1().data());
|
||||
|
||||
QString qstrSettingsFilePath = qsMainSettings.value(QString("M300RTK/SettingsFilePath"), "Error").toString();
|
||||
if (qstrSettingsFilePath == "Error")
|
||||
|
||||
434
Source/WDA/WDACalibration.cpp
Normal file
434
Source/WDA/WDACalibration.cpp
Normal file
@ -0,0 +1,434 @@
|
||||
#include "pch.h"
|
||||
#include "WDACalibration.h"
|
||||
#include <QRegularExpression>
|
||||
#include <QThread>
|
||||
|
||||
WDACalibration::WDACalibration()
|
||||
{
|
||||
}
|
||||
|
||||
WDACalibration::~WDACalibration()
|
||||
{
|
||||
}
|
||||
|
||||
int WDACalibration::ExecuteCalibration(QSerialPort* pSerialPort, double dTemperature)
|
||||
{
|
||||
if (!pSerialPort || !pSerialPort->isOpen())
|
||||
{
|
||||
qDebug() << "Err:ExecuteCalibration - Serial port not open.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 将温度转换为5位数字格式,例如24.0 -> 00240
|
||||
int iTempValue = static_cast<int>(dTemperature * 10);
|
||||
char szTemp[16];
|
||||
snprintf(szTemp, sizeof(szTemp), "%05d", iTempValue);
|
||||
std::string sTempValue = szTemp;
|
||||
|
||||
qDebug() << QString("开始WDA校准流程,校准温度: %1℃ (编码: %2)").arg(dTemperature).arg(sTempValue.c_str());
|
||||
|
||||
CalibrationState eState = Calib_Step1_TC0;
|
||||
int iRetryCount = 0;
|
||||
int iTryCount = 0;
|
||||
|
||||
// 执行校准流程
|
||||
while (eState != Calib_Idle)
|
||||
{
|
||||
// 执行当前步骤
|
||||
std::string sResponse;
|
||||
int iResult = ExecuteCalibrationStep(pSerialPort, eState, sTempValue, iRetryCount, iTryCount, sResponse);
|
||||
|
||||
if (iResult != 0)
|
||||
{
|
||||
// 步骤执行失败
|
||||
iRetryCount++;
|
||||
if (iRetryCount > 3)
|
||||
{
|
||||
// 错误码映射:ExecuteCalibrationStep返回1,2,3,4 -> ExecuteCalibration返回2,3,4,5
|
||||
// (因为错误码1是串口未打开,错误码2由IrisSensor_WDA_P0返回表示WDA正在工作)
|
||||
qDebug() << "Err:ExecuteCalibration - Too many retries.Exit Code:" << (iResult + 1);
|
||||
return (iResult + 1);
|
||||
}
|
||||
qDebug() << "Warning:ExecuteCalibration - Step failed, retrying...";
|
||||
continue;
|
||||
}
|
||||
|
||||
// 步骤执行成功,重置重试计数
|
||||
iRetryCount = 0;
|
||||
|
||||
// 特殊处理:步骤5需要检查校准是否完成
|
||||
if (eState == Calib_Step5_AC_Second)
|
||||
{
|
||||
if (CheckCalibrationComplete(sResponse))
|
||||
{
|
||||
qDebug() << "WDA校准完成!所有值均小于10";
|
||||
// 继续到下一步
|
||||
eState = Calib_Step6_Restore_KY18;
|
||||
}
|
||||
else
|
||||
{
|
||||
iTryCount++;
|
||||
if (iTryCount > 1)
|
||||
{
|
||||
qDebug() << "Warning:ExecuteCalibration - Calibration not complete after retries, continuing...";
|
||||
eState = Calib_Step6_Restore_KY18;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "WDA校准未完成,需要重复步骤2-3,等待5秒后重试...";
|
||||
// 等待5秒
|
||||
QThread::msleep(5000);
|
||||
// 重新开始步骤2
|
||||
eState = Calib_Step2_KY18_First;
|
||||
iRetryCount = 0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 更新到下一步状态
|
||||
switch (eState)
|
||||
{
|
||||
case Calib_Step1_TC0:
|
||||
eState = Calib_Step2_KY18_First;
|
||||
break;
|
||||
case Calib_Step2_KY18_First:
|
||||
eState = Calib_Step3_AC_First;
|
||||
break;
|
||||
case Calib_Step3_AC_First:
|
||||
eState = Calib_Step4_KY18_Second;
|
||||
break;
|
||||
case Calib_Step4_KY18_Second:
|
||||
eState = Calib_Step5_AC_Second;
|
||||
break;
|
||||
case Calib_Step5_AC_Second:
|
||||
eState = Calib_Step6_Restore_KY18;
|
||||
break;
|
||||
case Calib_Step6_Restore_KY18:
|
||||
eState = Calib_Step7_Restore_TC;
|
||||
break;
|
||||
case Calib_Step7_Restore_TC:
|
||||
qDebug() << "WDA校准流程全部完成!";
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// 步骤之间等待500ms
|
||||
QThread::msleep(500);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WDACalibration::ExecuteCalibrationStep(QSerialPort* pSerialPort, CalibrationState eStep,
|
||||
const std::string& sTempValue, int& iRetryCount, int& iTryCount,
|
||||
std::string& sResponse)
|
||||
{
|
||||
// 发送当前步骤的命令
|
||||
std::string sCommand;
|
||||
switch (eStep)
|
||||
{
|
||||
case Calib_Step1_TC0:
|
||||
sCommand = "$01,TC0\r\n";
|
||||
break;
|
||||
case Calib_Step2_KY18_First:
|
||||
sCommand = "$01,KY18\r\n";
|
||||
break;
|
||||
case Calib_Step3_AC_First:
|
||||
{
|
||||
char szCmd[64];
|
||||
snprintf(szCmd, sizeof(szCmd), "$01,AC%s^**\r\n", sTempValue.c_str());
|
||||
sCommand = szCmd;
|
||||
}
|
||||
break;
|
||||
case Calib_Step4_KY18_Second:
|
||||
sCommand = "$01,KY18\r\n";
|
||||
break;
|
||||
case Calib_Step5_AC_Second:
|
||||
{
|
||||
char szCmd[64];
|
||||
snprintf(szCmd, sizeof(szCmd), "$01,AC%s^**\r\n", sTempValue.c_str());
|
||||
sCommand = szCmd;
|
||||
}
|
||||
break;
|
||||
case Calib_Step6_Restore_KY18:
|
||||
sCommand = "$01,KY18\r\n";
|
||||
break;
|
||||
case Calib_Step7_Restore_TC:
|
||||
sCommand = "$01,TC00001^**\r\n";
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (SendCalibrationCommand(pSerialPort, sCommand) != 0)
|
||||
{
|
||||
qDebug() << "Err:ExecuteCalibrationStep - SendCalibrationCommand failed.Exit Code:2";
|
||||
return 2;
|
||||
}
|
||||
|
||||
// 接收响应
|
||||
sResponse.clear();
|
||||
if (RecvCalibrationResponse(pSerialPort, sResponse, 5000) != 0)
|
||||
{
|
||||
qDebug() << "Err:ExecuteCalibrationStep - RecvCalibrationResponse timeout.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
|
||||
// 检查响应
|
||||
if (!CheckCalibrationResponse(sResponse, eStep))
|
||||
{
|
||||
qDebug() << "Err:ExecuteCalibrationStep - Invalid response.Exit Code:4";
|
||||
return 4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WDACalibration::SendCalibrationCommand(QSerialPort* pSerialPort, const std::string& sCommand)
|
||||
{
|
||||
if (!pSerialPort || !pSerialPort->isOpen())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
QByteArray qbaSend(sCommand.c_str(), (int)sCommand.length());
|
||||
qint64 qi64Write = pSerialPort->write(qbaSend);
|
||||
pSerialPort->waitForBytesWritten(50);
|
||||
|
||||
if (qi64Write != qbaSend.size())
|
||||
{
|
||||
qDebug() << "Err:SendCalibrationCommand - Write failed";
|
||||
return 1;
|
||||
}
|
||||
|
||||
qDebug() << QString("发送: %1").arg(sCommand.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WDACalibration::RecvCalibrationResponse(QSerialPort* pSerialPort, std::string& sResponse, int iTimeoutMs)
|
||||
{
|
||||
if (!pSerialPort || !pSerialPort->isOpen())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
sResponse.clear();
|
||||
QByteArray qbData;
|
||||
qbData.clear();
|
||||
|
||||
// 清空接收缓冲区
|
||||
pSerialPort->readAll();
|
||||
|
||||
// 等待数据到达
|
||||
int iElapsed = 0;
|
||||
while (iElapsed < iTimeoutMs)
|
||||
{
|
||||
if (pSerialPort->waitForReadyRead(100))
|
||||
{
|
||||
QByteArray qbTemp = pSerialPort->readAll();
|
||||
qbData.append(qbTemp);
|
||||
|
||||
// 检查是否收到完整的行(以\r\n或\n结尾)
|
||||
if (qbData.contains("\r\n") || qbData.contains('\n') || qbData.contains('\r'))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
iElapsed += 100;
|
||||
}
|
||||
|
||||
if (qbData.isEmpty())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 提取一行数据
|
||||
int iLineEnd = -1;
|
||||
int iLineLength = 0;
|
||||
|
||||
if (qbData.contains("\r\n"))
|
||||
{
|
||||
iLineEnd = qbData.indexOf("\r\n");
|
||||
iLineLength = 2;
|
||||
}
|
||||
else if (qbData.contains('\n'))
|
||||
{
|
||||
iLineEnd = qbData.indexOf('\n');
|
||||
iLineLength = 1;
|
||||
}
|
||||
else if (qbData.contains('\r'))
|
||||
{
|
||||
iLineEnd = qbData.indexOf('\r');
|
||||
iLineLength = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 没有换行符,使用全部数据
|
||||
iLineEnd = qbData.size();
|
||||
iLineLength = 0;
|
||||
}
|
||||
|
||||
QByteArray qbLine = qbData.left(iLineEnd);
|
||||
QString qstrResponse = QString::fromUtf8(qbLine).trimmed();
|
||||
sResponse = qstrResponse.toStdString();
|
||||
|
||||
if (!sResponse.empty())
|
||||
{
|
||||
qDebug() << QString("接收: %1").arg(sResponse.c_str());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool WDACalibration::CheckCalibrationResponse(const std::string& sResponse, CalibrationState eStep)
|
||||
{
|
||||
QString qstrResponse = QString::fromStdString(sResponse);
|
||||
|
||||
switch (eStep)
|
||||
{
|
||||
case Calib_Step1_TC0:
|
||||
if (qstrResponse.contains("$WI,TC=0") || qstrResponse.contains("TC=0"))
|
||||
{
|
||||
qDebug() << "步骤1完成: TC0设置成功";
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case Calib_Step2_KY18_First:
|
||||
if (qstrResponse.contains("$WI,KY=18") || qstrResponse.contains("KY=18"))
|
||||
{
|
||||
qDebug() << "步骤2完成: KY18设置成功";
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case Calib_Step3_AC_First:
|
||||
if (qstrResponse.contains("$WI,AC=") || qstrResponse.contains("AC="))
|
||||
{
|
||||
std::string sACValues = ExtractACValues(sResponse);
|
||||
qDebug() << QString("步骤3完成: 第一次AC校准,返回值: %1").arg(sACValues.c_str());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case Calib_Step4_KY18_Second:
|
||||
if (qstrResponse.contains("$WI,KY=18") || qstrResponse.contains("KY=18"))
|
||||
{
|
||||
qDebug() << "步骤4完成: 第二次KY18设置成功";
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case Calib_Step5_AC_Second:
|
||||
if (qstrResponse.contains("$WI,AC=") || qstrResponse.contains("AC="))
|
||||
{
|
||||
std::string sACValues = ExtractACValues(sResponse);
|
||||
qDebug() << QString("步骤5: 第二次AC校准,返回值: %1").arg(sACValues.c_str());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case Calib_Step6_Restore_KY18:
|
||||
if (qstrResponse.contains("$WI,KY=18") || qstrResponse.contains("KY=18"))
|
||||
{
|
||||
qDebug() << "步骤6完成: 恢复模式KY18设置成功";
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case Calib_Step7_Restore_TC:
|
||||
if (qstrResponse.contains("$WI,TC=00001") || qstrResponse.contains("TC=00001"))
|
||||
{
|
||||
qDebug() << "步骤7完成: 恢复模式TC设置成功";
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WDACalibration::CheckCalibrationComplete(const std::string& sResponse)
|
||||
{
|
||||
std::string sACValues = ExtractACValues(sResponse);
|
||||
return AllValuesLessThan10(sACValues);
|
||||
}
|
||||
|
||||
std::string WDACalibration::ExtractACValues(const std::string& sResponse)
|
||||
{
|
||||
QString qstrResponse = QString::fromStdString(sResponse);
|
||||
QRegularExpression re(R"(\$WI,AC=(.+))");
|
||||
QRegularExpressionMatch match = re.match(qstrResponse);
|
||||
|
||||
if (!match.hasMatch())
|
||||
{
|
||||
re.setPattern(R"(AC=(.+))");
|
||||
match = re.match(qstrResponse);
|
||||
}
|
||||
|
||||
if (match.hasMatch())
|
||||
{
|
||||
return match.captured(1).toStdString();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
bool WDACalibration::AllValuesLessThan10(const std::string& sACValues)
|
||||
{
|
||||
if (sACValues.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString qstrACValues = QString::fromStdString(sACValues);
|
||||
QStringList values = qstrACValues.split(',');
|
||||
|
||||
if (values.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查从第5个值(索引4)到最后一个值
|
||||
int iStartIndex = 4;
|
||||
|
||||
if (iStartIndex >= values.size())
|
||||
{
|
||||
qDebug() << QString("值数量不足5个,无法检查");
|
||||
return false;
|
||||
}
|
||||
|
||||
QStringList checkedValues;
|
||||
for (int i = iStartIndex; i < values.size(); i++)
|
||||
{
|
||||
QString valueStr = values[i].trimmed();
|
||||
bool ok;
|
||||
int iValue = valueStr.toInt(&ok);
|
||||
if (!ok)
|
||||
{
|
||||
qDebug() << QString("无法解析值: %1").arg(valueStr);
|
||||
return false;
|
||||
}
|
||||
checkedValues << valueStr;
|
||||
if (iValue >= 10)
|
||||
{
|
||||
qDebug() << QString("检查值: %1 (第%2到最后一个值: %3),值 %4 >= 10,校准未完成")
|
||||
.arg(valueStr)
|
||||
.arg(iStartIndex + 1)
|
||||
.arg(checkedValues.join(","))
|
||||
.arg(iValue);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << QString("第%1到最后一个值均小于10 (值: %2),校准完成")
|
||||
.arg(iStartIndex + 1)
|
||||
.arg(checkedValues.join(","));
|
||||
return true;
|
||||
}
|
||||
|
||||
63
Source/WDA/WDACalibration.h
Normal file
63
Source/WDA/WDACalibration.h
Normal file
@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
|
||||
// WDA校正功能类
|
||||
// 用于执行WDA传感器的自动校准流程
|
||||
class WDACalibration
|
||||
{
|
||||
public:
|
||||
WDACalibration();
|
||||
~WDACalibration();
|
||||
|
||||
// 执行WDA校正流程
|
||||
// 参数:
|
||||
// pSerialPort - 串口指针(必须已打开)
|
||||
// dTemperature - 校准温度(单位:℃)
|
||||
// 返回:
|
||||
// 0 - 成功
|
||||
// 1 - 串口未打开
|
||||
// 2 - 发送命令失败(重试次数过多)
|
||||
// 3 - 接收响应超时(重试次数过多)
|
||||
// 4 - 响应无效(重试次数过多)
|
||||
// 5 - 未知错误
|
||||
// 注意:WDA工作状态检查由调用者(IrisSensor_WDA_P0)负责,错误码2由调用者返回
|
||||
int ExecuteCalibration(QSerialPort* pSerialPort, double dTemperature);
|
||||
|
||||
private:
|
||||
// 校正状态枚举
|
||||
enum CalibrationState {
|
||||
Calib_Idle,
|
||||
Calib_Step1_TC0,
|
||||
Calib_Step2_KY18_First,
|
||||
Calib_Step3_AC_First,
|
||||
Calib_Step4_KY18_Second,
|
||||
Calib_Step5_AC_Second,
|
||||
Calib_Step6_Restore_KY18,
|
||||
Calib_Step7_Restore_TC
|
||||
};
|
||||
|
||||
// 发送校正命令
|
||||
int SendCalibrationCommand(QSerialPort* pSerialPort, const std::string& sCommand);
|
||||
|
||||
// 接收校正响应
|
||||
int RecvCalibrationResponse(QSerialPort* pSerialPort, std::string& sResponse, int iTimeoutMs = 5000);
|
||||
|
||||
// 检查响应是否匹配当前步骤
|
||||
bool CheckCalibrationResponse(const std::string& sResponse, CalibrationState eStep);
|
||||
|
||||
// 检查校正是否完成
|
||||
bool CheckCalibrationComplete(const std::string& sResponse);
|
||||
|
||||
// 从响应中提取AC值
|
||||
std::string ExtractACValues(const std::string& sResponse);
|
||||
|
||||
// 检查所有值是否小于10
|
||||
bool AllValuesLessThan10(const std::string& sACValues);
|
||||
|
||||
// 执行单个校正步骤
|
||||
// 返回:0-成功,非0-失败
|
||||
// sResponse:输出参数,接收到的响应(仅在成功时有效)
|
||||
int ExecuteCalibrationStep(QSerialPort* pSerialPort, CalibrationState eStep, const std::string& sTempValue,
|
||||
int& iRetryCount, int& iTryCount, std::string& sResponse);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user