NEW: release DJI Payload-SDK version 3.1
Signed-off-by: DJI-Martin <DJI-Martin@dji.com>
This commit is contained in:
14
README.md
14
README.md
@ -1,6 +1,6 @@
|
||||
# DJI Payload SDK (PSDK)
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
[](https://gitter.im/dji-sdk/Payload-SDK?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
@ -20,12 +20,12 @@ Documentation regarding the code can be found in the [PSDK API Reference](https:
|
||||
Please visit the [Latest Version Information](https://developer.dji.com/payload-sdk/documentation/appendix/firmware.html) to get the latest version information.
|
||||
|
||||
## Latest Release
|
||||
PSDK 3.0.0 was released on 20 October 2021. This version inherit the PSDK 2.2.1 existing functions (use X-Port or Skyport-V2
|
||||
to develop payload), and add extension port existing functions(based on OSDK 4.1.0) support, add the DJI offline certificate
|
||||
support, add the serial port baud rate adaptive support, add the arrest-flying feature support in flight-controller module,
|
||||
add the custom widget feature support on extend port, add the remote controller custom button mapping function support,
|
||||
add the DJI L1/P1 camera support in camera-manager module. Also enhance the camera media file download speed and fix some
|
||||
bugs on the last version. At the same time, add more api sample support and more toolchain support.
|
||||
|
||||
PSDK 3.1.0 was released on 21 March 2022. This version of Payload SDK mainly add some features support, such as add the
|
||||
Matrice 30/30T support, add the standard speaker widget support on M30/M30T, add the waypoint 3.0 support on M30/30T, add the
|
||||
get camera laser ranging data support on M30/30T, add the power-off notification support on M300 RTK OSDK port, etc. At
|
||||
the same time, we also fixed some bugs on the last version, add more sample support and add ESP32 toolchain support.
|
||||
Please refer to the release notes for detailed changes list.
|
||||
|
||||
## License
|
||||
|
||||
|
BIN
doc/reference_designs/Type-C Schematic Reference.pdf
Normal file
BIN
doc/reference_designs/Type-C Schematic Reference.pdf
Normal file
Binary file not shown.
6681
doc/simple_model/PSDK Mounting Bracket(Payload).stp
Normal file
6681
doc/simple_model/PSDK Mounting Bracket(Payload).stp
Normal file
File diff suppressed because it is too large
Load Diff
@ -509,6 +509,17 @@ typedef struct {
|
||||
uint8_t progressInPercent;
|
||||
} T_DjiDownloadFilePacketInfo;
|
||||
|
||||
typedef struct {
|
||||
dji_f64_t longitude; /*! Range: [-180,180] */
|
||||
dji_f64_t latitude; /*! Range: [-90,90] */
|
||||
int32_t altitude; /*! Unit: 0.1m */
|
||||
int32_t distance; /*! Unit: 0.1m */
|
||||
int16_t screenX; /*! Unit: 0.1% */
|
||||
int16_t screenY; /*! Unit: 0.1% */
|
||||
bool enable_lidar;
|
||||
bool exception;
|
||||
} T_DjiCameraManagerLaserRangingInfo;
|
||||
|
||||
typedef T_DjiReturnCode (*DjiCameraManagerDownloadFileDataCallback)(T_DjiDownloadFilePacketInfo packetInfo,
|
||||
const uint8_t *data,
|
||||
uint16_t dataLen);
|
||||
@ -976,6 +987,14 @@ T_DjiReturnCode DjiCameraManager_DownloadFileByIndex(E_DjiMountPosition position
|
||||
*/
|
||||
T_DjiReturnCode DjiCameraManager_DeleteFileByIndex(E_DjiMountPosition position, uint32_t fileIndex);
|
||||
|
||||
/**
|
||||
* @brief Get the camera laser ranging info of the selected camera mounted position.
|
||||
* @param position: the mount position of the camera
|
||||
* @param laserRangingInfo: the pointer to the camera laser ranging info
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiCameraManager_GetLaserRangingInfo(E_DjiMountPosition position,
|
||||
T_DjiCameraManagerLaserRangingInfo *laserRangingInfo);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -55,7 +55,7 @@ typedef struct {
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Initialize the Onboard SDK core in blocking mode.
|
||||
* @brief Initialize the Payload SDK core in blocking mode.
|
||||
* @note The call location of this interface requires special attention, The call needs to be completed after the
|
||||
* registration of console/OSAL handler functions/HAL handler functions are completed. At the same time, it must be
|
||||
* initialized at the beginning of calling other functional module interfaces. You need to fill in the developer
|
||||
@ -82,7 +82,7 @@ T_DjiReturnCode DjiCore_Init(const T_DjiUserInfo *userInfo);
|
||||
T_DjiReturnCode DjiCore_SetAlias(const char *productAlias);
|
||||
|
||||
/**
|
||||
* @brief Notify that the Onboard SDK core application starts.
|
||||
* @brief Notify that the Payload SDK core application starts.
|
||||
* @note The call location of this interface requires special attention, The call needs to be completed after all the
|
||||
* module initialize and register interfaces.
|
||||
* @return Execution result.
|
||||
|
@ -90,6 +90,7 @@ typedef enum {
|
||||
DJI_AIRCRAFT_SERIES_UNKNOWN = 0,
|
||||
DJI_AIRCRAFT_SERIES_M200_V2 = 1,
|
||||
DJI_AIRCRAFT_SERIES_M300 = 2,
|
||||
DJI_AIRCRAFT_SERIES_M30 = 3,
|
||||
} E_DjiAircraftSeries;
|
||||
|
||||
typedef enum {
|
||||
@ -98,6 +99,8 @@ typedef enum {
|
||||
DJI_AIRCRAFT_TYPE_M210_V2 = 45, /*!< Aircraft type is Matrice 220 V2. */
|
||||
DJI_AIRCRAFT_TYPE_M210RTK_V2 = 46, /*!< Aircraft type is Matrice 210 RTK V2. */
|
||||
DJI_AIRCRAFT_TYPE_M300_RTK = 60, /*!< Aircraft type is Matrice 300 RTK. */
|
||||
DJI_AIRCRAFT_TYPE_M30 = 67, /*!< Aircraft type is Matrice 30. */
|
||||
DJI_AIRCRAFT_TYPE_M30T = 68, /*!< Aircraft type is Matrice 30T. */
|
||||
} E_DjiAircraftType;
|
||||
|
||||
/**
|
||||
@ -113,6 +116,8 @@ typedef enum {
|
||||
DJI_CAMERA_TYPE_H20T = 43, /*!< Camera type is H20T. */
|
||||
DJI_CAMERA_TYPE_P1 = 50, /*!< Camera type is P1. */
|
||||
DJI_CAMERA_TYPE_L1, /*!< Camera type is L1. */
|
||||
DJI_CAMERA_TYPE_M30, /*!< Camera type is M30. */
|
||||
DJI_CAMERA_TYPE_M30T, /*!< Camera type is M30T. */
|
||||
} E_DjiCameraType;
|
||||
|
||||
/**
|
||||
|
@ -28,24 +28,21 @@
|
||||
#define DJI_VERSION_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
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 0 /*!< DJI SDK minor version num, when add functionality in a backwards compatible manner changes. Range from 0 to 99. */
|
||||
#define DJI_VERSION_MINOR 1 /*!< 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 1462 /*!< DJI SDK version build info, when jenkins trigger build changes. Range from 0 to 65535. */
|
||||
#define DJI_VERSION_BUILD 1491 /*!< DJI SDK version build info, when jenkins trigger build changes. Range from 0 to 65535. */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -36,9 +36,11 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef T_DjiReturnCode (*WaypointV2EventCbFunc)(T_DjiWaypointV2MissionEventPush eventData);
|
||||
typedef T_DjiReturnCode (*WaypointV2StateCbFunc)(T_DjiWaypointV2MissionStatePush stateData);
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Initialise waypoint v2 module, and user should call this function
|
||||
|
122
psdk_lib/include/dji_waypoint_v3.h
Normal file
122
psdk_lib/include/dji_waypoint_v3.h
Normal file
@ -0,0 +1,122 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file dji_waypoint_v3.h
|
||||
* @brief This is the header file for "dji_waypoint_v3.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_WAYPOINT_V3_H
|
||||
#define DJI_WAYPOINT_V3_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Waypoint v3 mission action.
|
||||
*/
|
||||
typedef enum {
|
||||
DJI_WAYPOINT_V3_ACTION_START = 0, /*!< Waypoint v3 mission start action. */
|
||||
DJI_WAYPOINT_V3_ACTION_STOP = 1, /*!< Waypoint v3 mission stop action. */
|
||||
DJI_WAYPOINT_V3_ACTION_PAUSE = 2, /*!< Waypoint v3 mission pause action. */
|
||||
DJI_WAYPOINT_V3_ACTION_RESUME = 3, /*!< Waypoint v3 mission resume action. */
|
||||
} E_DjiWaypointV3Action;
|
||||
|
||||
/**
|
||||
* Waypoint v3 current aircraft state.
|
||||
*/
|
||||
typedef enum {
|
||||
DJI_WAYPOINT_V3_STATE_IDLE = 0, /*!< Waypoint v3 aircraft in idle state. */
|
||||
DJI_WAYPOINT_V3_STATE_PREPARE = 16, /*!< Waypoint v3 aircraft in prepare state. */
|
||||
DJI_WAYPOINT_V3_STATE_TRANS_MISSION = 32, /*!< Waypoint v3 aircraft in trans mission state. */
|
||||
DJI_WAYPOINT_V3_STATE_MISSION = 48, /*!< Waypoint v3 aircraft in mission state. */
|
||||
DJI_WAYPOINT_V3_STATE_BREAK = 64, /*!< Waypoint v3 aircraft in break state. */
|
||||
DJI_WAYPOINT_V3_STATE_RESUME = 80, /*!< Waypoint v3 aircraft in resume state. */
|
||||
DJI_WAYPOINT_V3_STATE_RETURN_FIRSTPOINT = 98, /*!< Waypoint v3 aircraft in return first point state. */
|
||||
} E_DjiWaypointV3State;
|
||||
|
||||
/**
|
||||
* Waypoint v3 mission state.
|
||||
*/
|
||||
typedef struct {
|
||||
E_DjiWaypointV3State state; /*!< Waypoint v3 current aircraft state, #E_DjiWaypointV3State. */
|
||||
uint32_t wayLineId; /*!< Waypoint v3 current way line id. */
|
||||
uint16_t currentWaypointIndex; /*!< Waypoint v3 current waypoint index. */
|
||||
} T_DjiWaypointV3MissionState;
|
||||
|
||||
/**
|
||||
* @brief Prototype of callback function used to receive the waypoint v3 mission state.
|
||||
* @warning User can not execute blocking style operations or functions in callback function, because that will block
|
||||
* root thread, causing problems such as slow system response, payload disconnection or infinite loop.
|
||||
* @param missionState: current waypoint v3 mission state.
|
||||
* @return Execution result.
|
||||
*/
|
||||
typedef T_DjiReturnCode (*WaypointV3StateCallback)(T_DjiWaypointV3MissionState missionState);
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Initialise waypoint v3 module, and user should call this function.
|
||||
* before using waypoint v3 features.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWaypointV3_Init(void);
|
||||
|
||||
/**
|
||||
* @brief Deinitialise waypoint v3 module.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWaypointV3_DeInit(void);
|
||||
|
||||
/**
|
||||
* @brief Upload kmz file by raw data.
|
||||
* @note The size of kmz file is very small, you can use this interface to upload quickly.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWaypointV3_UploadKmzFile(const uint8_t *data, uint32_t dataLen);
|
||||
|
||||
/**
|
||||
* @brief Execute the mission action.
|
||||
* @note This action should be called after uploading the kmz file.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWaypointV3_Action(E_DjiWaypointV3Action action);
|
||||
|
||||
/**
|
||||
* @brief Register the mission state callback for waypoint mission.
|
||||
* @note If you want to monitor the state of waypoint mission, this interface should be called before uploading kmz
|
||||
* file or executing this mission action.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWaypointV3_RegMissionStateCallback(WaypointV3StateCallback callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DJI_WAYPOINT_V3_H
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
@ -66,6 +66,42 @@ typedef enum {
|
||||
DJI_WIDGET_SWITCH_STATE_ON = 1 /*!< Switch is turned on */
|
||||
} E_DjiWidgetSwitchState;
|
||||
|
||||
/**
|
||||
* @brief Switch widget speaker work mode.
|
||||
*/
|
||||
typedef enum {
|
||||
DJI_WIDGET_SPEAKER_WORK_MODE_TTS,
|
||||
DJI_WIDGET_SPEAKER_WORK_MODE_VOICE,
|
||||
} E_DjiWidgetSpeakerWorkMode;
|
||||
|
||||
/**
|
||||
* @brief Switch widget speaker play mode.
|
||||
*/
|
||||
typedef enum {
|
||||
DJI_WIDGET_SPEAKER_PLAY_MODE_SINGLE_PLAY,
|
||||
DJI_WIDGET_SPEAKER_PLAY_MODE_LOOP_PLAYBACK,
|
||||
} E_DjiWidgetSpeakerPlayMode;
|
||||
|
||||
/**
|
||||
* @brief Switch widget speaker state.
|
||||
*/
|
||||
typedef enum {
|
||||
DJI_WIDGET_SPEAKER_STATE_IDEL,
|
||||
DJI_WIDGET_SPEAKER_STATE_TRANSMITTING,
|
||||
DJI_WIDGET_SPEAKER_STATE_PLAYING,
|
||||
DJI_WIDGET_SPEAKER_STATE_ERROR,
|
||||
} E_DjiWidgetSpeakerState;
|
||||
|
||||
/**
|
||||
* @brief Switch widget transmit data event.
|
||||
*/
|
||||
typedef enum {
|
||||
DJI_WIDGET_TRANSMIT_DATA_EVENT_START,
|
||||
DJI_WIDGET_TRANSMIT_DATA_EVENT_TRANSMIT,
|
||||
DJI_WIDGET_TRANSMIT_DATA_EVENT_FINISH,
|
||||
DJI_WIDGET_TRANSMIT_DATA_EVENT_ABORT,
|
||||
} E_DjiWidgetTransmitDataEvent;
|
||||
|
||||
/**
|
||||
* @brief Widget file binary array.
|
||||
*/
|
||||
@ -132,6 +168,45 @@ typedef struct {
|
||||
void *userData;
|
||||
} T_DjiWidgetHandlerListItem;
|
||||
|
||||
typedef struct {
|
||||
uint16_t size;
|
||||
uint32_t uuid;
|
||||
uint8_t md5Sum[16];
|
||||
} T_DjiWidgetTtsDataInfo;
|
||||
|
||||
typedef struct {
|
||||
uint16_t size;
|
||||
uint32_t uuid;
|
||||
uint8_t md5Sum[16];
|
||||
} T_DjiWidgetVoiceDataInfo;
|
||||
|
||||
typedef struct {
|
||||
E_DjiWidgetSpeakerState state;
|
||||
E_DjiWidgetSpeakerWorkMode workMode;
|
||||
E_DjiWidgetSpeakerPlayMode playMode;
|
||||
uint8_t volume;
|
||||
uint32_t uuid;
|
||||
} T_DjiWidgetSpeakerState;
|
||||
|
||||
typedef struct {
|
||||
T_DjiReturnCode (*GetSpeakerState)(T_DjiWidgetSpeakerState *speakerState);
|
||||
|
||||
T_DjiReturnCode (*SetWorkMode)(E_DjiWidgetSpeakerWorkMode workMode);
|
||||
T_DjiReturnCode (*GetWorkMode)(E_DjiWidgetSpeakerWorkMode *workMode);
|
||||
T_DjiReturnCode (*SetPlayMode)(E_DjiWidgetSpeakerPlayMode playMode);
|
||||
T_DjiReturnCode (*GetPlayMode)(E_DjiWidgetSpeakerPlayMode *playMode);
|
||||
T_DjiReturnCode (*SetVolume)(uint8_t volume);
|
||||
T_DjiReturnCode (*GetVolume)(uint8_t *volume);
|
||||
|
||||
T_DjiReturnCode (*StartPlay)(void);
|
||||
T_DjiReturnCode (*StopPlay)(void);
|
||||
|
||||
T_DjiReturnCode (*ReceiveTtsData)(E_DjiWidgetTransmitDataEvent event,
|
||||
uint32_t offset, uint8_t *buf, uint16_t size);
|
||||
T_DjiReturnCode (*ReceiveVoiceData)(E_DjiWidgetTransmitDataEvent event,
|
||||
uint32_t offset, uint8_t *buf, uint16_t size);
|
||||
} T_DjiWidgetSpeakerHandler;
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Initialise widget module, and user should call this function before using widget features.
|
||||
@ -215,6 +290,15 @@ T_DjiReturnCode DjiWidgetFloatingWindow_ShowMessage(const char *str);
|
||||
*/
|
||||
T_DjiReturnCode DjiWidgetFloatingWindow_GetChannelState(T_DjiDataChannelState *state);
|
||||
|
||||
/**
|
||||
* @brief Register the handler for widget speaker function interfaces.
|
||||
* @note This interface registers the widget speaker function interface, including speaker settings, play operation,
|
||||
* speaker status interface.
|
||||
* @param widgetSpeakerHandler: pointer to the handler for widget speaker functions.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_DjiReturnCode DjiWidget_RegSpeakerHandler(const T_DjiWidgetSpeakerHandler *widgetSpeakerHandler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -25,6 +25,7 @@
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <stdexcept>
|
||||
#include "test_perception.hpp"
|
||||
#include "dji_logger.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
|
||||
@ -41,6 +42,11 @@ PerceptionSample::PerceptionSample()
|
||||
|
||||
returnCode = DjiPerception_Init();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
|
||||
if (returnCode == DJI_ERROR_SYSTEM_MODULE_CODE_NONSUPPORT) {
|
||||
USER_LOG_ERROR("Perception feature will support on later version.");
|
||||
}
|
||||
|
||||
throw std::runtime_error("Perception init failed");
|
||||
}
|
||||
}
|
||||
|
272
samples/sample_c++/platform/linux/common/osal/osal_socket.c
Normal file
272
samples/sample_c++/platform/linux/common/osal/osal_socket.c
Normal file
@ -0,0 +1,272 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file osal_socket.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 "osal_socket.h"
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include "stdlib.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
typedef struct {
|
||||
int socketFd;
|
||||
} T_SocketHandleStruct;
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
|
||||
/* Private values -------------------------------------------------------------*/
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
T_DjiReturnCode Osal_Socket(E_DjiSocketMode mode, T_DjiSocketHandle *socketHandle)
|
||||
{
|
||||
T_SocketHandleStruct *socketHandleStruct;
|
||||
|
||||
if (socketHandle == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
socketHandleStruct = malloc(sizeof(T_SocketHandleStruct));
|
||||
if (socketHandleStruct == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED;
|
||||
}
|
||||
|
||||
if (mode == DJI_SOCKET_MODE_UDP) {
|
||||
socketHandleStruct->socketFd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
} else if (mode == DJI_SOCKET_MODE_TCP) {
|
||||
socketHandleStruct->socketFd = socket(PF_INET, SOCK_STREAM, 0);
|
||||
} else {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*socketHandle = socketHandleStruct;
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode Osal_Close(T_DjiSocketHandle socketHandle)
|
||||
{
|
||||
T_SocketHandleStruct *socketHandleStruct = (T_SocketHandleStruct *) socketHandle;
|
||||
int32_t ret;
|
||||
|
||||
if (socketHandleStruct->socketFd <= 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ret = close(socketHandleStruct->socketFd);
|
||||
if (ret < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode Osal_Bind(T_DjiSocketHandle socketHandle, const char *ipAddr, uint32_t port)
|
||||
{
|
||||
T_SocketHandleStruct *socketHandleStruct = (T_SocketHandleStruct *) socketHandle;
|
||||
struct sockaddr_in addr;
|
||||
int32_t ret;
|
||||
|
||||
if (socketHandle == NULL || ipAddr == NULL || port == 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
bzero(&addr, sizeof(addr));
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons(port);
|
||||
addr.sin_addr.s_addr = inet_addr(ipAddr);
|
||||
|
||||
ret = bind(socketHandleStruct->socketFd, (struct sockaddr *) &addr, sizeof(struct sockaddr_in));
|
||||
if (ret < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode Osal_UdpSendData(T_DjiSocketHandle socketHandle, const char *ipAddr, uint32_t port,
|
||||
const uint8_t *buf, uint32_t len, uint32_t *realLen)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
T_SocketHandleStruct *socketHandleStruct = (T_SocketHandleStruct *) socketHandle;
|
||||
int32_t ret;
|
||||
|
||||
if (socketHandle <= 0 || ipAddr == NULL || port == 0 || buf == NULL || len == 0 || realLen == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
bzero(&addr, sizeof(addr));
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons(port);
|
||||
addr.sin_addr.s_addr = inet_addr(ipAddr);
|
||||
|
||||
ret = sendto(socketHandleStruct->socketFd, buf, len, 0, (struct sockaddr *) &addr, sizeof(struct sockaddr_in));
|
||||
if (ret >= 0) {
|
||||
*realLen = ret;
|
||||
} else {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode Osal_UdpRecvData(T_DjiSocketHandle socketHandle, char *ipAddr, uint32_t *port,
|
||||
uint8_t *buf, uint32_t len, uint32_t *realLen)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
T_SocketHandleStruct *socketHandleStruct = (T_SocketHandleStruct *) socketHandle;
|
||||
uint32_t addrLen = 0;
|
||||
int32_t ret;
|
||||
|
||||
if (socketHandle == NULL || ipAddr == NULL || port == 0 || buf == NULL || len == 0 || realLen == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode Osal_TcpListen(T_DjiSocketHandle socketHandle)
|
||||
{
|
||||
int32_t ret;
|
||||
T_SocketHandleStruct *socketHandleStruct = (T_SocketHandleStruct *) socketHandle;
|
||||
|
||||
if (socketHandle == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ret = listen(socketHandleStruct->socketFd, 5);
|
||||
if (ret < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode Osal_TcpAccept(T_DjiSocketHandle socketHandle, char *ipAddr, uint32_t *port,
|
||||
T_DjiSocketHandle *outSocketHandle)
|
||||
{
|
||||
T_SocketHandleStruct *socketHandleStruct = (T_SocketHandleStruct *) socketHandle;
|
||||
T_SocketHandleStruct *outSocketHandleStruct;
|
||||
struct sockaddr_in addr;
|
||||
uint32_t addrLen = 0;
|
||||
|
||||
if (socketHandle == NULL || ipAddr == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
outSocketHandleStruct = malloc(sizeof(T_SocketHandleStruct));
|
||||
if (outSocketHandleStruct == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED;
|
||||
}
|
||||
|
||||
outSocketHandleStruct->socketFd = accept(socketHandleStruct->socketFd, (struct sockaddr *) &addr, &addrLen);
|
||||
if (outSocketHandleStruct->socketFd < 0) {
|
||||
free(outSocketHandleStruct);
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
*port = ntohs(addr.sin_port);
|
||||
*outSocketHandle = outSocketHandleStruct;
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode Osal_TcpConnect(T_DjiSocketHandle socketHandle, const char *ipAddr, uint32_t port)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
T_SocketHandleStruct *socketHandleStruct = (T_SocketHandleStruct *) socketHandle;
|
||||
int32_t ret;
|
||||
|
||||
if (socketHandle == NULL || ipAddr == NULL || port == 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
bzero(&addr, sizeof(addr));
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons(port);
|
||||
addr.sin_addr.s_addr = inet_addr(ipAddr);
|
||||
|
||||
ret = connect(socketHandleStruct->socketFd, (struct sockaddr *) &addr, sizeof(struct sockaddr_in));
|
||||
if (ret < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode Osal_TcpSendData(T_DjiSocketHandle socketHandle,
|
||||
const uint8_t *buf, uint32_t len, uint32_t *realLen)
|
||||
{
|
||||
T_SocketHandleStruct *socketHandleStruct = (T_SocketHandleStruct *) socketHandle;
|
||||
int32_t ret;
|
||||
|
||||
if (socketHandle == NULL || buf == NULL || len == 0 || realLen == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ret = send(socketHandleStruct->socketFd, buf, len, 0);
|
||||
if (ret >= 0) {
|
||||
*realLen = ret;
|
||||
} else {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode Osal_TcpRecvData(T_DjiSocketHandle socketHandle,
|
||||
uint8_t *buf, uint32_t len, uint32_t *realLen)
|
||||
{
|
||||
T_SocketHandleStruct *socketHandleStruct = (T_SocketHandleStruct *) socketHandle;
|
||||
int32_t ret;
|
||||
|
||||
if (socketHandle == NULL || buf == NULL || len == 0 || realLen == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ret = recv(socketHandleStruct->socketFd, buf, len, 0);
|
||||
if (ret >= 0) {
|
||||
*realLen = ret;
|
||||
} else {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
72
samples/sample_c++/platform/linux/common/osal/osal_socket.h
Normal file
72
samples/sample_c++/platform/linux/common/osal/osal_socket.h
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file osal_socket.h
|
||||
* @brief This is the header file for "osal_socket.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 OSAL_SOCKET_H
|
||||
#define OSAL_SOCKET_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
T_DjiReturnCode Osal_Socket(E_DjiSocketMode mode, T_DjiSocketHandle *socketHandle);
|
||||
|
||||
T_DjiReturnCode Osal_Close(T_DjiSocketHandle socketHandle);
|
||||
|
||||
T_DjiReturnCode Osal_Bind(T_DjiSocketHandle socketHandle, const char *ipAddr, uint32_t port);
|
||||
|
||||
T_DjiReturnCode Osal_UdpSendData(T_DjiSocketHandle socketHandle, const char *ipAddr, uint32_t port,
|
||||
const uint8_t *buf, uint32_t len, uint32_t *realLen);
|
||||
|
||||
T_DjiReturnCode Osal_UdpRecvData(T_DjiSocketHandle socketHandle, char *ipAddr, uint32_t *port,
|
||||
uint8_t *buf, uint32_t len, uint32_t *realLen);
|
||||
|
||||
T_DjiReturnCode Osal_TcpListen(T_DjiSocketHandle socketHandle);
|
||||
|
||||
T_DjiReturnCode Osal_TcpAccept(T_DjiSocketHandle socketHandle, char *ipAddr, uint32_t *port,
|
||||
T_DjiSocketHandle *outSocketHandle);
|
||||
|
||||
T_DjiReturnCode Osal_TcpConnect(T_DjiSocketHandle socketHandle, const char *ipAddr, uint32_t port);
|
||||
|
||||
T_DjiReturnCode Osal_TcpSendData(T_DjiSocketHandle socketHandle,
|
||||
const uint8_t *buf, uint32_t len, uint32_t *realLen);
|
||||
|
||||
T_DjiReturnCode Osal_TcpRecvData(T_DjiSocketHandle socketHandle,
|
||||
uint8_t *buf, uint32_t len, uint32_t *realLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // OSAL_SOCKET_H
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
@ -26,11 +26,13 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage -lgcov")
|
||||
|
||||
include_directories(../../../module_sample)
|
||||
include_directories(../../../../sample_c/module_sample)
|
||||
include_directories(../common)
|
||||
|
||||
file(GLOB_RECURSE MODULE_SAMPLE_SRC
|
||||
../../../module_sample/liveview/*.c*
|
||||
../../../module_sample/perception/*.c*
|
||||
../../../../sample_c/module_sample/*.c
|
||||
)
|
||||
file(GLOB_RECURSE MODULE_COMMON_SRC ../common/*.c*)
|
||||
file(GLOB_RECURSE MODULE_HAL_SRC hal/*.c*)
|
||||
|
@ -32,8 +32,9 @@
|
||||
|
||||
#include "../common/osal/osal.h"
|
||||
#include "../common/osal/osal_fs.h"
|
||||
#include "../manifold2//hal/hal_usb_bulk.h"
|
||||
#include "../manifold2//hal/hal_uart.h"
|
||||
#include "../common/osal/osal_socket.h"
|
||||
#include "../manifold2/hal/hal_usb_bulk.h"
|
||||
#include "../manifold2/hal/hal_uart.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define DJI_LOG_PATH "Logs/DJI"
|
||||
@ -41,7 +42,7 @@
|
||||
#define DJI_LOG_FOLDER_NAME "Logs"
|
||||
#define DJI_LOG_PATH_MAX_SIZE (128)
|
||||
#define DJI_LOG_FOLDER_NAME_MAX_SIZE (32)
|
||||
#define DJI_SYSTEM_CMD_STR_MAX_SIZE (64)
|
||||
#define DJI_LOG_SYSTEM_CMD_MAX_SIZE (64)
|
||||
#define DJI_LOG_MAX_COUNT (10)
|
||||
|
||||
#define USER_UTIL_UNUSED(x) ((x) = (x))
|
||||
@ -62,7 +63,7 @@ Application::Application(int argc, char **argv)
|
||||
Application::DjiUser_SetupEnvironment();
|
||||
Application::DjiUser_ApplicationStart();
|
||||
|
||||
Osal_TaskSleepMs(1000);
|
||||
Osal_TaskSleepMs(3000);
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
@ -78,6 +79,18 @@ void Application::DjiUser_SetupEnvironment()
|
||||
T_DjiLoggerConsole printConsole;
|
||||
T_DjiLoggerConsole localRecordConsole;
|
||||
T_DjiFileSystemHandler fileSystemHandler;
|
||||
T_DjiSocketHandler socketHandler;
|
||||
|
||||
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;
|
||||
|
||||
osalHandler.TaskCreate = Osal_TaskCreate;
|
||||
osalHandler.TaskDestroy = Osal_TaskDestroy;
|
||||
@ -145,6 +158,11 @@ void Application::DjiUser_SetupEnvironment()
|
||||
throw std::runtime_error("Register hal usb bulk handler error.");
|
||||
}
|
||||
|
||||
returnCode = DjiPlatform_RegSocketHandler(&socketHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
throw std::runtime_error("register osal socket handler error");
|
||||
}
|
||||
|
||||
returnCode = DjiPlatform_RegFileSystemHandler(&fileSystemHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
throw std::runtime_error("Register osal filesystem handler error.");
|
||||
@ -272,7 +290,7 @@ T_DjiReturnCode Application::DjiUser_LocalWriteFsInit(const char *path)
|
||||
{
|
||||
T_DjiReturnCode djiReturnCode = DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
char filePath[DJI_LOG_PATH_MAX_SIZE];
|
||||
char systemCmd[DJI_SYSTEM_CMD_STR_MAX_SIZE];
|
||||
char systemCmd[DJI_LOG_SYSTEM_CMD_MAX_SIZE];
|
||||
char folderName[DJI_LOG_FOLDER_NAME_MAX_SIZE];
|
||||
time_t currentTime = time(nullptr);
|
||||
struct tm *localTime = localtime(¤tTime);
|
||||
|
@ -25,7 +25,22 @@
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <liveview/test_liveview_entry.hpp>
|
||||
#include <perception/test_perception_entry.hpp>
|
||||
#include <flight_control/test_flight_control.h>
|
||||
#include <hms/test_hms.h>
|
||||
#include <waypoint_v2/test_waypoint_v2.h>
|
||||
#include <waypoint_v3/test_waypoint_v3.h>
|
||||
#include <gimbal_manager/test_gimbal_manager.h>
|
||||
#include "application.hpp"
|
||||
#include "fc_subscription/test_fc_subscription.h"
|
||||
#include <gimbal_emu/test_payload_gimbal_emu.h>
|
||||
#include <camera_emu/test_payload_cam_emu_media.h>
|
||||
#include <camera_emu/test_payload_cam_emu_base.h>
|
||||
#include <dji_logger.h>
|
||||
#include "widget/test_widget.h"
|
||||
#include "widget/test_widget_speaker.h"
|
||||
#include <power_management/test_power_management.h>
|
||||
#include "data_transmission/test_data_transmission.h"
|
||||
#include <camera_manager/test_camera_manager.h>
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
|
||||
@ -34,35 +49,182 @@
|
||||
/* Private values -------------------------------------------------------------*/
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
static T_DjiReturnCode DjiTest_HighPowerApplyPinInit();
|
||||
static T_DjiReturnCode DjiTest_WriteHighPowerApplyPin(E_DjiPowerManagementPinState pinState);
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Application application(argc, argv);
|
||||
char inputChar;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiTestApplyHighPowerHandler applyHighPowerHandler;
|
||||
|
||||
start:
|
||||
std::cout
|
||||
<< "\n"
|
||||
<< "| Available commands: |\n"
|
||||
<< "| [0] Camera stream view sample |\n"
|
||||
<< "| [1] Stereo vision view sample |\n"
|
||||
<< "| Available commands: |\n"
|
||||
<< "| [0] Fc subscribe sample - subscribe quaternion and gps data |\n"
|
||||
<< "| [1] Flight controller sample - take off landing |\n"
|
||||
<< "| [2] Flight controller sample - take off position ctrl landing |\n"
|
||||
<< "| [3] Flight controller sample - take off go home force landing |\n"
|
||||
<< "| [4] Flight controller sample - take off velocity ctrl landing |\n"
|
||||
<< "| [5] Flight controller sample - arrest flying |\n"
|
||||
<< "| [6] Flight controller sample - set get parameters |\n"
|
||||
<< "| [7] Hms info sample - get health manger system info |\n"
|
||||
<< "| [8] Waypoint 2.0 sample - run airline mission by settings (only support on M300 RTK) |\n"
|
||||
<< "| [9] Waypoint 3.0 sample - run airline mission by kmz file (only support on M30/30T) |\n"
|
||||
<< "| [a] Gimbal manager sample - rotate gimbal on free mode |\n"
|
||||
<< "| [b] Gimbal manager sample - rotate gimbal on yaw follow mode |\n"
|
||||
<< "| [c] Camera stream view sample - display the camera video stream |\n"
|
||||
<< "| [d] Stereo vision view sample - display the stereo image (only support on M300 RTK) |\n"
|
||||
<< "| [e] Start camera all feautes sample - you can operate the camera on DJI Pilot |\n"
|
||||
<< "| [f] Start gimbal all feautes sample - you can operate the gimbal on DJI Pilot |\n"
|
||||
<< "| [g] Start widget all feautes sample - you can operate the widget on DJI Pilot |\n"
|
||||
<< "| [h] Start widget speaker sample - you can operate the speaker on MSDK demo |\n"
|
||||
<< "| [i] Start power management sample - you will see notification when aircraft power off |\n"
|
||||
<< "| [j] Start data transmission sample - you can send or recv custom data on MSDK demo |\n"
|
||||
<< "| [l] Run camera manager sample - shoot photo by the selected camera mounted position |\n"
|
||||
<< std::endl;
|
||||
|
||||
std::cin >> inputChar;
|
||||
switch (inputChar) {
|
||||
case '0':
|
||||
DjiUser_RunCameraStreamViewSample();
|
||||
DjiTest_FcSubscriptionRunSample();
|
||||
break;
|
||||
case '1':
|
||||
DjiTest_FlightControlRunSample(E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_TAKE_OFF_LANDING);
|
||||
break;
|
||||
case '2':
|
||||
DjiTest_FlightControlRunSample(E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_TAKE_OFF_POSITION_CTRL_LANDING);
|
||||
break;
|
||||
case '3':
|
||||
DjiTest_FlightControlRunSample(E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_TAKE_OFF_GO_HOME_FORCE_LANDING);
|
||||
break;
|
||||
case '4':
|
||||
DjiTest_FlightControlRunSample(E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_TAKE_OFF_VELOCITY_CTRL_LANDING);
|
||||
break;
|
||||
case '5':
|
||||
DjiTest_FlightControlRunSample(E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_ARREST_FLYING);
|
||||
break;
|
||||
case '6':
|
||||
DjiTest_FlightControlRunSample(E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_SET_GET_PARAM);
|
||||
break;
|
||||
case '7':
|
||||
DjiTest_HmsRunSample();
|
||||
break;
|
||||
case '8':
|
||||
DjiTest_WaypointV2RunSample();
|
||||
break;
|
||||
case '9':
|
||||
DjiTest_WaypointV3RunSample();
|
||||
break;
|
||||
case 'a':
|
||||
DjiTest_GimbalManagerRunSample(DJI_MOUNT_POSITION_PAYLOAD_PORT_NO1, DJI_GIMBAL_MODE_FREE);
|
||||
break;
|
||||
case 'b':
|
||||
DjiTest_GimbalManagerRunSample(DJI_MOUNT_POSITION_PAYLOAD_PORT_NO1, DJI_GIMBAL_MODE_YAW_FOLLOW);
|
||||
break;
|
||||
case 'c':
|
||||
DjiUser_RunCameraStreamViewSample();
|
||||
break;
|
||||
case 'd':
|
||||
DjiUser_RunStereoVisionViewSample();
|
||||
break;
|
||||
case 'e':
|
||||
returnCode = DjiTest_CameraEmuBaseStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("camera emu common init error");
|
||||
break;
|
||||
}
|
||||
|
||||
if (DjiPlatform_GetSocketHandler() != NULL) {
|
||||
returnCode = DjiTest_CameraEmuMediaStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("camera emu media init error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Start camera all feautes sample successfully");
|
||||
break;
|
||||
case 'f':
|
||||
if (DjiTest_GimbalStartService() != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("psdk gimbal init error");
|
||||
break;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Start gimbal all feautes sample successfully");
|
||||
break;
|
||||
case 'g':
|
||||
returnCode = DjiTest_WidgetStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget sample init error");
|
||||
break;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Start widget all feautes sample successfully");
|
||||
break;
|
||||
case 'h':
|
||||
returnCode = DjiTest_WidgetSpeakerStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget speaker test init error");
|
||||
break;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Start widget speaker sample successfully");
|
||||
break;
|
||||
case 'i':
|
||||
applyHighPowerHandler.pinInit = DjiTest_HighPowerApplyPinInit;
|
||||
applyHighPowerHandler.pinWrite = DjiTest_WriteHighPowerApplyPin;
|
||||
|
||||
returnCode = DjiTest_RegApplyHighPowerHandler(&applyHighPowerHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("regsiter apply high power handler error");
|
||||
break;
|
||||
}
|
||||
|
||||
returnCode = DjiTest_PowerManagementStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("power management init error");
|
||||
break;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Start power management sample successfully");
|
||||
break;
|
||||
case 'j':
|
||||
returnCode = DjiTest_DataTransmissionStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("data transmission sample init error");
|
||||
break;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Start data transmission sample successfully");
|
||||
break;
|
||||
case 'l':
|
||||
DjiTest_CameraManagerRunSample(DJI_MOUNT_POSITION_PAYLOAD_PORT_NO1,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SHOOT_SINGLE_PHOTO);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
osalHandler->TaskSleepMs(2000);
|
||||
|
||||
goto start;
|
||||
}
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
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;
|
||||
}
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define UART_DEV_NAME_STR_SIZE (128)
|
||||
#define DJI_SYSTEM_CMD_STR_MAX_SIZE (64)
|
||||
#define DJI_SYSTEM_CMD_MAX_SIZE (64)
|
||||
#define DJI_SYSTEM_RESULT_STR_MAX_SIZE (128)
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
@ -48,7 +48,7 @@ T_DjiReturnCode HalUart_Init(E_DjiHalUartNum uartNum, uint32_t baudRate, T_DjiUa
|
||||
struct flock lock;
|
||||
T_DjiReturnCode returnCode = DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
char uartName[UART_DEV_NAME_STR_SIZE];
|
||||
char systemCmd[DJI_SYSTEM_CMD_STR_MAX_SIZE];
|
||||
char systemCmd[DJI_SYSTEM_CMD_MAX_SIZE];
|
||||
char *ret = NULL;
|
||||
char lineBuf[DJI_SYSTEM_RESULT_STR_MAX_SIZE] = {0};
|
||||
FILE *fp;
|
||||
|
@ -1234,7 +1234,8 @@ T_DjiReturnCode DjiTest_CameraEmuBaseStartService(void)
|
||||
|
||||
returnCode = DjiPayloadCamera_Init();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("payload camera init error:0x%08llX", returnCode);
|
||||
USER_LOG_ERROR("init payload camera error:0x%08llX", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
/* Init the SDcard parameters */
|
||||
|
@ -51,6 +51,8 @@ static const T_DjiTestCameraTypeStr s_cameraTypeStrList[] = {
|
||||
{DJI_CAMERA_TYPE_H20T, "Zenmuse H20T"},
|
||||
{DJI_CAMERA_TYPE_P1, "Zenmuse P1"},
|
||||
{DJI_CAMERA_TYPE_L1, "Zenmuse L1"},
|
||||
{DJI_CAMERA_TYPE_M30, "Zenmuse M30"},
|
||||
{DJI_CAMERA_TYPE_M30T, "Zenmuse M30T"},
|
||||
};
|
||||
|
||||
static FILE *s_downloadMediaFile = NULL;
|
||||
|
@ -48,10 +48,9 @@ static T_DjiReturnCode ReceiveDataFromPayload(const uint8_t *data, uint16_t len)
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
static T_DjiTaskHandle s_userDataTransmissionThread;
|
||||
static T_DjiAircraftInfoBaseInfo s_aircraftInfoBaseInfo;
|
||||
static DjiTestDataTransmissionConfig s_dataTransmissionConfig = {0};
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
T_DjiReturnCode DjiTest_DataTransmissionStartService(DjiTestDataTransmissionConfig config)
|
||||
T_DjiReturnCode DjiTest_DataTransmissionStartService(void)
|
||||
{
|
||||
T_DjiReturnCode djiStat;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
@ -61,8 +60,6 @@ T_DjiReturnCode DjiTest_DataTransmissionStartService(DjiTestDataTransmissionConf
|
||||
char ipAddr[DJI_IP_ADDR_STR_SIZE_MAX];
|
||||
uint16_t port;
|
||||
|
||||
memcpy(&s_dataTransmissionConfig, &config, sizeof(DjiTestDataTransmissionConfig));
|
||||
|
||||
djiStat = DjiLowSpeedDataChannel_Init();
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("init data transmission module error.");
|
||||
@ -179,20 +176,20 @@ static void *UserDataTransmission_Task(void *arg)
|
||||
USER_LOG_ERROR("get send to onboard computer channel state error.");
|
||||
}
|
||||
|
||||
if (s_dataTransmissionConfig.isEnableHighSpeedDataChannel == true) {
|
||||
djiStat = DjiHighSpeedDataChannel_SendDataStreamData(dataToBeSent, sizeof(dataToBeSent));
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
USER_LOG_ERROR("send data to data stream error.");
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
djiStat = DjiHighSpeedDataChannel_SendDataStreamData(dataToBeSent, sizeof(dataToBeSent));
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
USER_LOG_ERROR("send data to data stream error.");
|
||||
|
||||
djiStat = DjiHighSpeedDataChannel_GetDataStreamState(&state);
|
||||
if (djiStat == DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_DEBUG(
|
||||
"data stream state: realtimeBandwidthLimit: %d, realtimeBandwidthBeforeFlowController: %d, busyState: %d.",
|
||||
state.realtimeBandwidthLimit, state.realtimeBandwidthBeforeFlowController, state.busyState);
|
||||
} else {
|
||||
USER_LOG_ERROR("get data stream state error.");
|
||||
}
|
||||
djiStat = DjiHighSpeedDataChannel_GetDataStreamState(&state);
|
||||
if (djiStat == DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_DEBUG(
|
||||
"data stream state: realtimeBandwidthLimit: %d, realtimeBandwidthBeforeFlowController: %d, busyState: %d.",
|
||||
state.realtimeBandwidthLimit, state.realtimeBandwidthBeforeFlowController, state.busyState);
|
||||
} else {
|
||||
USER_LOG_ERROR("get data stream state error.");
|
||||
}
|
||||
#endif
|
||||
} else if (s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_EXTENSION_PORT) {
|
||||
channelAddress = DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO1;
|
||||
djiStat = DjiLowSpeedDataChannel_SendData(channelAddress, dataToBeSent, sizeof(dataToBeSent));
|
||||
|
@ -38,13 +38,10 @@ extern "C" {
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
bool isEnableLowSpeedDataChannel;
|
||||
bool isEnableHighSpeedDataChannel;
|
||||
} DjiTestDataTransmissionConfig;
|
||||
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
T_DjiReturnCode DjiTest_DataTransmissionStartService(DjiTestDataTransmissionConfig config);
|
||||
T_DjiReturnCode DjiTest_DataTransmissionStartService(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ T_DjiReturnCode DjiTest_FcSubscriptionRunSample(void)
|
||||
|
||||
USER_LOG_INFO("--> Step 3: Get latest value of the subscribed topics in the next 20s\r\n");
|
||||
|
||||
for (int i = 0; i < 20; ++i) {
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
osalHandler->TaskSleepMs(1000 / FC_SUBSCRIPTION_TASK_FREQ);
|
||||
djiStat = DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_VELOCITY,
|
||||
(uint8_t *) &velocity,
|
||||
|
@ -127,6 +127,12 @@ T_DjiReturnCode DjiTest_GimbalStartService(void)
|
||||
s_commonHandler.Reset = Reset;
|
||||
s_commonHandler.FineTuneAngle = FineTuneAngle;
|
||||
|
||||
djiStat = DjiFcSubscription_Init();
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("init data subscription module error.");
|
||||
return djiStat;
|
||||
}
|
||||
|
||||
if (osalHandler->MutexCreate(&s_commonMutex) != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("mutex create error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
@ -145,11 +151,13 @@ T_DjiReturnCode DjiTest_GimbalStartService(void)
|
||||
djiStat = DjiGimbal_Init();
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("init gimbal module error: 0x%08llX", djiStat);
|
||||
return djiStat;
|
||||
}
|
||||
|
||||
djiStat = DjiGimbal_RegCommonHandler(&s_commonHandler);
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("gimbal register common handler error: 0x%08llX", djiStat);
|
||||
return djiStat;
|
||||
}
|
||||
|
||||
if (osalHandler->TaskCreate("user_gimbal_task", UserGimbal_Task,
|
||||
@ -379,6 +387,14 @@ static void *UserGimbal_Task(void *arg)
|
||||
|
||||
USER_UTIL_UNUSED(arg);
|
||||
|
||||
djiStat = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_QUATERNION, DJI_DATA_SUBSCRIPTION_TOPIC_10_HZ,
|
||||
NULL);
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Subscribe topic quaternion error.");
|
||||
} else {
|
||||
USER_LOG_DEBUG("Subscribe topic quaternion success.");
|
||||
}
|
||||
|
||||
while (1) {
|
||||
osalHandler->TaskSleepMs(1000 / PAYLOAD_GIMBAL_TASK_FREQ);
|
||||
step++;
|
||||
|
@ -78,7 +78,6 @@ T_DjiReturnCode DjiTest_GimbalManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
returnCode = DjiGimbalManager_Rotate(mountPosition, rotation);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Target gimbal pry = (30, 0, 0) failed, error code: 0x%08X", returnCode);
|
||||
goto out;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(1000);
|
||||
@ -88,7 +87,6 @@ T_DjiReturnCode DjiTest_GimbalManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
returnCode = DjiGimbalManager_Rotate(mountPosition, rotation);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Target gimbal pry = (0, 30, 0) failed, error code: 0x%08X", returnCode);
|
||||
goto out;
|
||||
}
|
||||
osalHandler->TaskSleepMs(1000);
|
||||
|
||||
@ -97,7 +95,6 @@ T_DjiReturnCode DjiTest_GimbalManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
returnCode = DjiGimbalManager_Rotate(mountPosition, rotation);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Target gimbal pry = (0, 0, 30) failed, error code: 0x%08X", returnCode);
|
||||
goto out;
|
||||
}
|
||||
osalHandler->TaskSleepMs(1000);
|
||||
|
||||
@ -105,7 +102,6 @@ T_DjiReturnCode DjiTest_GimbalManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
returnCode = DjiGimbalManager_Reset(mountPosition);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Reset gimbal failed, error code: 0x%08X", returnCode);
|
||||
goto out;
|
||||
}
|
||||
osalHandler->TaskSleepMs(2000);
|
||||
}
|
||||
@ -119,7 +115,6 @@ T_DjiReturnCode DjiTest_GimbalManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
returnCode = DjiGimbalManager_Rotate(mountPosition, rotation);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Target gimbal pry = (30, 0, 0) failed, error code: 0x%08X", returnCode);
|
||||
goto out;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(1000);
|
||||
@ -129,7 +124,6 @@ T_DjiReturnCode DjiTest_GimbalManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
returnCode = DjiGimbalManager_Rotate(mountPosition, rotation);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Target gimbal pry = (0, 30, 0) failed, error code: 0x%08X", returnCode);
|
||||
goto out;
|
||||
}
|
||||
osalHandler->TaskSleepMs(1000);
|
||||
|
||||
@ -138,7 +132,6 @@ T_DjiReturnCode DjiTest_GimbalManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
returnCode = DjiGimbalManager_Rotate(mountPosition, rotation);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Target gimbal pry = (0, 0, 30) failed, error code: 0x%08X", returnCode);
|
||||
goto out;
|
||||
}
|
||||
osalHandler->TaskSleepMs(1000);
|
||||
|
||||
@ -146,7 +139,6 @@ T_DjiReturnCode DjiTest_GimbalManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
returnCode = DjiGimbalManager_Reset(mountPosition);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Reset gimbal failed, error code: 0x%08X", returnCode);
|
||||
goto out;
|
||||
}
|
||||
osalHandler->TaskSleepMs(2000);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ T_DjiReturnCode DjiTest_HmsRunSample(void)
|
||||
goto out;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(30000);
|
||||
osalHandler->TaskSleepMs(10000);
|
||||
|
||||
out:
|
||||
USER_LOG_INFO("--> Step 3: Deinit hms sample");
|
||||
|
161
samples/sample_c/module_sample/waypoint_v3/test_waypoint_v3.c
Normal file
161
samples/sample_c/module_sample/waypoint_v3/test_waypoint_v3.c
Normal file
@ -0,0 +1,161 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file test_waypoint_v3.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 <utils/util_file.h>
|
||||
#include <utils/util_misc.h>
|
||||
#include "test_waypoint_v3.h"
|
||||
#include "dji_logger.h"
|
||||
#include "dji_waypoint_v3.h"
|
||||
#include "waypoint_file_c/waypoint_v3_test_file_kmz.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define DJI_TEST_WAYPOINT_V3_KMZ_FILE_PATH_LEN_MAX (256)
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
|
||||
/* Private values -------------------------------------------------------------*/
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
static T_DjiReturnCode DjiTest_WaypointV3StateCallback(T_DjiWaypointV3MissionState missionState);
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
T_DjiReturnCode DjiTest_WaypointV3RunSample(void)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
FILE *kmzFile;
|
||||
uint32_t kmzFileSize = 0;
|
||||
uint8_t *kmzFileBuf;
|
||||
uint16_t readLen;
|
||||
char curFileDirPath[DJI_TEST_WAYPOINT_V3_KMZ_FILE_PATH_LEN_MAX];
|
||||
char tempPath[DJI_TEST_WAYPOINT_V3_KMZ_FILE_PATH_LEN_MAX];
|
||||
|
||||
returnCode = DjiWaypointV3_Init();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Waypoint v3 init failed.");
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
returnCode = DjiWaypointV3_RegMissionStateCallback(DjiTest_WaypointV3StateCallback);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Register waypoint v3 state callback failed.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
returnCode = DjiUserUtil_GetCurrentFileDirPath(__FILE__, DJI_TEST_WAYPOINT_V3_KMZ_FILE_PATH_LEN_MAX,
|
||||
curFileDirPath);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get file current path error, stat = 0x%08llX", returnCode);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*! Attention: suggest use the exported kmz file by DJI pilot. If use this test file, you need set the longitude as
|
||||
* 113.94755, latitude as 22.51853 on DJI Assistant 2 simulator */
|
||||
snprintf(tempPath, DJI_TEST_WAYPOINT_V3_KMZ_FILE_PATH_LEN_MAX, "%s/waypoint_file/waypoint_v3_test_file.kmz",
|
||||
curFileDirPath);
|
||||
|
||||
kmzFile = fopen(tempPath, "r");
|
||||
if (kmzFile == NULL) {
|
||||
USER_LOG_ERROR("Open kmz file failed.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
returnCode = UtilFile_GetFileSize(kmzFile, &kmzFileSize);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get kmz file size failed.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
kmzFileBuf = osalHandler->Malloc(kmzFileSize);
|
||||
if (kmzFileBuf == NULL) {
|
||||
USER_LOG_ERROR("Malloc kmz file buf error.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
readLen = fread(kmzFileBuf, 1, kmzFileSize, kmzFile);
|
||||
if (readLen != kmzFileSize) {
|
||||
USER_LOG_ERROR("Read kmz file data failed.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
returnCode = DjiWaypointV3_UploadKmzFile(kmzFileBuf, kmzFileSize);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Upload kmz file failed.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
osalHandler->Free(kmzFileBuf);
|
||||
#else
|
||||
returnCode = DjiWaypointV3_UploadKmzFile(waypoint_v3_test_file_kmz_fileBinaryArray,
|
||||
waypoint_v3_test_file_kmz_fileSize);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Upload kmz file failed.");
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
||||
USER_LOG_INFO("Execute start action");
|
||||
returnCode = DjiWaypointV3_Action(DJI_WAYPOINT_V3_ACTION_START);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Execute start action failed.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 30; ++i) {
|
||||
osalHandler->TaskSleepMs(1000);
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Execute pause action");
|
||||
returnCode = DjiWaypointV3_Action(DJI_WAYPOINT_V3_ACTION_PAUSE);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Execute start action failed.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
osalHandler->TaskSleepMs(1000);
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Execute resume action");
|
||||
returnCode = DjiWaypointV3_Action(DJI_WAYPOINT_V3_ACTION_RESUME);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Execute start action failed.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
static T_DjiReturnCode DjiTest_WaypointV3StateCallback(T_DjiWaypointV3MissionState missionState)
|
||||
{
|
||||
USER_LOG_INFO("Waypoint v3 mission state: %d, current waypoint index: %d, wayLine id: %d", missionState.state,
|
||||
missionState.currentWaypointIndex, missionState.wayLineId);
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
@ -0,0 +1,49 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file test_waypoint_v3.h
|
||||
* @brief This is the header file for "test_waypoint_v3.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 TEST_WAYPOINT_V3_H
|
||||
#define TEST_WAYPOINT_V3_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
T_DjiReturnCode DjiTest_WaypointV3RunSample(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_WAYPOINT_V3_H
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
Binary file not shown.
@ -0,0 +1,245 @@
|
||||
/* Generated by file2c, do not edit manually */
|
||||
#ifndef __waypoint_v3_test_file_kmz_h_included
|
||||
#define __waypoint_v3_test_file_kmz_h_included
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Contents of file waypoint_v3_test_file.kmz */
|
||||
#define waypoint_v3_test_file_kmz_fileName "waypoint_v3_test_file.kmz"
|
||||
#define waypoint_v3_test_file_kmz_fileSize 3690
|
||||
|
||||
static const uint8_t waypoint_v3_test_file_kmz_fileBinaryArray[3690] = {
|
||||
0x50, 0x4B, 0x03, 0x04, 0x14, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0xA8,
|
||||
0x54, 0x6C, 0xA8, 0x06, 0x00, 0x00, 0xD9, 0x59, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x77, 0x70,
|
||||
0x6D, 0x7A, 0x2F, 0x74, 0x65, 0x6D, 0x70, 0x6C, 0x61, 0x74, 0x65,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0xC0, 0xB9, 0x3A, 0x3C, 0x0C, 0x9C, 0xF1, 0xE9, 0x19, 0x78, 0x5C, 0x11, 0x78, 0x90,
|
||||
0x9F, 0xF0, 0x3F, 0x9A, 0x0E, 0x4C, 0x9E, 0x11, 0xF0, 0xDF, 0x30, 0x81, 0x46, 0x0B, 0xC9, 0x19,
|
||||
0xA2, 0x86, 0x86, 0x09, 0xD4, 0x52, 0x29, 0x44, 0x00, 0xE5, 0xC9, 0x04, 0x44, 0x26, 0x02, 0x65,
|
||||
0x42, 0x82, 0x94, 0xD6, 0x2A, 0xED, 0x1A, 0x26, 0x24, 0x87, 0x0C, 0x92, 0xC6, 0x28, 0x65, 0x3D,
|
||||
0x99, 0xC0, 0xC8, 0x44, 0xA0, 0x4C, 0x30, 0x05, 0xC2, 0x39, 0x74, 0xBA, 0x45, 0x82, 0x17, 0x12,
|
||||
0x25, 0x94, 0x06, 0xE9, 0x89, 0x84, 0x8C, 0x48, 0x04, 0x8A, 0x84, 0xB6, 0x12, 0x09, 0x08, 0x45,
|
||||
0x1B, 0x26, 0xA4, 0x26, 0xA1, 0x0C, 0xF1, 0x3F, 0x9E, 0x4C, 0xA8, 0xC8, 0x44, 0xA0, 0x4C, 0x18,
|
||||
0x63, 0x90, 0x88, 0xB4, 0x38, 0xA4, 0x13, 0x0A, 0x1C, 0x2A, 0x23, 0x94, 0x6F, 0x8A, 0x49, 0x91,
|
||||
0x89, 0x40, 0x99, 0xB0, 0x92, 0xFF, 0xD6, 0x4B, 0x87, 0xDA, 0x33, 0x21, 0xAC, 0x34, 0x20, 0x34,
|
||||
0x0A, 0xF4, 0x4D, 0x27, 0x74, 0x64, 0x22, 0x50, 0x26, 0x8C, 0x71, 0x8E, 0x04, 0x49, 0xB1, 0xCF,
|
||||
0x27, 0xC0, 0x91, 0xE2, 0xEC, 0x42, 0xF0, 0xA2, 0xE2, 0x1B, 0x27, 0x4C, 0x64, 0x22, 0x50, 0x26,
|
||||
0xB4, 0x93, 0xCE, 0x5A, 0x4D, 0x68, 0x1B, 0x26, 0x94, 0x20, 0xB2, 0x28, 0xB4, 0x31, 0x9E, 0x4C,
|
||||
0xD8, 0xC8, 0x44, 0xA8, 0x4C, 0x48, 0xDE, 0x67, 0x80, 0x33, 0x16, 0xF7, 0x4C, 0x58, 0x63, 0x49,
|
||||
0x08, 0x29, 0xBC, 0xB7, 0x1D, 0x2E, 0x22, 0x11, 0x28, 0x12, 0xBC, 0xC3, 0xB0, 0x1C, 0x16, 0x24,
|
||||
0x35, 0x4B, 0x87, 0x75, 0xC6, 0x09, 0x34, 0x02, 0x49, 0xFB, 0x2A, 0x56, 0x51, 0xC6, 0x0C, 0x15,
|
||||
0x0A, 0xDE, 0x7B, 0x3A, 0x4B, 0xC8, 0xC9, 0xE6, 0x61, 0xED, 0x10, 0xC4, 0x4B, 0x09, 0x08, 0xDF,
|
||||
0x40, 0x01, 0x51, 0xC7, 0x0C, 0x15, 0x0A, 0x8E, 0x11, 0x52, 0x2A, 0xA7, 0x9D, 0x6A, 0xA0, 0x70,
|
||||
0x56, 0x0B, 0xAD, 0x35, 0x87, 0x0A, 0x5F, 0x28, 0xA2, 0x90, 0x19, 0x2A, 0x14, 0xC2, 0xDA, 0xFA,
|
||||
0x6E, 0x87, 0x46, 0x38, 0xEC, 0x46, 0xA5, 0xA9, 0xB9, 0x00, 0xDF, 0x2C, 0x13, 0xA2, 0x94, 0x19,
|
||||
0x2A, 0x14, 0x00, 0x9C, 0x63, 0x6A, 0xAB, 0x1A, 0x75, 0x1B, 0xB4, 0x96, 0x4C, 0x05, 0x48, 0xEF,
|
||||
0x7B, 0x60, 0x51, 0xC9, 0x0C, 0x16, 0x09, 0x4B, 0x52, 0x5B, 0x61, 0x4C, 0xCB, 0x84, 0x33, 0x1C,
|
||||
0x34, 0x38, 0xC3, 0x40, 0x6F, 0x28, 0xA2, 0x94, 0x19, 0x2A, 0x14, 0x12, 0xB5, 0x71, 0xA8, 0xAD,
|
||||
0x74, 0x0D, 0x14, 0x46, 0x0A, 0x67, 0x0D, 0x90, 0xF1, 0xDE, 0x7B, 0x44, 0x2D, 0x33, 0x54, 0x28,
|
||||
0x98, 0x0A, 0x09, 0xBC, 0x7A, 0x68, 0xD9, 0x46, 0x0A, 0x72, 0x68, 0x2C, 0x6A, 0xE1, 0x9D, 0x66,
|
||||
0x46, 0x31, 0x33, 0x54, 0x28, 0x78, 0xF3, 0xC9, 0x04, 0x10, 0xB4, 0x48, 0xF0, 0xA6, 0x83, 0x8F,
|
||||
0x09, 0xE1, 0x2B, 0x6F, 0x43, 0xD4, 0x32, 0x43, 0x45, 0x42, 0xD7, 0xB7, 0x38, 0x08, 0x8C, 0x69,
|
||||
0x16, 0x0F, 0xE1, 0x48, 0xA3, 0x55, 0x40, 0xCE, 0x5B, 0xA3, 0x88, 0x6A, 0x66, 0xA8, 0x50, 0x90,
|
||||
0x03, 0x52, 0x0C, 0x06, 0xB5, 0x50, 0x68, 0x24, 0x12, 0x4E, 0xF0, 0x86, 0xD4, 0x13, 0x0A, 0x8C,
|
||||
0x6A, 0x66, 0xB0, 0x50, 0xA0, 0xB0, 0xAA, 0x4E, 0x2A, 0x5A, 0x28, 0x48, 0x09, 0xE4, 0xCD, 0x07,
|
||||
0x38, 0xEF, 0x07, 0xF0, 0xA2, 0x9A, 0x19, 0x2A, 0x14, 0x4A, 0x73, 0x06, 0x41, 0x12, 0xC0, 0x1E,
|
||||
0x84, 0x2B, 0x01, 0xC2, 0x48, 0x8E, 0x1D, 0xBE, 0x50, 0x44, 0x35, 0x33, 0x58, 0x28, 0x04, 0x20,
|
||||
0x49, 0x85, 0xBA, 0x55, 0x29, 0x24, 0x3A, 0x49, 0x44, 0xCE, 0x80, 0x2F, 0x14, 0x51, 0xCD, 0x0C,
|
||||
0x15, 0x0A, 0x94, 0x4E, 0x59, 0xA1, 0x00, 0xB1, 0x4D, 0x34, 0xB5, 0x95, 0xF5, 0xD3, 0x15, 0xDE,
|
||||
0x81, 0x22, 0xCA, 0x99, 0xA1, 0x32, 0xC1, 0xE3, 0x4F, 0x9C, 0x51, 0x48, 0x6A, 0x90, 0x10, 0xC6,
|
||||
0x10, 0xF1, 0x4F, 0xEF, 0xBB, 0x1E, 0x18, 0xD5, 0xCC, 0x50, 0x99, 0x50, 0x16, 0xD1, 0x82, 0x40,
|
||||
0x69, 0x9A, 0xFB, 0xA3, 0x46, 0x2B, 0x09, 0x4A, 0xF1, 0x0E, 0xC4, 0x17, 0x8A, 0xA8, 0x66, 0x86,
|
||||
0x0A, 0x85, 0x06, 0x94, 0xBB, 0xFD, 0x46, 0x0B, 0x85, 0x45, 0xCE, 0x32, 0x19, 0x13, 0xE9, 0x2B,
|
||||
0x5D, 0x61, 0x54, 0x33, 0x43, 0x85, 0xC2, 0x08, 0xD2, 0x52, 0xE2, 0x31, 0xA3, 0x00, 0xB2, 0xCC,
|
||||
0x88, 0xE5, 0x5D, 0xA9, 0x2F, 0x14, 0x51, 0xCF, 0x0C, 0x16, 0x0A, 0x5E, 0x2B, 0x0C, 0x10, 0xE8,
|
||||
0xCE, 0x93, 0x14, 0xA0, 0x88, 0x37, 0xA8, 0xCE, 0x17, 0x8A, 0xA8, 0x67, 0x86, 0x0A, 0x05, 0x6F,
|
||||
0x33, 0xAC, 0x12, 0xCA, 0x91, 0x6D, 0x1F, 0xA5, 0x20, 0xCE, 0x34, 0xAD, 0x22, 0xE1, 0x0B, 0x85,
|
||||
0x8C, 0x7A, 0x66, 0xB0, 0x50, 0x28, 0x30, 0xF5, 0x77, 0x88, 0xDA, 0xE5, 0x03, 0xA9, 0xFE, 0xA6,
|
||||
0x83, 0x33, 0xDE, 0xCF, 0xD7, 0xC8, 0x28, 0x67, 0x86, 0xCA, 0x04, 0x49, 0x47, 0x86, 0x14, 0xA8,
|
||||
0xE6, 0xAE, 0x39, 0x1A, 0x63, 0xA0, 0xBE, 0x4B, 0x8A, 0xDE, 0x81, 0x22, 0xCA, 0x99, 0xA1, 0x42,
|
||||
0xA1, 0xEA, 0x77, 0xCA, 0x9D, 0x70, 0x6D, 0x9C, 0x70, 0x00, 0xA8, 0x0D, 0xFA, 0xEF, 0x3D, 0x64,
|
||||
0x54, 0x33, 0x43, 0x65, 0x42, 0x5A, 0x0D, 0x00, 0xC6, 0x08, 0x73, 0x08, 0x14, 0x0A, 0x04, 0x39,
|
||||
0xAD, 0x7C, 0xA5, 0x2B, 0x19, 0xE5, 0xCC, 0x60, 0xA1, 0xC0, 0xFA, 0xE5, 0x0E, 0xB0, 0xCD, 0xFB,
|
||||
0x1E, 0x58, 0x7F, 0x9D, 0x82, 0x40, 0x1A, 0xEB, 0x7D, 0x87, 0x54, 0x46, 0x3D, 0x33, 0x58, 0x28,
|
||||
0xA4, 0x10, 0x48, 0x8E, 0xB3, 0x8A, 0xE6, 0xCD, 0x30, 0x5D, 0xBF, 0x52, 0x2C, 0x34, 0x79, 0x7F,
|
||||
0xDF, 0x4A, 0x46, 0x3D, 0x33, 0x54, 0x28, 0xC0, 0x70, 0x3E, 0x61, 0xE1, 0xF0, 0xA6, 0xB9, 0x15,
|
||||
0x86, 0x78, 0x3F, 0x22, 0xB4, 0xF2, 0xFE, 0x72, 0x4D, 0xD4, 0x33, 0x43, 0x85, 0x02, 0x95, 0x76,
|
||||
0x64, 0x25, 0x6F, 0x42, 0xF6, 0xCB, 0x87, 0x62, 0x4C, 0x84, 0x04, 0xE5, 0xB4, 0x77, 0x4E, 0x11,
|
||||
0xF5, 0xCC, 0xFF, 0x1B, 0x8A, 0xF1, 0xE8, 0xF8, 0x45, 0xD7, 0xF1, 0xE8, 0xF8, 0x15, 0xE5, 0x71,
|
||||
0xFD, 0x25, 0xE6, 0xC9, 0xB3, 0x7F, 0x00, 0x50, 0x4B, 0x03, 0x04, 0x14, 0x00, 0x00, 0x00, 0x08,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xB3, 0xD8, 0x8E, 0x16, 0xCE, 0x06, 0x00, 0x00, 0xD6, 0x99, 0x00,
|
||||
0x00, 0x12, 0x00, 0x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EB, 0x81, 0x2C, 0x10, 0x9B, 0x48,
|
||||
0xA0, 0x51, 0x84, 0x62, 0x42, 0xB4, 0x10, 0x3D, 0xBC, 0xAE, 0x44, 0x19, 0xEF, 0x98, 0xBC, 0x7E,
|
||||
0x18, 0x72, 0x03, 0x87, 0x11, 0x38, 0x42, 0xAC, 0x8B, 0x46, 0x51, 0x8A, 0x09, 0xD1, 0x42, 0xF4,
|
||||
0xF0, 0xD2, 0x4F, 0xC5, 0x4A, 0x69, 0x6F, 0xBC, 0x6E, 0x89, 0xF6, 0xCE, 0x80, 0x31, 0x26, 0x38,
|
||||
0xE9, 0x58, 0xA2, 0x45, 0x2A, 0x26, 0x44, 0x0B, 0xD1, 0x83, 0x13, 0x0D, 0xCE, 0x35, 0x4A, 0x6E,
|
||||
0x43, 0xB8, 0x7B, 0x71, 0xA5, 0x6C, 0x03, 0x35, 0xC6, 0x2E, 0x8B, 0xA1, 0x88, 0xC5, 0x84, 0x68,
|
||||
0x21, 0x7A, 0x70, 0xA2, 0x11, 0xD1, 0x5B, 0xE3, 0x74, 0x2B, 0xFE, 0x44, 0x63, 0x54, 0x40, 0x1A,
|
||||
0x55, 0xF4, 0xE6, 0x0C, 0xD1, 0x8A, 0x09, 0xCF, 0xC2, 0xF3, 0xF0, 0x3C, 0x3B, 0x56, 0xC6, 0x81,
|
||||
0xB5, 0x1D, 0xD0, 0xDE, 0x06, 0x77, 0x1D, 0x66, 0xD5, 0x14, 0x4D, 0xB4, 0x88, 0xC5, 0x84, 0x68,
|
||||
0x21, 0x7A, 0xF8, 0x75, 0x31, 0x32, 0xD6, 0x93, 0x71, 0xCA, 0xB7, 0x44, 0x5B, 0x05, 0xDE, 0x59,
|
||||
0x64, 0x1B, 0xBD, 0xD2, 0x2D, 0x6A, 0x31, 0x21, 0x5A, 0x88, 0x1E, 0xFE, 0xDD, 0x95, 0x22, 0x85,
|
||||
0x61, 0xD0, 0x6D, 0x54, 0xE7, 0xA3, 0xD9, 0x93, 0x75, 0x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 0x17, 0x2D, 0x82, 0x31, 0x01, 0x5A, 0x80, 0x1E, 0x5E,
|
||||
0x5E, 0x62, 0x3C, 0x87, 0x59, 0xB4, 0xE2, 0x96, 0x67, 0xB0, 0x96, 0x39, 0x5C, 0x46, 0x2B, 0xBA,
|
||||
0x49, 0xF4, 0x62, 0x02, 0xB4, 0x00, 0x3D, 0xFC, 0x98, 0xDB, 0x11, 0x39, 0x04, 0x52, 0xB6, 0xDD,
|
||||
0x75, 0x65, 0x8D, 0x56, 0xA8, 0x35, 0x71, 0xB4, 0x8B, 0x16, 0xBD, 0x98, 0x10, 0x2D, 0x44, 0x0F,
|
||||
0xFF, 0x36, 0x1A, 0x49, 0x6D, 0x56, 0xB7, 0x3B, 0xA2, 0x1D, 0x21, 0xD8, 0xC0, 0xB8, 0x8A, 0xD5,
|
||||
0x97, 0x90, 0xE8, 0xC5, 0x84, 0x68, 0x21, 0x7A, 0xF8, 0xF3, 0x02, 0x81, 0x8D, 0x52, 0xF4, 0x30,
|
||||
0x8B, 0x46, 0x76, 0x01, 0x70, 0x07, 0x14, 0xFD, 0x36, 0x5A, 0x14, 0x63, 0x42, 0xB4, 0x10, 0x3D,
|
||||
0x3C, 0xD1, 0x61, 0x88, 0x6D, 0x91, 0xD1, 0xEC, 0xED, 0x8C, 0x46, 0xCD, 0x88, 0xCE, 0xC7, 0x12,
|
||||
0x2D, 0x8A, 0x31, 0x21, 0x5A, 0x88, 0x7E, 0x8E, 0x23, 0x40, 0x9D, 0x06, 0xED, 0xD9, 0x75, 0x5B,
|
||||
0xA3, 0xD9, 0x5A, 0x76, 0x9A, 0x21, 0x96, 0x68, 0x25, 0x8A, 0x31, 0x21, 0x5A, 0x88, 0x7E, 0x06,
|
||||
0x55, 0x37, 0xDA, 0xE0, 0xA8, 0xA9, 0x1B, 0x75, 0x13, 0x37, 0xDD, 0xC4, 0xDB, 0xE8, 0xC3, 0x0E,
|
||||
0x94, 0x08, 0xC6, 0x04, 0x68, 0x01, 0x7A, 0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x84, 0x68, 0x21, 0xFA, 0x97, 0x89, 0x9E, 0x8C, 0xCF, 0xCB, 0x7C,
|
||||
0x9E, 0x56, 0xCD, 0xD5, 0x64, 0x7C, 0x56, 0xCE, 0xD6, 0x8B, 0xB4, 0x79, 0x8E, 0x93, 0xF1, 0xDD,
|
||||
0x22, 0x9F, 0xBE, 0xF8, 0x17, 0x50, 0x4B, 0x01, 0x02, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x08,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0xA8, 0x54, 0x6C, 0xA8, 0x06, 0x00, 0x00, 0xD9, 0x59, 0x00,
|
||||
0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x77, 0x70, 0x6D, 0x7A, 0x2F, 0x74, 0x65, 0x6D, 0x70, 0x6C, 0x61, 0x74, 0x65,
|
||||
0x2E, 0x6B, 0x6D, 0x6C, 0x50, 0x4B, 0x01, 0x02, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x08, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xB3, 0xD8, 0x8E, 0x16, 0xCE, 0x06, 0x00, 0x00, 0xD6, 0x99, 0x00, 0x00,
|
||||
0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD7, 0x06,
|
||||
0x00, 0x00, 0x77, 0x70, 0x6D, 0x7A, 0x2F, 0x77, 0x61, 0x79, 0x6C, 0x69, 0x6E, 0x65, 0x73, 0x2E,
|
||||
0x77, 0x70, 0x6D, 0x6C, 0x50, 0x4B, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00,
|
||||
0x7F, 0x00, 0x00, 0x00, 0xD5, 0x0D, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif /* __waypoint_v3_test_file_kmz_h_included */
|
708
samples/sample_c/module_sample/widget/test_widget_speaker.c
Normal file
708
samples/sample_c/module_sample/widget/test_widget_speaker.c
Normal file
@ -0,0 +1,708 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file test_widget_speaker.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 ------------------------------------------------------------------*/
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
|
||||
#include "test_widget_speaker.h"
|
||||
#include "dji_logger.h"
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "utils/util_misc.h"
|
||||
#include "utils/util_md5.h"
|
||||
|
||||
#ifdef OPUS_INSTALLED
|
||||
|
||||
#include <opus.h>
|
||||
|
||||
#endif
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define WIDGET_SPEAKER_TASK_STACK_SIZE (2048)
|
||||
|
||||
#define WIDGET_SPEAKER_USB_AUDIO_DEVICE_NAME "alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo"
|
||||
|
||||
#define WIDGET_SPEAKER_AUDIO_OPUS_FILE_NAME "test_audio.opus"
|
||||
#define WIDGET_SPEAKER_AUDIO_PCM_FILE_NAME "test_audio.pcm"
|
||||
|
||||
#define WIDGET_SPEAKER_TTS_FILE_NAME "test_tts.txt"
|
||||
#define WIDGET_SPEAKER_TTS_OUTPUT_FILE_NAME "tts_sample.wav"
|
||||
#define WIDGET_SPEAKER_TTS_FILE_MAX_SIZE (3000)
|
||||
|
||||
/*The frame size is hardcoded for this sample code but it doesn't have to be*/
|
||||
#define WIDGET_SPEAKER_AUDIO_OPUS_MAX_PACKET_SIZE (3 * 1276)
|
||||
#define WIDGET_SPEAKER_AUDIO_OPUS_MAX_FRAME_SIZE (6 * 960)
|
||||
#define WIDGET_SPEAKER_AUDIO_OPUS_SAMPLE_RATE (16000)
|
||||
#define WIDGET_SPEAKER_AUDIO_OPUS_CHANNELS (1)
|
||||
#define WIDGET_SPEAKER_AUDIO_OPUS_DECODE_FRAME_SIZE (160)
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
|
||||
/* Private values -------------------------------------------------------------*/
|
||||
static T_DjiWidgetSpeakerHandler s_speakerHandler = {0};
|
||||
static T_DjiMutexHandle s_speakerMutex = {0};
|
||||
static T_DjiWidgetSpeakerState s_speakerState = {0};
|
||||
static T_DjiTaskHandle s_widgetSpeakerTestThread;
|
||||
|
||||
static FILE *audioFile = NULL;
|
||||
static FILE *ttsFile = NULL;
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
static T_DjiReturnCode GetSpeakerState(T_DjiWidgetSpeakerState *speakerState);
|
||||
static T_DjiReturnCode SetWorkMode(E_DjiWidgetSpeakerWorkMode workMode);
|
||||
static T_DjiReturnCode GetWorkMode(E_DjiWidgetSpeakerWorkMode *workMode);
|
||||
static T_DjiReturnCode SetPlayMode(E_DjiWidgetSpeakerPlayMode playMode);
|
||||
static T_DjiReturnCode GetPlayMode(E_DjiWidgetSpeakerPlayMode *playMode);
|
||||
static T_DjiReturnCode StartPlay(void);
|
||||
static T_DjiReturnCode StopPlay(void);
|
||||
static T_DjiReturnCode SetVolume(uint8_t volume);
|
||||
static T_DjiReturnCode GetVolume(uint8_t *volume);
|
||||
static T_DjiReturnCode ReceiveTtsData(E_DjiWidgetTransmitDataEvent event,
|
||||
uint32_t offset, uint8_t *buf, uint16_t size);
|
||||
static T_DjiReturnCode ReceiveAudioData(E_DjiWidgetTransmitDataEvent event,
|
||||
uint32_t offset, uint8_t *buf, uint16_t size);
|
||||
static void *DjiTest_WidgetSpeakerTask(void *arg);
|
||||
static uint32_t DjiTest_GetVoicePlayProcessId(void);
|
||||
static uint32_t DjiTest_KillVoicePlayProcess(uint32_t pid);
|
||||
static T_DjiReturnCode DjiTest_DecodeAudioData(void);
|
||||
static T_DjiReturnCode DjiTest_PlayAudioData(void);
|
||||
static T_DjiReturnCode DjiTest_PlayTtsData(void);
|
||||
static T_DjiReturnCode DjiTest_CheckFileMd5Sum(const char *path, uint8_t *buf, uint16_t size);
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
T_DjiReturnCode DjiTest_WidgetSpeakerStartService(void)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
s_speakerHandler.GetSpeakerState = GetSpeakerState;
|
||||
s_speakerHandler.SetWorkMode = SetWorkMode;
|
||||
s_speakerHandler.GetWorkMode = GetWorkMode;
|
||||
s_speakerHandler.StartPlay = StartPlay;
|
||||
s_speakerHandler.StopPlay = StopPlay;
|
||||
s_speakerHandler.SetPlayMode = SetPlayMode;
|
||||
s_speakerHandler.GetPlayMode = GetPlayMode;
|
||||
s_speakerHandler.SetVolume = SetVolume;
|
||||
s_speakerHandler.GetVolume = GetVolume;
|
||||
s_speakerHandler.ReceiveTtsData = ReceiveTtsData;
|
||||
s_speakerHandler.ReceiveVoiceData = ReceiveAudioData;
|
||||
|
||||
returnCode = osalHandler->MutexCreate(&s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Create speaker mutex error: 0x%08llX", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
returnCode = DjiWidget_RegSpeakerHandler(&s_speakerHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Register speaker handler error: 0x%08llX", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
if (osalHandler->TaskCreate("user_widget_speaker_task", DjiTest_WidgetSpeakerTask, WIDGET_SPEAKER_TASK_STACK_SIZE,
|
||||
NULL,
|
||||
&s_widgetSpeakerTestThread) != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Dji widget speaker test task create error.");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
static uint32_t DjiTest_GetVoicePlayProcessId(void)
|
||||
{
|
||||
FILE *fp;
|
||||
char cmdStr[128];
|
||||
uint32_t pid;
|
||||
int ret;
|
||||
|
||||
snprintf(cmdStr, 128, "pgrep ffplay");
|
||||
fp = popen(cmdStr, "r");
|
||||
if (fp == NULL) {
|
||||
USER_LOG_ERROR("fp is null.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = fscanf(fp, "%u", &pid);
|
||||
if (ret <= 0) {
|
||||
USER_LOG_ERROR("get pid error.");
|
||||
pid = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
pclose(fp);
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
static uint32_t DjiTest_KillVoicePlayProcess(uint32_t pid)
|
||||
{
|
||||
FILE *fp;
|
||||
char cmdStr[128];
|
||||
|
||||
snprintf(cmdStr, 128, "kill %d", pid);
|
||||
fp = popen(cmdStr, "r");
|
||||
if (fp == NULL) {
|
||||
USER_LOG_ERROR("fp is null.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
pclose(fp);
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiTest_DecodeAudioData(void)
|
||||
{
|
||||
#ifdef OPUS_INSTALLED
|
||||
FILE *fin;
|
||||
FILE *fout;
|
||||
OpusDecoder *decoder;
|
||||
opus_int16 out[WIDGET_SPEAKER_AUDIO_OPUS_MAX_FRAME_SIZE * WIDGET_SPEAKER_AUDIO_OPUS_CHANNELS];
|
||||
uint8_t cbits[WIDGET_SPEAKER_AUDIO_OPUS_MAX_PACKET_SIZE];
|
||||
int32_t nbBytes;
|
||||
int32_t err;
|
||||
|
||||
/*! Attention: you can use "ffmpeg -i xxx.mp3 -ar 16000 -ac 1 out.wav" and use opus-tools to generate opus file for test */
|
||||
fin = fopen(WIDGET_SPEAKER_AUDIO_OPUS_FILE_NAME, "r");
|
||||
if (fin == NULL) {
|
||||
fprintf(stderr, "failed to open input file: %s\n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Create a new decoder state. */
|
||||
decoder = opus_decoder_create(WIDGET_SPEAKER_AUDIO_OPUS_SAMPLE_RATE, WIDGET_SPEAKER_AUDIO_OPUS_CHANNELS, &err);
|
||||
if (err < 0) {
|
||||
fprintf(stderr, "failed to create decoder: %s\n", opus_strerror(err));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
fout = fopen(WIDGET_SPEAKER_AUDIO_PCM_FILE_NAME, "w");
|
||||
if (fout == NULL) {
|
||||
fprintf(stderr, "failed to open output file: %s\n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Decode Start...");
|
||||
|
||||
while (1) {
|
||||
int i;
|
||||
unsigned char pcm_bytes[WIDGET_SPEAKER_AUDIO_OPUS_MAX_FRAME_SIZE * WIDGET_SPEAKER_AUDIO_OPUS_CHANNELS * 2];
|
||||
int frame_size;
|
||||
|
||||
/* Read a 16 bits/sample audio frame. */
|
||||
nbBytes = fread(cbits, 1, WIDGET_SPEAKER_AUDIO_OPUS_DECODE_FRAME_SIZE, fin);
|
||||
if (feof(fin))
|
||||
break;
|
||||
|
||||
/* Decode the data. In this example, frame_size will be constant because
|
||||
the encoder is using a constant frame size. However, that may not
|
||||
be the case for all encoders, so the decoder must always check
|
||||
the frame size returned. */
|
||||
frame_size = opus_decode(decoder, cbits, nbBytes, out, WIDGET_SPEAKER_AUDIO_OPUS_MAX_FRAME_SIZE, 0);
|
||||
if (frame_size < 0) {
|
||||
fprintf(stderr, "decoder failed: %s\n", opus_strerror(frame_size));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
USER_LOG_DEBUG("decode data to file: %d\r\n", frame_size * WIDGET_SPEAKER_AUDIO_OPUS_CHANNELS);
|
||||
/* Convert to little-endian ordering. */
|
||||
for (i = 0; i < WIDGET_SPEAKER_AUDIO_OPUS_CHANNELS * frame_size; i++) {
|
||||
pcm_bytes[2 * i] = out[i] & 0xFF;
|
||||
pcm_bytes[2 * i + 1] = (out[i] >> 8) & 0xFF;
|
||||
}
|
||||
/* Write the decoded audio to file. */
|
||||
fwrite(pcm_bytes, sizeof(short), frame_size * WIDGET_SPEAKER_AUDIO_OPUS_CHANNELS, fout);
|
||||
}
|
||||
|
||||
/*Destroy the encoder state*/
|
||||
opus_decoder_destroy(decoder);
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
|
||||
USER_LOG_INFO("Decode Finished...");
|
||||
|
||||
#endif
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiTest_PlayAudioData(void)
|
||||
{
|
||||
char cmdStr[128];
|
||||
|
||||
memset(cmdStr, 0, sizeof(cmdStr));
|
||||
|
||||
snprintf(cmdStr, sizeof(cmdStr), "ffplay -nodisp -autoexit -ar 16000 -ac 1 -f s16le -i %s 2>/dev/null",
|
||||
WIDGET_SPEAKER_AUDIO_PCM_FILE_NAME);
|
||||
|
||||
return DjiUserUtil_RunSystemCmd(cmdStr);
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiTest_PlayTtsData(void)
|
||||
{
|
||||
FILE *txtFile;
|
||||
uint8_t data[WIDGET_SPEAKER_TTS_FILE_MAX_SIZE] = {0};
|
||||
int32_t readLen;
|
||||
char cmdStr[WIDGET_SPEAKER_TTS_FILE_MAX_SIZE + 128];
|
||||
|
||||
txtFile = fopen(WIDGET_SPEAKER_TTS_FILE_NAME, "r");
|
||||
if (txtFile == NULL) {
|
||||
fprintf(stderr, "failed to open input file: %s\n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
readLen = fread(data, 1, WIDGET_SPEAKER_TTS_FILE_MAX_SIZE, txtFile);
|
||||
if (readLen <= 0) {
|
||||
USER_LOG_ERROR("Read tts file failed, error code: %d", readLen);
|
||||
fclose(txtFile);
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_NOT_FOUND;
|
||||
}
|
||||
|
||||
fclose(txtFile);
|
||||
|
||||
USER_LOG_INFO("Read tts file success, len: %d", readLen);
|
||||
USER_LOG_INFO("Content: %s", data);
|
||||
|
||||
memset(cmdStr, 0, sizeof(cmdStr));
|
||||
|
||||
/*! Attention: you can use other tts opensource function to convert txt to speech, example used ekho v7.5 */
|
||||
snprintf(cmdStr, sizeof(cmdStr), " ekho %s -s 20 -p 20 -a 100", data);
|
||||
|
||||
return DjiUserUtil_RunSystemCmd(cmdStr);
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiTest_CheckFileMd5Sum(const char *path, uint8_t *buf, uint16_t size)
|
||||
{
|
||||
MD5_CTX md5Ctx;
|
||||
uint32_t readFileTotalSize = 0;
|
||||
uint16_t readLen;
|
||||
T_DjiReturnCode returnCode;
|
||||
uint8_t readBuf[1024];
|
||||
uint8_t md5Sum[16];
|
||||
FILE *file = NULL;;
|
||||
|
||||
UtilMd5_Init(&md5Ctx);
|
||||
|
||||
file = fopen(path, "rb");
|
||||
if (file == NULL) {
|
||||
USER_LOG_ERROR("Open tts file error.");
|
||||
}
|
||||
|
||||
while (1) {
|
||||
returnCode = fseek(file, readFileTotalSize, SEEK_SET);
|
||||
if (returnCode != 0) {
|
||||
USER_LOG_INFO("fseek file error");
|
||||
}
|
||||
|
||||
readLen = fread(readBuf, 1, sizeof(readBuf), file);
|
||||
if (readLen > 0) {
|
||||
readFileTotalSize += readLen;
|
||||
UtilMd5_Update(&md5Ctx, readBuf, readLen);
|
||||
}
|
||||
|
||||
if (feof(file))
|
||||
break;
|
||||
}
|
||||
|
||||
UtilMd5_Final(&md5Ctx, md5Sum);
|
||||
fclose(file);
|
||||
|
||||
if (size == sizeof(md5Sum)) {
|
||||
if (memcmp(md5Sum, buf, sizeof(md5Sum)) == 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
} else {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
} else {
|
||||
USER_LOG_ERROR("MD5 sum length error");
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode GetSpeakerState(T_DjiWidgetSpeakerState *speakerState)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
returnCode = osalHandler->MutexLock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("lock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
*speakerState = s_speakerState;
|
||||
|
||||
returnCode = osalHandler->MutexUnlock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("unlock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode SetWorkMode(E_DjiWidgetSpeakerWorkMode workMode)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
returnCode = osalHandler->MutexLock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("lock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Set widget speaker work mode: %d", workMode);
|
||||
s_speakerState.workMode = workMode;
|
||||
|
||||
returnCode = osalHandler->MutexUnlock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("unlock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode GetWorkMode(E_DjiWidgetSpeakerWorkMode *workMode)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
returnCode = osalHandler->MutexLock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("lock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
*workMode = s_speakerState.workMode;
|
||||
|
||||
returnCode = osalHandler->MutexUnlock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("unlock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode SetPlayMode(E_DjiWidgetSpeakerPlayMode playMode)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
returnCode = osalHandler->MutexLock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("lock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Set widget speaker play mode: %d", playMode);
|
||||
s_speakerState.playMode = playMode;
|
||||
|
||||
returnCode = osalHandler->MutexUnlock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("unlock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode GetPlayMode(E_DjiWidgetSpeakerPlayMode *playMode)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
returnCode = osalHandler->MutexLock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("lock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
*playMode = s_speakerState.playMode;
|
||||
|
||||
returnCode = osalHandler->MutexUnlock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("unlock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode StartPlay(void)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
returnCode = osalHandler->MutexLock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("lock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Start widget speaker play");
|
||||
s_speakerState.state = DJI_WIDGET_SPEAKER_STATE_PLAYING;
|
||||
|
||||
returnCode = osalHandler->MutexUnlock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("unlock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode StopPlay(void)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
uint32_t pid;
|
||||
|
||||
returnCode = osalHandler->MutexLock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("lock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Stop widget speaker play");
|
||||
s_speakerState.state = DJI_WIDGET_SPEAKER_STATE_IDEL;
|
||||
|
||||
pid = DjiTest_GetVoicePlayProcessId();
|
||||
if (pid != 0) {
|
||||
DjiTest_KillVoicePlayProcess(pid);
|
||||
}
|
||||
|
||||
returnCode = osalHandler->MutexUnlock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("unlock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode SetVolume(uint8_t volume)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
char cmdStr[128];
|
||||
int32_t ret = 0;
|
||||
float realVolume;
|
||||
|
||||
returnCode = osalHandler->MutexLock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("lock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
realVolume = 1.5f * (float) volume;
|
||||
USER_LOG_INFO("Set widget speaker volume: %d", volume);
|
||||
s_speakerState.volume = volume;
|
||||
|
||||
memset(cmdStr, 0, sizeof(cmdStr));
|
||||
snprintf(cmdStr, sizeof(cmdStr), "pactl set-sink-volume %s %d%%", WIDGET_SPEAKER_USB_AUDIO_DEVICE_NAME,
|
||||
(int32_t) realVolume);
|
||||
|
||||
returnCode = DjiUserUtil_RunSystemCmd(cmdStr);
|
||||
if (returnCode < 0) {
|
||||
USER_LOG_ERROR("Set widget speaker volume error: %d", ret);
|
||||
}
|
||||
|
||||
returnCode = osalHandler->MutexUnlock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("unlock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode GetVolume(uint8_t *volume)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
returnCode = osalHandler->MutexLock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("lock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
*volume = s_speakerState.volume;
|
||||
|
||||
returnCode = osalHandler->MutexUnlock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("unlock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode ReceiveTtsData(E_DjiWidgetTransmitDataEvent event,
|
||||
uint32_t offset, uint8_t *buf, uint16_t size)
|
||||
{
|
||||
uint16_t writeLen;
|
||||
T_DjiReturnCode returnCode;
|
||||
|
||||
if (event == DJI_WIDGET_TRANSMIT_DATA_EVENT_START) {
|
||||
USER_LOG_INFO("Create tts file.");
|
||||
ttsFile = fopen(WIDGET_SPEAKER_TTS_FILE_NAME, "wb");
|
||||
if (ttsFile == NULL) {
|
||||
USER_LOG_ERROR("Open tts file error.");
|
||||
}
|
||||
} else if (event == DJI_WIDGET_TRANSMIT_DATA_EVENT_TRANSMIT) {
|
||||
USER_LOG_INFO("Transmit tts file, offset: %d, size: %d", offset, size);
|
||||
if (ttsFile != NULL) {
|
||||
fseek(ttsFile, offset, SEEK_SET);
|
||||
writeLen = fwrite(buf, 1, size, ttsFile);
|
||||
if (writeLen != size) {
|
||||
USER_LOG_ERROR("Write tts file error %d", writeLen);
|
||||
}
|
||||
}
|
||||
} else if (event == DJI_WIDGET_TRANSMIT_DATA_EVENT_FINISH) {
|
||||
USER_LOG_INFO("Close tts file.");
|
||||
if (ttsFile != NULL) {
|
||||
fclose(ttsFile);
|
||||
}
|
||||
|
||||
returnCode = DjiTest_CheckFileMd5Sum(WIDGET_SPEAKER_TTS_FILE_NAME, buf, size);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("File md5 sum check failed");
|
||||
}
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode ReceiveAudioData(E_DjiWidgetTransmitDataEvent event,
|
||||
uint32_t offset, uint8_t *buf, uint16_t size)
|
||||
{
|
||||
uint16_t writeLen;
|
||||
T_DjiReturnCode returnCode;
|
||||
|
||||
if (event == DJI_WIDGET_TRANSMIT_DATA_EVENT_START) {
|
||||
USER_LOG_INFO("Create voice file.");
|
||||
audioFile = fopen(WIDGET_SPEAKER_AUDIO_OPUS_FILE_NAME, "wb");
|
||||
if (audioFile == NULL) {
|
||||
USER_LOG_ERROR("Create tts file error.");
|
||||
}
|
||||
} else if (event == DJI_WIDGET_TRANSMIT_DATA_EVENT_TRANSMIT) {
|
||||
USER_LOG_INFO("Transmit voice file, offset: %d, size: %d", offset, size);
|
||||
if (audioFile != NULL) {
|
||||
fseek(audioFile, offset, SEEK_SET);
|
||||
writeLen = fwrite(buf, 1, size, audioFile);
|
||||
if (writeLen != size) {
|
||||
USER_LOG_ERROR("Write tts file error %d", writeLen);
|
||||
}
|
||||
}
|
||||
} else if (event == DJI_WIDGET_TRANSMIT_DATA_EVENT_FINISH) {
|
||||
USER_LOG_INFO("Close voice file.");
|
||||
if (audioFile != NULL) {
|
||||
fclose(audioFile);
|
||||
}
|
||||
|
||||
returnCode = DjiTest_CheckFileMd5Sum(WIDGET_SPEAKER_AUDIO_OPUS_FILE_NAME, buf, size);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("File md5 sum check failed");
|
||||
}
|
||||
|
||||
DjiTest_DecodeAudioData();
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
#ifndef __CC_ARM
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmissing-noreturn"
|
||||
#pragma GCC diagnostic ignored "-Wreturn-type"
|
||||
#endif
|
||||
|
||||
static void *DjiTest_WidgetSpeakerTask(void *arg)
|
||||
{
|
||||
T_DjiReturnCode djiReturnCode;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
USER_UTIL_UNUSED(arg);
|
||||
|
||||
while (1) {
|
||||
osalHandler->TaskSleepMs(10);
|
||||
|
||||
if (s_speakerState.state == DJI_WIDGET_SPEAKER_STATE_PLAYING) {
|
||||
if (s_speakerState.playMode == DJI_WIDGET_SPEAKER_PLAY_MODE_LOOP_PLAYBACK) {
|
||||
if (s_speakerState.workMode == DJI_WIDGET_SPEAKER_WORK_MODE_VOICE) {
|
||||
djiReturnCode = DjiTest_PlayAudioData();
|
||||
if (djiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Play audio data failed, error: 0x%08llX.", djiReturnCode);
|
||||
}
|
||||
} else {
|
||||
djiReturnCode = DjiTest_PlayTtsData();
|
||||
if (djiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Play tts data failed, error: 0x%08llX.", djiReturnCode);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (s_speakerState.workMode == DJI_WIDGET_SPEAKER_WORK_MODE_VOICE) {
|
||||
djiReturnCode = DjiTest_PlayAudioData();
|
||||
if (djiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Play audio data failed, error: 0x%08llX.", djiReturnCode);
|
||||
}
|
||||
} else {
|
||||
djiReturnCode = DjiTest_PlayTtsData();
|
||||
if (djiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Play tts data failed, error: 0x%08llX.", djiReturnCode);
|
||||
}
|
||||
}
|
||||
|
||||
djiReturnCode = osalHandler->MutexLock(s_speakerMutex);
|
||||
if (djiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("lock mutex error: 0x%08llX.", djiReturnCode);
|
||||
}
|
||||
|
||||
s_speakerState.state = DJI_WIDGET_SPEAKER_STATE_IDEL;
|
||||
|
||||
djiReturnCode = osalHandler->MutexUnlock(s_speakerMutex);
|
||||
if (djiReturnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("unlock mutex error: 0x%08llX.", djiReturnCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __CC_ARM
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
53
samples/sample_c/module_sample/widget/test_widget_speaker.h
Normal file
53
samples/sample_c/module_sample/widget/test_widget_speaker.h
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file test_widget_speaker.h
|
||||
* @brief This is the header file for "test_widget_speaker.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 TEST_WIDGET_SPEAKER_H
|
||||
#define TEST_WIDGET_SPEAKER_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_widget.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
T_DjiReturnCode DjiTest_WidgetSpeakerStartService(void);
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_WIDGET_SPEAKER_H
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
@ -7,6 +7,10 @@
|
||||
"floating_window": {
|
||||
"is_enable": true
|
||||
},
|
||||
"speaker": {
|
||||
"is_enable_tts": true,
|
||||
"is_enable_voice": true
|
||||
},
|
||||
"widget_list": [
|
||||
{
|
||||
"widget_index": 0,
|
||||
|
@ -7,6 +7,10 @@
|
||||
"floating_window": {
|
||||
"is_enable": true
|
||||
},
|
||||
"speaker": {
|
||||
"is_enable_tts": true,
|
||||
"is_enable_voice": true
|
||||
},
|
||||
"widget_list": [
|
||||
{
|
||||
"widget_index": 0,
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "dji_aircraft_info.h"
|
||||
#include "dji_core.h"
|
||||
#include <payload_collaboration/test_payload_collaboration.h>
|
||||
#include <waypoint_v3/test_waypoint_v3.h>
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define WIDGET_DIR_PATH_LEN_MAX (256)
|
||||
@ -55,18 +56,19 @@
|
||||
typedef enum {
|
||||
E_DJI_SAMPLE_INDEX_FC_SUBSCRIPTION = 0,
|
||||
E_DJI_SAMPLE_INDEX_WAYPOINT_V2 = 1,
|
||||
E_DJI_SAMPLE_INDEX_FLIGHT_CONTROL_TAKE_OFF_LANDING = 2,
|
||||
E_DJI_SAMPLE_INDEX_FLIGHT_CONTROL_TAKE_OFF_POSITION_CTRL_LANDING = 3,
|
||||
E_DJI_SAMPLE_INDEX_FLIGHT_CONTROL_TAKE_OFF_GO_HOME_FORCE_LANDING = 4,
|
||||
E_DJI_SAMPLE_INDEX_FLIGHT_CONTROL_TAKE_OFF_VELOCITY_CTRL_LANDING = 5,
|
||||
E_DJI_SAMPLE_INDEX_FLIGHT_CONTROL_ARREST_FLYING = 6,
|
||||
E_DJI_SAMPLE_INDEX_FLIGHT_CONTROL_SET_GET_PARAM = 7,
|
||||
E_DJI_SAMPLE_INDEX_HMS = 8,
|
||||
E_DJI_SAMPLE_INDEX_CAMERA_MANAGER = 9,
|
||||
E_DJI_SAMPLE_INDEX_GIMBAL_MANAGER_FREE_MODE = 10,
|
||||
E_DJI_SAMPLE_INDEX_GIMBAL_MANAGER_YAW_FOLLOW_MODE = 11,
|
||||
E_DJI_SAMPLE_INDEX_LIVEVIEW = 12,
|
||||
E_DJI_SAMPLE_INDEX_PERCEPTION = 13,
|
||||
E_DJI_SAMPLE_INDEX_WAYPOINT_V3 = 2,
|
||||
E_DJI_SAMPLE_INDEX_FLIGHT_CONTROL_TAKE_OFF_LANDING = 3,
|
||||
E_DJI_SAMPLE_INDEX_FLIGHT_CONTROL_TAKE_OFF_POSITION_CTRL_LANDING = 4,
|
||||
E_DJI_SAMPLE_INDEX_FLIGHT_CONTROL_TAKE_OFF_GO_HOME_FORCE_LANDING = 5,
|
||||
E_DJI_SAMPLE_INDEX_FLIGHT_CONTROL_TAKE_OFF_VELOCITY_CTRL_LANDING = 6,
|
||||
E_DJI_SAMPLE_INDEX_FLIGHT_CONTROL_ARREST_FLYING = 7,
|
||||
E_DJI_SAMPLE_INDEX_FLIGHT_CONTROL_SET_GET_PARAM = 8,
|
||||
E_DJI_SAMPLE_INDEX_HMS = 9,
|
||||
E_DJI_SAMPLE_INDEX_CAMERA_MANAGER = 10,
|
||||
E_DJI_SAMPLE_INDEX_GIMBAL_MANAGER_FREE_MODE = 11,
|
||||
E_DJI_SAMPLE_INDEX_GIMBAL_MANAGER_YAW_FOLLOW_MODE = 12,
|
||||
E_DJI_SAMPLE_INDEX_LIVEVIEW = 13,
|
||||
E_DJI_SAMPLE_INDEX_PERCEPTION = 14,
|
||||
E_DJI_SAMPLE_INDEX_UNKNOWN = 0xFF,
|
||||
} E_DjiExtensionPortSampleIndex;
|
||||
|
||||
@ -338,6 +340,14 @@ static void *DjiTest_WidgetInteractionTask(void *arg)
|
||||
USER_LOG_WARN("Please turn on the 'unlock flight control restrictions' switch.");
|
||||
}
|
||||
break;
|
||||
case E_DJI_SAMPLE_INDEX_WAYPOINT_V3:
|
||||
if (s_isallowRunFlightControlSample == true) {
|
||||
DjiTest_WaypointV3RunSample();
|
||||
} else {
|
||||
DjiTest_WidgetLogAppend("Please turn on the 'unlock flight control restrictions'");
|
||||
USER_LOG_WARN("Please turn on the 'unlock flight control restrictions' switch.");
|
||||
}
|
||||
break;
|
||||
case E_DJI_SAMPLE_INDEX_FLIGHT_CONTROL_TAKE_OFF_LANDING:
|
||||
if (s_isallowRunFlightControlSample == true) {
|
||||
DjiTest_FlightControlRunSample(E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_TAKE_OFF_LANDING);
|
||||
|
@ -243,6 +243,9 @@
|
||||
{
|
||||
"item_name": "waypoint_v2"
|
||||
},
|
||||
{
|
||||
"item_name": "waypoint_v3"
|
||||
},
|
||||
{
|
||||
"item_name": "flight_ctrl_takeoff_landing"
|
||||
},
|
||||
|
@ -245,6 +245,9 @@
|
||||
{
|
||||
"item_name": "waypoint_v2"
|
||||
},
|
||||
{
|
||||
"item_name": "waypoint_v3"
|
||||
},
|
||||
{
|
||||
"item_name": "flight_ctrl_takeoff_landing"
|
||||
},
|
||||
|
@ -271,7 +271,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(&(st.st_mtim));
|
||||
if (fileTm == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
@ -279,7 +279,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;
|
||||
|
@ -124,7 +124,7 @@ T_DjiReturnCode Osal_UdpSendData(T_DjiSocketHandle socketHandle, const char *ipA
|
||||
addr.sin_port = htons(port);
|
||||
addr.sin_addr.s_addr = inet_addr(ipAddr);
|
||||
|
||||
ret = sendto(socketHandleStruct->socketFd, buf, len, MSG_DONTWAIT, (struct sockaddr *) &addr, sizeof(struct sockaddr_in));
|
||||
ret = sendto(socketHandleStruct->socketFd, buf, len, 0, (struct sockaddr *) &addr, sizeof(struct sockaddr_in));
|
||||
if (ret >= 0) {
|
||||
*realLen = ret;
|
||||
} else {
|
||||
|
@ -95,7 +95,7 @@ out:
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiUpgradePlatformLinux_GetUpgradeRebootState(bool *isUpgradeReboot,
|
||||
T_DjiUpgradeEndInfo *upgradeEndInfo)
|
||||
T_DjiUpgradeEndInfo *upgradeEndInfo)
|
||||
{
|
||||
FILE *rebootStateFile;
|
||||
size_t res;
|
||||
@ -162,7 +162,7 @@ DjiUpgradePlatformLinux_WriteUpgradeProgramFile(uint32_t offset, const uint8_t *
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiUpgradePlatformLinux_ReadUpgradeProgramFile(uint32_t offset, uint16_t readDataLen, uint8_t *data,
|
||||
uint16_t *realLen)
|
||||
uint16_t *realLen)
|
||||
{
|
||||
uint32_t readRtn;
|
||||
|
||||
|
@ -38,7 +38,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define DJI_TEST_UPGRADE_OLD_FIRMWARE_PATH "/usr/local/bin/dji_sdk_demo"
|
||||
#define DJI_TEST_UPGRADE_OLD_FIRMWARE_PATH "/usr/local/bin/dji_sdk_demo_linux"
|
||||
#define DJI_TEST_UPGRADE_FILE_DIR "/upgrade/"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
@ -48,12 +48,14 @@ extern "C" {
|
||||
|
||||
#define CONFIG_MODULE_SAMPLE_WIDGET_ON
|
||||
|
||||
#define CONFIG_MODULE_SAMPLE_WIDGET_SPEAKER_ON
|
||||
|
||||
#define CONFIG_MODULE_SAMPLE_DATA_TRANSMISSION_ON
|
||||
|
||||
#define CONFIG_MODULE_SAMPLE_PAYLOAD_COLLABORATION_ON
|
||||
|
||||
#define CONFIG_MODULE_SAMPLE_UPGRADE_ON
|
||||
|
||||
#define CONFIG_MODULE_SAMPLE_PAYLOAD_COLLABORATION_ON
|
||||
|
||||
/*!< Attention: This function needs to be used together with mobile sdk mop sample.
|
||||
* */
|
||||
//#define CONFIG_MODULE_SAMPLE_MOP_CHANNEL_ON
|
||||
|
@ -30,25 +30,26 @@
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <power_management/test_power_management.h>
|
||||
#include <upgrade/test_upgrade.h>
|
||||
#include <payload_collaboration/test_payload_collaboration.h>
|
||||
#include <mop_channel/test_mop_channel.h>
|
||||
#include <xport/test_payload_xport.h>
|
||||
#include <gimbal_emu/test_payload_gimbal_emu.h>
|
||||
#include <fc_subscription/test_fc_subscription.h>
|
||||
#include <camera_emu/test_payload_cam_emu_media.h>
|
||||
#include <camera_emu/test_payload_cam_emu_base.h>
|
||||
#include <upgrade/test_upgrade.h>
|
||||
#include <upgrade_platform_opt/upgrade_platform_opt_linux.h>
|
||||
#include <mop_channel/test_mop_channel.h>
|
||||
#include <payload_collaboration/test_payload_collaboration.h>
|
||||
#include <xport/test_payload_xport.h>
|
||||
#include "monitor/sys_monitor.h"
|
||||
#include "osal/osal.h"
|
||||
#include "osal/osal_fs.h"
|
||||
#include "osal/osal_socket.h"
|
||||
#include "upgrade_platform_opt/upgrade_platform_opt_linux.h"
|
||||
#include "../hal/hal_uart.h"
|
||||
#include "../hal/hal_network.h"
|
||||
#include "../hal/hal_usb_bulk.h"
|
||||
#include "dji_sdk_app_info.h"
|
||||
#include "dji_aircraft_info.h"
|
||||
#include "widget/test_widget.h"
|
||||
#include "widget/test_widget_speaker.h"
|
||||
#include "widget_interaction_test/test_widget_interaction.h"
|
||||
#include "data_transmission/test_data_transmission.h"
|
||||
#include "dji_sdk_config.h"
|
||||
@ -59,9 +60,8 @@
|
||||
#define DJI_LOG_FOLDER_NAME "Logs"
|
||||
#define DJI_LOG_PATH_MAX_SIZE (128)
|
||||
#define DJI_LOG_FOLDER_NAME_MAX_SIZE (32)
|
||||
#define DJI_LOG_SYSTEM_CMD_MAX_SIZE (64)
|
||||
#define DJI_LOG_MAX_COUNT (10)
|
||||
#define DJI_SYSTEM_CMD_STR_MAX_SIZE (64)
|
||||
#define DJI_SYSTEM_RESULT_STR_MAX_SIZE (128)
|
||||
|
||||
#define DJI_USE_WIDGET_INTERACTION 0
|
||||
|
||||
@ -78,6 +78,7 @@ static FILE *s_djiLogFileCnt;
|
||||
static pthread_t s_monitorThread = 0;
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
static T_DjiReturnCode DjiUser_PrepareSystemEnvironment(void);
|
||||
static T_DjiReturnCode DjiUser_FillInUserInfo(T_DjiUserInfo *userInfo);
|
||||
static T_DjiReturnCode DjiUser_PrintConsole(const uint8_t *data, uint16_t dataLen);
|
||||
static T_DjiReturnCode DjiUser_LocalWrite(const uint8_t *data, uint16_t dataLen);
|
||||
@ -85,7 +86,6 @@ static T_DjiReturnCode DjiUser_LocalWriteFsInit(const char *path);
|
||||
static void *DjiUser_MonitorTask(void *argument);
|
||||
static T_DjiReturnCode DjiTest_HighPowerApplyPinInit();
|
||||
static T_DjiReturnCode DjiTest_WriteHighPowerApplyPin(E_DjiPowerManagementPinState pinState);
|
||||
static bool DjiUser_CheckNetCableConnectStatus(void);
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
int main(int argc, char **argv)
|
||||
@ -93,7 +93,204 @@ int main(int argc, char **argv)
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiUserInfo userInfo;
|
||||
T_DjiAircraftInfoBaseInfo aircraftInfoBaseInfo;
|
||||
DjiTestDataTransmissionConfig dataTransmissionConfig;
|
||||
|
||||
USER_UTIL_UNUSED(argc);
|
||||
USER_UTIL_UNUSED(argv);
|
||||
|
||||
/*!< Step 1: Prepare system environment, such as osal, hal uart, console function and so on. */
|
||||
returnCode = DjiUser_PrepareSystemEnvironment();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Prepare system environment error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
/*!< Step 2: Fill your application information in dji_sdk_app_info.h and use this interface to fill it. */
|
||||
returnCode = DjiUser_FillInUserInfo(&userInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Fill user info error, please check user info config");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
/*!< Step 3: Initialize the Payload SDK core by your application information. */
|
||||
returnCode = DjiCore_Init(&userInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Core init error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
returnCode = DjiAircraftInfo_GetBaseInfo(&aircraftInfoBaseInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("get aircraft base info error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
returnCode = DjiCore_SetAlias("PSDK_APPALIAS");
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("set alias error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
/*!< Step 4: Initialize the selected modules by macros in dji_sdk_config.h . */
|
||||
#ifdef CONFIG_MODULE_SAMPLE_POWER_MANAGEMENT_ON
|
||||
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");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_DATA_TRANSMISSION_ON
|
||||
returnCode = DjiTest_DataTransmissionStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget sample init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_EXTENSION_PORT &&
|
||||
aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M300_RTK) {
|
||||
returnCode = DjiTest_WidgetInteractionStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget interaction sample init error");
|
||||
}
|
||||
} else {
|
||||
#ifdef CONFIG_MODULE_SAMPLE_CAMERA_EMU_ON
|
||||
returnCode = DjiTest_CameraEmuBaseStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("camera emu common init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_CAMERA_MEDIA_ON
|
||||
returnCode = DjiTest_CameraEmuMediaStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("camera emu media init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_FC_SUBSCRIPTION_ON
|
||||
returnCode = DjiTest_FcSubscriptionStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("data subscription sample init error\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_GIMBAL_ON
|
||||
if (aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V2 ||
|
||||
aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_NONE) {
|
||||
if (DjiTest_GimbalStartService() != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("psdk gimbal init error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_XPORT_ON
|
||||
if (aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_XPORT) {
|
||||
if (DjiTest_XPortStartService() != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("psdk xport init error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_WIDGET_ON
|
||||
#if DJI_USE_WIDGET_INTERACTION
|
||||
returnCode = DjiTest_WidgetInteractionStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget interaction test init error");
|
||||
}
|
||||
#else
|
||||
returnCode = DjiTest_WidgetStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget sample init error");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_WIDGET_SPEAKER_ON
|
||||
if (aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_NONE) {
|
||||
returnCode = DjiTest_WidgetSpeakerStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget speaker test init error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_MOP_CHANNEL_ON
|
||||
if (aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V2 ||
|
||||
aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_XPORT) {
|
||||
returnCode = DjiTest_MopChannelStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("mop channel sample init error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_PAYLOAD_COLLABORATION_ON
|
||||
if (aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V2 ||
|
||||
aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_XPORT) {
|
||||
returnCode = DjiTest_PayloadCollaborationStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Payload collaboration sample init error\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_UPGRADE_ON
|
||||
T_DjiTestUpgradePlatformOpt linuxUpgradePlatformOpt = {
|
||||
.rebootSystem = DjiUpgradePlatformLinux_RebootSystem,
|
||||
.cleanUpgradeProgramFileStoreArea = DjiUpgradePlatformLinux_CleanUpgradeProgramFileStoreArea,
|
||||
.createUpgradeProgramFile = DjiUpgradePlatformLinux_CreateUpgradeProgramFile,
|
||||
.writeUpgradeProgramFile = DjiUpgradePlatformLinux_WriteUpgradeProgramFile,
|
||||
.readUpgradeProgramFile = DjiUpgradePlatformLinux_ReadUpgradeProgramFile,
|
||||
.closeUpgradeProgramFile = DjiUpgradePlatformLinux_CloseUpgradeProgramFile,
|
||||
.replaceOldProgram = DjiUpgradePlatformLinux_ReplaceOldProgram,
|
||||
.setUpgradeRebootState = DjiUpgradePlatformLinux_SetUpgradeRebootState,
|
||||
.getUpgradeRebootState = DjiUpgradePlatformLinux_GetUpgradeRebootState,
|
||||
.cleanUpgradeRebootState = DjiUpgradePlatformLinux_CleanUpgradeRebootState,
|
||||
};
|
||||
T_DjiTestUpgradeConfig testUpgradeConfig = {
|
||||
.firmwareVersion = {1, 0, 0, 0},
|
||||
.transferType = DJI_FIRMWARE_TRANSFER_TYPE_DCFTP,
|
||||
.needReplaceProgramBeforeReboot = true
|
||||
};
|
||||
if (DjiTest_UpgradeStartService(&linuxUpgradePlatformOpt, testUpgradeConfig) !=
|
||||
DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("psdk upgrade init error");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!< Step 5: Tell the DJI Pilot you are ready. */
|
||||
returnCode = DjiCore_ApplicationStart();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("start sdk application error");
|
||||
}
|
||||
|
||||
if (pthread_create(&s_monitorThread, NULL, DjiUser_MonitorTask, NULL) != 0) {
|
||||
USER_LOG_ERROR("create monitor task fail.");
|
||||
}
|
||||
|
||||
if (pthread_setname_np(s_monitorThread, "monitor task") != 0) {
|
||||
USER_LOG_ERROR("set name for monitor task fail.");
|
||||
}
|
||||
|
||||
while (1) {
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
static T_DjiReturnCode DjiUser_PrepareSystemEnvironment(void)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler osalHandler = {
|
||||
.TaskCreate = Osal_TaskCreate,
|
||||
.TaskDestroy = Osal_TaskDestroy,
|
||||
@ -112,6 +309,7 @@ int main(int argc, char **argv)
|
||||
.GetTimeMs = Osal_GetTimeMs,
|
||||
.GetTimeUs = Osal_GetTimeUs,
|
||||
};
|
||||
|
||||
T_DjiLoggerConsole printConsole = {
|
||||
.func = DjiUser_PrintConsole,
|
||||
.consoleLevel = DJI_LOGGER_CONSOLE_LOG_LEVEL_INFO,
|
||||
@ -121,7 +319,7 @@ int main(int argc, char **argv)
|
||||
T_DjiLoggerConsole localRecordConsole = {
|
||||
.consoleLevel = DJI_LOGGER_CONSOLE_LOG_LEVEL_DEBUG,
|
||||
.func = DjiUser_LocalWrite,
|
||||
.isSupportColor = false,
|
||||
.isSupportColor = true,
|
||||
};
|
||||
|
||||
T_DjiHalUartHandler uartHandler = {
|
||||
@ -227,211 +425,15 @@ int main(int argc, char **argv)
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
returnCode = DjiUser_FillInUserInfo(&userInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
osalHandler.TaskSleepMs(1000);
|
||||
USER_LOG_ERROR("fill user info error, please check user info config");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
returnCode = DjiCore_Init(&userInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("core init error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
returnCode = DjiAircraftInfo_GetBaseInfo(&aircraftInfoBaseInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("get aircraft base info error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
returnCode = DjiCore_SetAlias("PSDK_APPALIAS");
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("set alias error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
if (aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_EXTENSION_PORT) {
|
||||
dataTransmissionConfig.isEnableLowSpeedDataChannel = true;
|
||||
dataTransmissionConfig.isEnableHighSpeedDataChannel = false;
|
||||
|
||||
returnCode = DjiTest_DataTransmissionStartService(dataTransmissionConfig);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("data transmission init error");
|
||||
}
|
||||
|
||||
returnCode = DjiTest_WidgetInteractionStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget interaction sample init error");
|
||||
}
|
||||
} else {
|
||||
#ifdef CONFIG_MODULE_SAMPLE_POWER_MANAGEMENT_ON
|
||||
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");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_CAMERA_EMU_ON
|
||||
returnCode = DjiTest_CameraEmuBaseStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("camera emu common init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_CAMERA_MEDIA_ON
|
||||
if (DjiUser_CheckNetCableConnectStatus() == true) {
|
||||
returnCode = DjiTest_CameraEmuMediaStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("camera emu media init error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_FC_SUBSCRIPTION_ON
|
||||
returnCode = DjiTest_FcSubscriptionStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("data subscription sample init error\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_GIMBAL_ON
|
||||
if (aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V2 ||
|
||||
aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_NONE) {
|
||||
if (DjiTest_GimbalStartService() != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("psdk gimbal init error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_XPORT_ON
|
||||
if (aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_XPORT) {
|
||||
if (DjiTest_XPortStartService() != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("psdk xport init error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_WIDGET_ON
|
||||
#if DJI_USE_WIDGET_INTERACTION
|
||||
returnCode = DjiTest_WidgetInteractionStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget interaction test init error");
|
||||
}
|
||||
#else
|
||||
returnCode = DjiTest_WidgetStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget sample init error");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_DATA_TRANSMISSION_ON
|
||||
dataTransmissionConfig.isEnableLowSpeedDataChannel = true;
|
||||
dataTransmissionConfig.isEnableHighSpeedDataChannel = DjiUser_CheckNetCableConnectStatus();
|
||||
returnCode = DjiTest_DataTransmissionStartService(dataTransmissionConfig);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget sample init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_MOP_CHANNEL_ON
|
||||
returnCode = DjiTest_MopChannelStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("mop channel sample init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_PAYLOAD_COLLABORATION_ON
|
||||
returnCode = DjiTest_PayloadCollaborationStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Payload collaboration sample init error\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_UPGRADE_ON
|
||||
T_DjiTestUpgradePlatformOpt linuxUpgradePlatformOpt = {
|
||||
.rebootSystem = DjiUpgradePlatformLinux_RebootSystem,
|
||||
.cleanUpgradeProgramFileStoreArea = DjiUpgradePlatformLinux_CleanUpgradeProgramFileStoreArea,
|
||||
.createUpgradeProgramFile = DjiUpgradePlatformLinux_CreateUpgradeProgramFile,
|
||||
.writeUpgradeProgramFile = DjiUpgradePlatformLinux_WriteUpgradeProgramFile,
|
||||
.readUpgradeProgramFile = DjiUpgradePlatformLinux_ReadUpgradeProgramFile,
|
||||
.closeUpgradeProgramFile = DjiUpgradePlatformLinux_CloseUpgradeProgramFile,
|
||||
.replaceOldProgram = DjiUpgradePlatformLinux_ReplaceOldProgram,
|
||||
.setUpgradeRebootState = DjiUpgradePlatformLinux_SetUpgradeRebootState,
|
||||
.getUpgradeRebootState = DjiUpgradePlatformLinux_GetUpgradeRebootState,
|
||||
.cleanUpgradeRebootState = DjiUpgradePlatformLinux_CleanUpgradeRebootState,
|
||||
};
|
||||
T_DjiTestUpgradeConfig testUpgradeConfig = {
|
||||
.firmwareVersion = {1, 0, 0, 0},
|
||||
.transferType = DJI_FIRMWARE_TRANSFER_TYPE_FTP,
|
||||
.needReplaceProgramBeforeReboot = true
|
||||
};
|
||||
if (DjiTest_UpgradeStartService(&linuxUpgradePlatformOpt, testUpgradeConfig) !=
|
||||
DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("psdk upgrade init error");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
returnCode = DjiCore_ApplicationStart();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("start sdk application error");
|
||||
}
|
||||
|
||||
if (pthread_create(&s_monitorThread, NULL, DjiUser_MonitorTask, NULL) != 0) {
|
||||
USER_LOG_ERROR("create monitor task fail.");
|
||||
}
|
||||
|
||||
if (pthread_setname_np(s_monitorThread, "monitor task") != 0) {
|
||||
USER_LOG_ERROR("set name for monitor task fail.");
|
||||
}
|
||||
|
||||
while (1) {
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
static T_DjiReturnCode DjiUser_PrintConsole(const uint8_t *data, uint16_t dataLen)
|
||||
{
|
||||
USER_UTIL_UNUSED(dataLen);
|
||||
|
||||
printf("%s", data);
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiUser_LocalWrite(const uint8_t *data, uint16_t dataLen)
|
||||
{
|
||||
int32_t realLen;
|
||||
|
||||
if (s_djiLogFile == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
realLen = fwrite(data, 1, dataLen, s_djiLogFile);
|
||||
fflush(s_djiLogFile);
|
||||
if (realLen == dataLen) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
} else {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiUser_FillInUserInfo(T_DjiUserInfo *userInfo)
|
||||
{
|
||||
if (userInfo == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
memset(userInfo->appName, 0, sizeof(userInfo->appName));
|
||||
memset(userInfo->appId, 0, sizeof(userInfo->appId));
|
||||
memset(userInfo->appKey, 0, sizeof(userInfo->appKey));
|
||||
@ -446,6 +448,7 @@ static T_DjiReturnCode DjiUser_FillInUserInfo(T_DjiUserInfo *userInfo)
|
||||
strlen(USER_DEVELOPER_ACCOUNT) >= sizeof(userInfo->developerAccount) ||
|
||||
strlen(USER_BAUD_RATE) > sizeof(userInfo->baudRate)) {
|
||||
USER_LOG_ERROR("Length of user information string is beyond limit. Please check.");
|
||||
sleep(1);
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -457,6 +460,7 @@ static T_DjiReturnCode DjiUser_FillInUserInfo(T_DjiUserInfo *userInfo)
|
||||
!strcmp(USER_BAUD_RATE, "your_baud_rate")) {
|
||||
USER_LOG_ERROR(
|
||||
"Please fill in correct user information to 'samples/sample_c/platform/linux/manifold2/application/dji_sdk_app_info.h' file.");
|
||||
sleep(1);
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -471,11 +475,37 @@ static T_DjiReturnCode DjiUser_FillInUserInfo(T_DjiUserInfo *userInfo)
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiUser_PrintConsole(const uint8_t *data, uint16_t dataLen)
|
||||
{
|
||||
USER_UTIL_UNUSED(dataLen);
|
||||
|
||||
printf("%s", data);
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiUser_LocalWrite(const uint8_t *data, uint16_t dataLen)
|
||||
{
|
||||
uint32_t realLen;
|
||||
|
||||
if (s_djiLogFile == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
realLen = fwrite(data, 1, dataLen, s_djiLogFile);
|
||||
fflush(s_djiLogFile);
|
||||
if (realLen == dataLen) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
} else {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiUser_LocalWriteFsInit(const char *path)
|
||||
{
|
||||
T_DjiReturnCode djiReturnCode = DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
char filePath[DJI_LOG_PATH_MAX_SIZE];
|
||||
char systemCmd[DJI_SYSTEM_CMD_STR_MAX_SIZE];
|
||||
char systemCmd[DJI_LOG_SYSTEM_CMD_MAX_SIZE];
|
||||
char folderName[DJI_LOG_FOLDER_NAME_MAX_SIZE];
|
||||
time_t currentTime = time(NULL);
|
||||
struct tm *localTime = localtime(¤tTime);
|
||||
@ -621,25 +651,4 @@ static T_DjiReturnCode DjiTest_WriteHighPowerApplyPin(E_DjiPowerManagementPinSta
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
static bool DjiUser_CheckNetCableConnectStatus(void)
|
||||
{
|
||||
FILE *fp;
|
||||
char *ret = NULL;
|
||||
char systemCmd[DJI_SYSTEM_CMD_STR_MAX_SIZE] = {0};
|
||||
char lineBuf[DJI_SYSTEM_RESULT_STR_MAX_SIZE] = {0};
|
||||
|
||||
sprintf(systemCmd, "ifconfig %s | grep RUNNING", LINUX_NETWORK_DEV);
|
||||
fp = popen(systemCmd, "r");
|
||||
if (fp == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = fgets(lineBuf, sizeof(lineBuf), fp);
|
||||
if (ret == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
@ -55,7 +55,6 @@ extern "C" {
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
T_DjiReturnCode HalNetWork_Init(const char *ipAddr, const char *netMask, T_DjiNetworkHandle *halObj);
|
||||
|
||||
T_DjiReturnCode HalNetWork_DeInit(T_DjiNetworkHandle halObj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define UART_DEV_NAME_STR_SIZE (128)
|
||||
#define DJI_SYSTEM_CMD_STR_MAX_SIZE (64)
|
||||
#define DJI_SYSTEM_CMD_MAX_SIZE (64)
|
||||
#define DJI_SYSTEM_RESULT_STR_MAX_SIZE (128)
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
@ -48,7 +48,7 @@ T_DjiReturnCode HalUart_Init(E_DjiHalUartNum uartNum, uint32_t baudRate, T_DjiUa
|
||||
struct flock lock;
|
||||
T_DjiReturnCode returnCode = DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
char uartName[UART_DEV_NAME_STR_SIZE];
|
||||
char systemCmd[DJI_SYSTEM_CMD_STR_MAX_SIZE];
|
||||
char systemCmd[DJI_SYSTEM_CMD_MAX_SIZE];
|
||||
char *ret = NULL;
|
||||
char lineBuf[DJI_SYSTEM_RESULT_STR_MAX_SIZE] = {0};
|
||||
FILE *fp;
|
||||
|
@ -78,10 +78,6 @@ void DjiUser_StartTask(void const *argument)
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiUserInfo userInfo;
|
||||
T_DjiAircraftInfoBaseInfo aircraftInfoBaseInfo;
|
||||
DjiTestDataTransmissionConfig dataTransmissionConfig = {
|
||||
.isEnableHighSpeedDataChannel = false,
|
||||
.isEnableLowSpeedDataChannel = true,
|
||||
};
|
||||
T_DjiOsalHandler osalHandler = {
|
||||
.TaskCreate = Osal_TaskCreate,
|
||||
.TaskDestroy = Osal_TaskDestroy,
|
||||
@ -165,19 +161,6 @@ void DjiUser_StartTask(void const *argument)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_EXTENSION_PORT) {
|
||||
#if DJI_EXTENSION_PORT_SUPPORT
|
||||
returnCode = DjiTest_DataTransmissionStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("data transmission init error");
|
||||
}
|
||||
|
||||
returnCode = DjiTest_WidgetStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget sample init error");
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
#ifdef CONFIG_MODULE_SAMPLE_POWER_MANAGEMENT_ON
|
||||
T_DjiTestApplyHighPowerHandler applyHighPowerHandler = {
|
||||
.pinInit = DjiTest_HighPowerApplyPinInit,
|
||||
@ -218,7 +201,7 @@ void DjiUser_StartTask(void const *argument)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_DATA_TRANSMISSION_ON
|
||||
returnCode = DjiTest_DataTransmissionStartService(dataTransmissionConfig);
|
||||
returnCode = DjiTest_DataTransmissionStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget sample init error");
|
||||
}
|
||||
@ -301,7 +284,6 @@ void DjiUser_StartTask(void const *argument)
|
||||
printf("psdk upgrade init error");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
returnCode = DjiCore_ApplicationStart();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
|
@ -34,34 +34,34 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define CONFIG_MODULE_SAMPLE_POWER_MANAGEMENT_ON
|
||||
//#define CONFIG_MODULE_SAMPLE_POWER_MANAGEMENT_ON
|
||||
|
||||
#define CONFIG_MODULE_SAMPLE_CAMERA_ON
|
||||
//#define CONFIG_MODULE_SAMPLE_DATA_TRANSMISSION_ON
|
||||
|
||||
#define CONFIG_MODULE_SAMPLE_WIDGET_ON
|
||||
|
||||
#ifdef USE_BOOTLOADER
|
||||
//#ifdef USE_BOOTLOADER
|
||||
//Attention: If you don’t need to upgrade, you can uncomment it and change flash size from 0x70000 to 0xD0000 to build all functions.
|
||||
#define CONFIG_MODULE_SAMPLE_UPGRADE_ON
|
||||
#endif
|
||||
//#define CONFIG_MODULE_SAMPLE_UPGRADE_ON
|
||||
//#endif
|
||||
|
||||
#ifndef CONFIG_MODULE_SAMPLE_UPGRADE_ON
|
||||
//#ifndef CONFIG_MODULE_SAMPLE_UPGRADE_ON
|
||||
|
||||
#define CONFIG_MODULE_SAMPLE_GIMBAL_ON
|
||||
//#define CONFIG_MODULE_SAMPLE_GIMBAL_ON
|
||||
|
||||
#define CONFIG_MODULE_SAMPLE_DATA_TRANSMISSION_ON
|
||||
//#define CONFIG_MODULE_SAMPLE_CAMERA_ON
|
||||
|
||||
#define CONFIG_MODULE_SAMPLE_FC_SUBSCRIPTION_ON
|
||||
//#define CONFIG_MODULE_SAMPLE_FC_SUBSCRIPTION_ON
|
||||
|
||||
#define CONFIG_MODULE_SAMPLE_XPORT_ON
|
||||
//#define CONFIG_MODULE_SAMPLE_XPORT_ON
|
||||
|
||||
#define CONFIG_MODULE_SAMPLE_PAYLOAD_COLLABORATION_ON
|
||||
//#define CONFIG_MODULE_SAMPLE_PAYLOAD_COLLABORATION_ON
|
||||
|
||||
#define CONFIG_MODULE_SAMPLE_TIME_SYNC_ON
|
||||
//#define CONFIG_MODULE_SAMPLE_TIME_SYNC_ON
|
||||
|
||||
#define CONFIG_MODULE_SAMPLE_POSITIONING_ON
|
||||
//#define CONFIG_MODULE_SAMPLE_POSITIONING_ON
|
||||
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
|
@ -500,6 +500,11 @@
|
||||
</File>
|
||||
<File>
|
||||
<FileType>1</FileType>
|
||||
<FileName>test_waypoint_v3.c</FileName>
|
||||
<FilePath>..\..\..\..\..\module_sample\waypoint_v3\test_waypoint_v3.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileType>1</FileType>
|
||||
<FileName>test_widget.c</FileName>
|
||||
<FilePath>..\..\..\..\..\module_sample\widget\test_widget.c</FilePath>
|
||||
</File>
|
||||
@ -510,6 +515,11 @@
|
||||
</File>
|
||||
<File>
|
||||
<FileType>1</FileType>
|
||||
<FileName>test_widget_speaker.c</FileName>
|
||||
<FilePath>..\..\..\..\..\module_sample\widget\test_widget_speaker.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileType>1</FileType>
|
||||
<FileName>util_buffer.c</FileName>
|
||||
<FilePath>..\..\..\..\..\module_sample\utils\util_buffer.c</FilePath>
|
||||
</File>
|
||||
@ -1025,6 +1035,11 @@
|
||||
</File>
|
||||
<File>
|
||||
<FileType>5</FileType>
|
||||
<FileName>dji_waypoint_v3.h</FileName>
|
||||
<FilePath>..\..\..\..\..\..\..\psdk_lib\include\dji_waypoint_v3.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileType>5</FileType>
|
||||
<FileName>dji_widget.h</FileName>
|
||||
<FilePath>..\..\..\..\..\..\..\psdk_lib\include\dji_widget.h</FilePath>
|
||||
</File>
|
||||
|
Reference in New Issue
Block a user