更新到psdk 3.13.0,适配M400

This commit is contained in:
tangchao0503
2025-09-10 16:03:18 +08:00
517 changed files with 197499 additions and 7197653 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,290 @@
/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef cJSON__h
#define cJSON__h
#ifdef __cplusplus
extern "C"
{
#endif
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
#define __WINDOWS__
#endif
#ifdef __WINDOWS__
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options:
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
For *nix builds that support visibility attribute, you can define similar behavior by
setting default visibility to hidden by adding
-fvisibility=hidden (for gcc)
or
-xldscope=hidden (for sun cc)
to CFLAGS
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
*/
#define CJSON_CDECL __cdecl
#define CJSON_STDCALL __stdcall
/* export symbols by default, this is necessary for copy pasting the C and header file */
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
#define CJSON_EXPORT_SYMBOLS
#endif
#if defined(CJSON_HIDE_SYMBOLS)
#define CJSON_PUBLIC(type) type CJSON_STDCALL
#elif defined(CJSON_EXPORT_SYMBOLS)
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
#elif defined(CJSON_IMPORT_SYMBOLS)
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
#endif
#else /* !__WINDOWS__ */
#define CJSON_CDECL
#define CJSON_STDCALL
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
#else
#define CJSON_PUBLIC(type) type
#endif
#endif
/* project version */
#define CJSON_VERSION_MAJOR 1
#define CJSON_VERSION_MINOR 7
#define CJSON_VERSION_PATCH 12
#include <stddef.h>
#include <stdint.h>
/* cJSON Types: */
#define cJSON_Invalid (0)
#define cJSON_False (1 << 0)
#define cJSON_True (1 << 1)
#define cJSON_NULL (1 << 2)
#define cJSON_Number (1 << 3)
#define cJSON_String (1 << 4)
#define cJSON_Array (1 << 5)
#define cJSON_Object (1 << 6)
#define cJSON_Raw (1 << 7) /* raw json */
#define cJSON_IsReference 256
#define cJSON_StringIsConst 512
/* The cJSON structure: */
typedef struct cJSON {
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON *next;
struct cJSON *prev;
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
struct cJSON *child;
/* The type of the item, as above. */
int type;
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
char *valuestring;
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
int valueint;
/* The item's number, if type==cJSON_Number */
double valuedouble;
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
char *string;
} cJSON;
typedef struct cJSON_Hooks {
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
void *(CJSON_CDECL *malloc_fn)(size_t sz);
void (CJSON_CDECL *free_fn)(void *ptr);
} cJSON_Hooks;
typedef int cJSON_bool;
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
* This is to prevent stack overflows. */
#ifndef CJSON_NESTING_LIMIT
#define CJSON_NESTING_LIMIT 1000
#endif
/* returns the version of cJSON as a string */
CJSON_PUBLIC(const char*)cJSON_Version(void);
/* Supply malloc, realloc and free functions to cJSON */
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks *hooks);
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
CJSON_PUBLIC(cJSON *)cJSON_Parse(const char *value);
CJSON_PUBLIC(cJSON *)cJSON_ParseByJsonData(const uint8_t *json_data, uint16_t data_len);
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
CJSON_PUBLIC(cJSON *)cJSON_ParseWithOpts(const char *value, const char **return_parse_end,
cJSON_bool require_null_terminated);
/* Render a cJSON entity to text for transfer/storage. */
CJSON_PUBLIC(char *)cJSON_Print(const cJSON *item);
/* Render a cJSON entity to text for transfer/storage without any formatting. */
CJSON_PUBLIC(char *)cJSON_PrintUnformatted(const cJSON *item);
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
CJSON_PUBLIC(char *)cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
/* Delete a cJSON entity and all subentities. */
CJSON_PUBLIC(void) cJSON_Delete(cJSON *item);
/* Returns the number of items in an array (or object). */
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
CJSON_PUBLIC(cJSON *)cJSON_GetArrayItem(const cJSON *array, int index);
/* Get item "string" from object. Case insensitive. */
CJSON_PUBLIC(cJSON *)cJSON_GetObjectItem(const cJSON *const object, const char *const string);
CJSON_PUBLIC(cJSON *)cJSON_GetObjectItemCaseSensitive(const cJSON *const object, const char *const string);
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
CJSON_PUBLIC(const char *)cJSON_GetErrorPtr(void);
/* Check if the item is a string and return its valuestring */
CJSON_PUBLIC(char *)cJSON_GetStringValue(cJSON *item);
/* These functions check the type of an item */
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON *const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON *const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON *const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON *const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON *const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON *const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON *const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON *const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON *const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON *const item);
/* These calls create a cJSON item of the appropriate type. */
CJSON_PUBLIC(cJSON *)cJSON_CreateNull(void);
CJSON_PUBLIC(cJSON *)cJSON_CreateTrue(void);
CJSON_PUBLIC(cJSON *)cJSON_CreateFalse(void);
CJSON_PUBLIC(cJSON *)cJSON_CreateBool(cJSON_bool boolean);
CJSON_PUBLIC(cJSON *)cJSON_CreateNumber(double num);
CJSON_PUBLIC(cJSON *)cJSON_CreateString(const char *string);
/* raw json */
CJSON_PUBLIC(cJSON *)cJSON_CreateRaw(const char *raw);
CJSON_PUBLIC(cJSON *)cJSON_CreateArray(void);
CJSON_PUBLIC(cJSON *)cJSON_CreateObject(void);
/* Create a string where valuestring references a string so
* it will not be freed by cJSON_Delete */
CJSON_PUBLIC(cJSON *)cJSON_CreateStringReference(const char *string);
/* Create an object/array that only references it's elements so
* they will not be freed by cJSON_Delete */
CJSON_PUBLIC(cJSON *)cJSON_CreateObjectReference(const cJSON *child);
CJSON_PUBLIC(cJSON *)cJSON_CreateArrayReference(const cJSON *child);
/* These utilities create an Array of count items.
* The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.*/
CJSON_PUBLIC(cJSON *)cJSON_CreateIntArray(const int *numbers, int count);
CJSON_PUBLIC(cJSON *)cJSON_CreateFloatArray(const float *numbers, int count);
CJSON_PUBLIC(cJSON *)cJSON_CreateDoubleArray(const double *numbers, int count);
CJSON_PUBLIC(cJSON *)cJSON_CreateStringArray(const char **strings, int count);
/* Append item to the specified array/object. */
CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item);
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
* writing to `item->string` */
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
/* Remove/Detach items from Arrays/Objects. */
CJSON_PUBLIC(cJSON *)cJSON_DetachItemViaPointer(cJSON *parent, cJSON *const item);
CJSON_PUBLIC(cJSON *)cJSON_DetachItemFromArray(cJSON *array, int which);
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
CJSON_PUBLIC(cJSON *)cJSON_DetachItemFromObject(cJSON *object, const char *string);
CJSON_PUBLIC(cJSON *)cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
/* Update array items. */
CJSON_PUBLIC(void)
cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON *const parent, cJSON *const item, cJSON *replacement);
CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem);
CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem);
/* Duplicate a cJSON item */
CJSON_PUBLIC(cJSON *)cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
* need to be released. With recurse!=0, it will duplicate any children connected to the item.
* The item->next and ->prev pointers are always zero on return from Duplicate. */
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON *const a, const cJSON *const b, const cJSON_bool case_sensitive);
/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
* The input pointer json cannot point to a read-only address area, such as a string constant,
* but should point to a readable and writable adress area. */
CJSON_PUBLIC(void) cJSON_Minify(char *json);
/* Helper functions for creating and adding items to an object at the same time.
* They return the added item or NULL on failure. */
CJSON_PUBLIC(cJSON*)cJSON_AddNullToObject(cJSON *const object, const char *const name);
CJSON_PUBLIC(cJSON*)cJSON_AddTrueToObject(cJSON *const object, const char *const name);
CJSON_PUBLIC(cJSON*)cJSON_AddFalseToObject(cJSON *const object, const char *const name);
CJSON_PUBLIC(cJSON*)cJSON_AddBoolToObject(cJSON *const object, const char *const name, const cJSON_bool boolean);
CJSON_PUBLIC(cJSON*)cJSON_AddNumberToObject(cJSON *const object, const char *const name, const double number);
CJSON_PUBLIC(cJSON*)cJSON_AddStringToObject(cJSON *const object, const char *const name, const char *const string);
CJSON_PUBLIC(cJSON*)cJSON_AddRawToObject(cJSON *const object, const char *const name, const char *const raw);
CJSON_PUBLIC(cJSON*)cJSON_AddObjectToObject(cJSON *const object, const char *const name);
CJSON_PUBLIC(cJSON*)cJSON_AddArrayToObject(cJSON *const object, const char *const name);
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
/* helper for the cJSON_SetNumberValue macro */
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
/* Macro for iterating over an array or object */
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
CJSON_PUBLIC(void *)cJSON_malloc(size_t size);
CJSON_PUBLIC(void) cJSON_free(void *object);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,359 @@
/**
********************************************************************
* @file dji_config_manager.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 DJIs 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_misc.h>
#include <dji_logger.h>
#include <utils/util_file.h>
#include <dji_aircraft_info.h>
#include "dji_config_manager.h"
#include "utils/cJSON.h"
/* Private constants ---------------------------------------------------------*/
/* Private types -------------------------------------------------------------*/
/* Private values -------------------------------------------------------------*/
static T_DjiUserInfo s_configManagerUserInfo = {0};
static T_DjiUserLinkConfig s_configManagerLinkInfo = {0};
static bool s_configManagerIsEnable = false;
/* Private functions declaration ---------------------------------------------*/
static T_DjiReturnCode DjiUserConfigManager_GetAppInfoInner(const char *path, T_DjiUserInfo *userInfo);
static T_DjiReturnCode DjiUserConfigManager_GetLinkConfigInner(const char *path, T_DjiUserLinkConfig *linkConfig);
/* Exported functions definition ---------------------------------------------*/
T_DjiReturnCode DjiUserConfigManager_LoadConfiguration(const char *path)
{
T_DjiReturnCode returnCode;
if (path == NULL) {
perror("Config file path is null.\n");
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
}
printf("Load configuration start, config file path is: %s\r\n", path);
returnCode = DjiUserConfigManager_GetAppInfoInner(path, &s_configManagerUserInfo);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
perror("Get app info failed.\n");
}
returnCode = DjiUserConfigManager_GetLinkConfigInner(path, &s_configManagerLinkInfo);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
perror("Get link info failed.\n");
}
printf("\r\nLoad configuration successfully.\r\n");
s_configManagerIsEnable = true;
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
void DjiUserConfigManager_GetAppInfo(T_DjiUserInfo *userInfo)
{
memcpy(userInfo, &s_configManagerUserInfo, sizeof(T_DjiUserInfo));
}
void DjiUserConfigManager_GetLinkConfig(T_DjiUserLinkConfig *linkConfig)
{
memcpy(linkConfig, &s_configManagerLinkInfo, sizeof(T_DjiUserLinkConfig));
}
bool DjiUserConfigManager_IsEnable(void)
{
return s_configManagerIsEnable;
}
/* Private functions definition-----------------------------------------------*/
static T_DjiReturnCode DjiUserConfigManager_GetAppInfoInner(const char *path, T_DjiUserInfo *userInfo)
{
#ifdef SYSTEM_ARCH_LINUX
T_DjiReturnCode returnCode;
uint32_t fileSize = 0;
uint32_t readRealSize = 0;
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
uint8_t *jsonData = NULL;
cJSON *jsonRoot = NULL;
cJSON *jsonItem = NULL;
cJSON *jsonValue = NULL;
returnCode = UtilFile_GetFileSizeByPath(path, &fileSize);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get file size by path failed, stat = 0x%08llX", returnCode);
return returnCode;
}
USER_LOG_DEBUG("Get config json file size is %d", fileSize);
jsonData = osalHandler->Malloc(fileSize + 1);
if (jsonData == NULL) {
USER_LOG_ERROR("Malloc failed.");
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
memset(jsonData, 0, fileSize);
UtilFile_GetFileDataByPath(path, 0, fileSize, jsonData, &readRealSize);
jsonData[readRealSize] = '\0';
jsonRoot = cJSON_Parse((char *) jsonData);
if (jsonRoot == NULL) {
returnCode = DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
goto jsonDataFree;
}
jsonItem = cJSON_GetObjectItem(jsonRoot, "dji_sdk_app_info");
if (jsonItem != NULL) {
jsonValue = cJSON_GetObjectItem(jsonItem, "user_app_name");
if (jsonValue != NULL) {
strcpy(userInfo->appName, jsonValue->valuestring);
}
jsonValue = cJSON_GetObjectItem(jsonItem, "user_app_id");
if (jsonValue != NULL) {
strcpy(userInfo->appId, jsonValue->valuestring);
}
jsonValue = cJSON_GetObjectItem(jsonItem, "user_app_key");
if (jsonValue != NULL) {
strcpy(userInfo->appKey, jsonValue->valuestring);
}
jsonValue = cJSON_GetObjectItem(jsonItem, "user_app_license");
if (jsonValue != NULL) {
strcpy(userInfo->appLicense, jsonValue->valuestring);
}
jsonValue = cJSON_GetObjectItem(jsonItem, "user_develop_account");
if (jsonValue != NULL) {
strcpy(userInfo->developerAccount, jsonValue->valuestring);
}
jsonValue = cJSON_GetObjectItem(jsonItem, "user_baud_rate");
if (jsonValue != NULL) {
strcpy(userInfo->baudRate, jsonValue->valuestring);
}
}
if (strlen(userInfo->appName) >= sizeof(userInfo->appName) ||
strlen(userInfo->appId) > sizeof(userInfo->appId) ||
strlen(userInfo->appKey) > sizeof(userInfo->appKey) ||
strlen(userInfo->appLicense) > sizeof(userInfo->appLicense) ||
strlen(userInfo->developerAccount) >= sizeof(userInfo->developerAccount) ||
strlen(userInfo->baudRate) > sizeof(userInfo->baudRate)) {
USER_LOG_ERROR("Length of user information string is beyond limit. Please check.");
returnCode = DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
goto jsonDataFree;
}
if (!strcmp(userInfo->appName, "your_app_name") ||
!strcmp(userInfo->appId, "your_app_id") ||
!strcmp(userInfo->appKey, "your_app_key") ||
!strcmp(userInfo->appLicense, "your_app_license") ||
!strcmp(userInfo->developerAccount, "your_developer_account") ||
!strcmp(userInfo->baudRate, "your_baud_rate")) {
USER_LOG_ERROR(
"Please fill in correct user information to 'samples/sample_c++/platform/linux/manifold2/application/dji_sdk_config.json' file.");
returnCode = DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
goto jsonDataFree;
}
jsonDataFree:
osalHandler->Free(jsonData);
#endif
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_DjiReturnCode DjiUserConfigManager_GetLinkConfigInner(const char *path, T_DjiUserLinkConfig *linkConfig)
{
#ifdef SYSTEM_ARCH_LINUX
T_DjiReturnCode returnCode;
uint32_t fileSize = 0;
uint32_t readRealSize = 0;
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
uint8_t *jsonData = NULL;
cJSON *jsonRoot = NULL;
cJSON *jsonItem = NULL;
cJSON *jsonValue = NULL;
cJSON *jsonConfig = NULL;
int32_t configValue;
returnCode = UtilFile_GetFileSizeByPath(path, &fileSize);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get file size by path failed, stat = 0x%08llX", returnCode);
return returnCode;
}
USER_LOG_DEBUG("Get config json file size is %d", fileSize);
jsonData = osalHandler->Malloc(fileSize + 1);
if (jsonData == NULL) {
USER_LOG_ERROR("Malloc failed.");
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
memset(jsonData, 0, fileSize);
UtilFile_GetFileDataByPath(path, 0, fileSize, jsonData, &readRealSize);
jsonData[readRealSize] = '\0';
jsonRoot = cJSON_Parse((char *) jsonData);
if (jsonRoot == NULL) {
goto jsonDataFree;
}
jsonItem = cJSON_GetObjectItem(jsonRoot, "dji_sdk_link_config");
if (jsonItem != NULL) {
jsonValue = cJSON_GetObjectItem(jsonItem, "link_select");
if (jsonValue != NULL) {
printf("\r\nSelect link type: %s\r\n", jsonValue->valuestring);
if (strcmp(jsonValue->valuestring, "use_only_uart") == 0) {
linkConfig->type = DJI_USER_LINK_CONFIG_USE_ONLY_UART;
} else if (strcmp(jsonValue->valuestring, "use_uart_and_network_device") == 0) {
linkConfig->type = DJI_USER_LINK_CONFIG_USE_UART_AND_NETWORK_DEVICE;
} else if (strcmp(jsonValue->valuestring, "use_uart_and_usb_bulk_device") == 0) {
linkConfig->type = DJI_USER_LINK_CONFIG_USE_UART_AND_USB_BULK_DEVICE;
} else if (strcmp(jsonValue->valuestring, "use_only_usb_bulk_device") == 0) {
linkConfig->type = DJI_USER_LINK_CONFIG_USE_ONLY_USB_BULK_DEVICE;
} else if (strcmp(jsonValue->valuestring, "use_only_network_device") == 0) {
linkConfig->type = DJI_USER_LINK_CONFIG_USE_ONLY_NETWORK_DEVICE;
}
}
jsonValue = cJSON_GetObjectItem(jsonItem, "uart_config");
if (jsonValue != NULL) {
jsonConfig = cJSON_GetObjectItem(jsonValue, "uart1_device_name");
printf("\r\nConfig uart1 device name: %s\r\n", jsonConfig->valuestring);
strcpy(linkConfig->uartConfig.uart1DeviceName, jsonConfig->valuestring);
jsonConfig = cJSON_GetObjectItem(jsonValue, "uart2_device_name");
printf("Config uart2 device name: %s\r\n", jsonConfig->valuestring);
strcpy(linkConfig->uartConfig.uart2DeviceName, jsonConfig->valuestring);
jsonConfig = cJSON_GetObjectItem(jsonValue, "uart2_device_enable");
printf("Config uart2 device enable: %s\r\n", jsonConfig->valuestring);
if (strcmp(jsonConfig->valuestring, "true") == 0) {
linkConfig->uartConfig.uart2DeviceEnable = true;
} else {
linkConfig->uartConfig.uart2DeviceEnable = false;
}
}
jsonValue = cJSON_GetObjectItem(jsonItem, "network_config");
if (jsonValue != NULL) {
jsonConfig = cJSON_GetObjectItem(jsonValue, "network_device_name");
printf("\r\nConfig network device name: %s\r\n", jsonConfig->valuestring);
strcpy(linkConfig->networkConfig.networkDeviceName, jsonConfig->valuestring);
jsonConfig = cJSON_GetObjectItem(jsonValue, "network_usb_adapter_vid");
printf("Config network usb adapter vid: %s\r\n", jsonConfig->valuestring);
sscanf(jsonConfig->valuestring, "%X", &configValue);
linkConfig->networkConfig.networkUsbAdapterVid = configValue;
jsonConfig = cJSON_GetObjectItem(jsonValue, "network_usb_adapter_pid");
printf("Config network usb adapter vid: %s\r\n", jsonConfig->valuestring);
sscanf(jsonConfig->valuestring, "%X", &configValue);
linkConfig->networkConfig.networkUsbAdapterPid = configValue;
}
jsonValue = cJSON_GetObjectItem(jsonItem, "usb_bulk_config");
if (jsonValue != NULL) {
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_device_vid");
printf("\r\nConfig usb device vid: %s\r\n", jsonConfig->valuestring);
sscanf(jsonConfig->valuestring, "%X", &configValue);
linkConfig->usbBulkConfig.usbDeviceVid = configValue;
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_device_pid");
printf("Config usb device pid: %s\r\n", jsonConfig->valuestring);
sscanf(jsonConfig->valuestring, "%X", &configValue);
linkConfig->usbBulkConfig.usbDevicePid = configValue;
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk1_device_name");
printf("Config usb bulk1 device name: %s\r\n", jsonConfig->valuestring);
strcpy(linkConfig->usbBulkConfig.usbBulk1DeviceName, jsonConfig->valuestring);
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk1_interface_num");
printf("Config usb bulk1 interface num: %s\r\n", jsonConfig->valuestring);
sscanf(jsonConfig->valuestring, "%X", &configValue);
linkConfig->usbBulkConfig.usbBulk1InterfaceNum = configValue;
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk1_endpoint_in");
printf("Config usb bulk1 endpoint in: %s\r\n", jsonConfig->valuestring);
sscanf(jsonConfig->valuestring, "%X", &configValue);
linkConfig->usbBulkConfig.usbBulk1EndpointIn = configValue;
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk1_endpoint_out");
printf("Config usb bulk1 endpoint out: %s\r\n", jsonConfig->valuestring);
sscanf(jsonConfig->valuestring, "%X", &configValue);
linkConfig->usbBulkConfig.usbBulk1EndpointOut = configValue;
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk2_device_name");
printf("Config usb bulk2 device name: %s\r\n", jsonConfig->valuestring);
strcpy(linkConfig->usbBulkConfig.usbBulk2DeviceName, jsonConfig->valuestring);
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk2_interface_num");
printf("Config usb bulk2 interface num: %s\r\n", jsonConfig->valuestring);
sscanf(jsonConfig->valuestring, "%X", &configValue);
linkConfig->usbBulkConfig.usbBulk2InterfaceNum = configValue;
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk2_endpoint_in");
printf("Config usb bulk2 endpoint in: %s\r\n", jsonConfig->valuestring);
linkConfig->usbBulkConfig.usbBulk2EndpointIn = configValue;
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk2_endpoint_out");
printf("Config usb bulk2 endpoint out: %s\r\n", jsonConfig->valuestring);
linkConfig->usbBulkConfig.usbBulk2EndpointOut = configValue;
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk3_device_name");
printf("Config usb bulk2 device name: %s\r\n", jsonConfig->valuestring);
strcpy(linkConfig->usbBulkConfig.usbBulk3DeviceName, jsonConfig->valuestring);
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk3_interface_num");
printf("Config usb bulk2 interface num: %s\r\n", jsonConfig->valuestring);
sscanf(jsonConfig->valuestring, "%X", &configValue);
linkConfig->usbBulkConfig.usbBulk3InterfaceNum = configValue;
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk3_endpoint_in");
printf("Config usb bulk2 endpoint in: %s\r\n", jsonConfig->valuestring);
linkConfig->usbBulkConfig.usbBulk3EndpointIn = configValue;
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk3_endpoint_out");
printf("Config usb bulk2 endpoint out: %s\r\n", jsonConfig->valuestring);
linkConfig->usbBulkConfig.usbBulk3EndpointOut = configValue;
}
}
jsonDataFree:
osalHandler->Free(jsonData);
#endif
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/

View File

@ -0,0 +1,95 @@
/**
********************************************************************
* @file dji_config_manager.h
* @brief This is the header file for "dji_config_manager.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 DJIs 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_CONFIG_MANAGER_H
#define DJI_CONFIG_MANAGER_H
/* Includes ------------------------------------------------------------------*/
#include "dji_platform.h"
#include "dji_core.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Exported constants --------------------------------------------------------*/
#define USER_DEVICE_NAME_STR_MAX_SIZE (64)
/* Exported types ------------------------------------------------------------*/
typedef enum {
DJI_USER_LINK_CONFIG_USE_ONLY_UART,
DJI_USER_LINK_CONFIG_USE_UART_AND_NETWORK_DEVICE,
DJI_USER_LINK_CONFIG_USE_UART_AND_USB_BULK_DEVICE,
DJI_USER_LINK_CONFIG_USE_ONLY_USB_BULK_DEVICE,
DJI_USER_LINK_CONFIG_USE_ONLY_NETWORK_DEVICE,
} E_DjiUserLinkConfigType;
typedef struct {
E_DjiUserLinkConfigType type;
struct {
char uart1DeviceName[USER_DEVICE_NAME_STR_MAX_SIZE];
bool uart2DeviceEnable;
char uart2DeviceName[USER_DEVICE_NAME_STR_MAX_SIZE];
} uartConfig;
struct {
char networkDeviceName[USER_DEVICE_NAME_STR_MAX_SIZE];
// M300/M350 RTK payload port no need
uint16_t networkUsbAdapterVid;
uint16_t networkUsbAdapterPid;
} networkConfig;
struct {
uint16_t usbDeviceVid;
uint16_t usbDevicePid;
char usbBulk1DeviceName[USER_DEVICE_NAME_STR_MAX_SIZE];
uint8_t usbBulk1InterfaceNum;
uint8_t usbBulk1EndpointIn;
uint8_t usbBulk1EndpointOut;
char usbBulk2DeviceName[USER_DEVICE_NAME_STR_MAX_SIZE];
uint8_t usbBulk2InterfaceNum;
uint8_t usbBulk2EndpointIn;
uint8_t usbBulk2EndpointOut;
char usbBulk3DeviceName[USER_DEVICE_NAME_STR_MAX_SIZE];
uint8_t usbBulk3InterfaceNum;
uint8_t usbBulk3EndpointIn;
uint8_t usbBulk3EndpointOut;
} usbBulkConfig;
} T_DjiUserLinkConfig;
/* Exported functions --------------------------------------------------------*/
T_DjiReturnCode DjiUserConfigManager_LoadConfiguration(const char *path);
void DjiUserConfigManager_GetAppInfo(T_DjiUserInfo *userInfo);
void DjiUserConfigManager_GetLinkConfig(T_DjiUserLinkConfig *linkConfig);
bool DjiUserConfigManager_IsEnable(void);
#ifdef __cplusplus
}
#endif
#endif // DJI_CONFIG_MANAGER_H
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/

View File

@ -89,8 +89,8 @@ T_DjiReturnCode UtilFile_GetFileSizeByPath(const char *filePath, uint32_t *fileS
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
T_DjiReturnCode UtilFile_GetFileDataByPath(const char *filePath, uint32_t offset, uint16_t len,
uint8_t *data, uint16_t *realLen)
T_DjiReturnCode UtilFile_GetFileDataByPath(const char *filePath, uint32_t offset, uint32_t len,
uint8_t *data, uint32_t *realLen)
{
FILE *pF;
T_DjiReturnCode psdkStat;

View File

@ -52,8 +52,8 @@ typedef struct {
/* Exported functions --------------------------------------------------------*/
T_DjiReturnCode UtilFile_GetCreateTime(const char *filePath, T_UtilFileCreateTime *createTime);
T_DjiReturnCode UtilFile_GetFileSizeByPath(const char *filePath, uint32_t *fileSize);
T_DjiReturnCode UtilFile_GetFileDataByPath(const char *filePath, uint32_t offset, uint16_t len,
uint8_t *data, uint16_t *realLen);
T_DjiReturnCode UtilFile_GetFileDataByPath(const char *filePath, uint32_t offset, uint32_t len,
uint8_t *data, uint32_t *realLen);
T_DjiReturnCode DjiFile_Delete(const char *filePath);
T_DjiReturnCode UtilFile_GetFileSize(FILE *file, uint32_t *fileSize);

View File

@ -0,0 +1,218 @@
/**
********************************************************************
* @file util_link_list.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 DJIs 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 UTIL_LINK_LIST_C
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "util_link_list.h"
/* Private constants ---------------------------------------------------------*/
/* Private types -------------------------------------------------------------*/
/* Private functions declaration ---------------------------------------------*/
/* Private values ------------------------------------------------------------*/
/* Exported functions definition ---------------------------------------------*/
void DjiUserUtil_ListNodeDeleteDataOnly( T_UtilListNode *node )
{
if ( NULL == node) {
UTIL_REPORT_ERROR( "null pointer" );
return;
}
if ( NULL != node->data ) {
UTIL_OSAL_MEMRY_FREE( node->data );
node->data = NULL;
}
return;
}
void DjiUserUtil_ListNodeDeleteNodeSelf( T_UtilListNode *node )
{
if ( NULL == node) {
UTIL_REPORT_ERROR( "null pointer" );
return;
}
UTIL_OSAL_MEMRY_FREE( node );
return;
}
void DjiUserUtil_InitListNode( T_UtilListNode *node, void *data )
{
if ( NULL == node ) {
UTIL_REPORT_ERROR( "null pointer" );
return;
}
node->prev = NULL;
node->next = NULL;
node->data = data;
return;
}
T_UtilListNode *DjiUserUtil_NewListNode( void *data )
{
T_UtilListNode *node = NULL;
node = (T_UtilListNode *)UTIL_OSAL_MEMRY_ALLOC( sizeof(T_UtilListNode) );
if ( NULL == node ) {
UTIL_REPORT_ERROR( "null pointer" );
return NULL;
}
DjiUserUtil_InitListNode( node, data );
return node;
}
void DjiUserUtil_LinkListDestory( T_UtilLinkList *linkList )
{
T_UtilListNode *node = NULL;
T_UtilListNode *next = NULL;
if ( NULL == linkList ) {
UTIL_REPORT_ERROR( "null pointer" );
return;
}
for ( node = linkList->first; NULL != node ; node = next ) {
next = node->next;
DjiUserUtil_ListNodeDeleteDataOnly( node );
DjiUserUtil_ListNodeDeleteNodeSelf( node );
}
}
void DjiUserUtil_LinkListAddNodeFirst( T_UtilLinkList *linkList, T_UtilListNode *node )
{
if ( ( NULL == linkList ) || ( NULL == node ) ) {
UTIL_REPORT_ERROR( "null pointer" );
return;
}
if ( UTIL_LINKLIST_IS_EMPTY( *linkList ) ) {
node->prev = NULL;
node->next = NULL;
linkList->first = node;
linkList->last = node;
} else {
node->prev = NULL;
node->next = linkList->first;
linkList->first = node;
node->next->prev = node;
}
linkList->count ++;
return;
}
void DjiUserUtil_LinkListAddNodeLast( T_UtilLinkList *linkList, T_UtilListNode *node )
{
if ( ( NULL == linkList ) || ( NULL == node ) ) {
UTIL_REPORT_ERROR( "null pointer" );
return;
}
if ( UTIL_LINKLIST_IS_EMPTY( *linkList ) ) {
node->prev = NULL;
node->next = NULL;
linkList->first = node;
linkList->last = node;
} else {
node->next = NULL;
node->prev = linkList->last;
linkList->last = node;
node->prev->next = node;
}
linkList->count ++;
return;
}
void DjiUserUtil_InitLinkList( T_UtilLinkList *linkList )
{
if ( NULL == linkList ) {
UTIL_REPORT_ERROR( "null pointer" );
return;
}
linkList->first = NULL;
linkList->last = NULL;
linkList->count = 0;
return;
}
T_UtilLinkList *DjiUserUtil_NewLinkList( void )
{
T_UtilLinkList *linkList = NULL;
linkList = (T_UtilLinkList *)UTIL_OSAL_MEMRY_ALLOC( sizeof( T_UtilLinkList ) );
if ( NULL == linkList ) {
UTIL_REPORT_ERROR( "null pointer" );
return NULL;
}
DjiUserUtil_InitLinkList( linkList );
return linkList;
}
void DjiUserUtil_LinkListRemoveNodeOnly( T_UtilLinkList *linkList, T_UtilListNode *node )
{
if ( ( NULL == linkList ) || ( NULL == node ) ) {
UTIL_REPORT_ERROR( "null pointer" );
return;
}
if ( node == linkList->first ) {
linkList->first = linkList->first->next;
}
if ( node == linkList->last ) {
linkList->last = linkList->last->prev;
}
if ( NULL != node->next ) {
node->next->prev = node->prev;
}
if ( NULL != node->prev ) {
node->prev->next = node->next;
}
if ( 0 != linkList->count ) {
linkList->count --;
}
DjiUserUtil_ListNodeDeleteNodeSelf( node );
return;
}
/* Private functions definition-----------------------------------------------*/
#ifdef __cplusplus
}
#endif
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/

View File

@ -0,0 +1,94 @@
/**
********************************************************************
* @file link_list.h
* @brief This is the header file for "link_list.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 DJIs 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 UTIL_LINK_LIST_H
#define UTIL_LINK_LIST_H
/* Includes ------------------------------------------------------------------*/
#include "dji_platform.h"
#ifdef UTIL_LINK_LIST_C
#define UTIL_LINK_LIST_EXT
#else
#define UTIL_LINK_LIST_EXT extern
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Exported constants --------------------------------------------------------*/
#define UTIL_REPORT_ERROR( exp... )
#define UTIL_OSAL_MEMRY_ALLOC(size) ( { T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler(); osalHandler->Malloc( size ); } )
#define UTIL_OSAL_MEMRY_FREE(ptr) ( { T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler(); osalHandler->Free( ptr ); } )
#define UTIL_OSAL_SEM_FREE_MAY_RETURN(sem) ( { T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler(); if( DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS != osalHandler->SemaphoreDestroy( sem ) ) { return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; } } )
#define UTIL_OSAL_SEM_INIT_MAY_RETURN(sem) ( { T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler(); if( DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS != osalHandler->SemaphoreCreate( 0, sem ) ) { return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; } } )
#define UTIL_OSAL_SEM_POST_MAY_RETURN(sem) ( { T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler(); if( DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS != osalHandler->SemaphorePost( sem ) ) { return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; } } )
#define UTIL_OSAL_SEM_WAIT_MAY_RETURN(sem) ( { T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler(); if( DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS != osalHandler->SemaphoreWait( sem ) ) { return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; } } )
#define UTIL_OSAL_SEM_WAIT_FOR(sem,ms) ( { T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler(); if( DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS != osalHandler->SemaphoreTimedWait( sem, ms ) ) { return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; } } )
#define UTIL_OSAL_MUTEX_FREE_MAY_RETURN(mutex) ( { T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler(); if( DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS != osalHandler->MutexDestroy( mutex ) ) { return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; } } )
#define UTIL_OSAL_MUTEX_INIT_MAY_RETURN(mutex) ( { T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler(); if( DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS != osalHandler->MutexCreate( mutex ) ) { return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; } } )
#define UTIL_OSAL_MUTEX_LOCK_MAY_RETURN(mutex) ( { T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler(); if( DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS != osalHandler->MutexLock( mutex ) ) { return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; } } )
#define UTIL_OSAL_MUTEX_UNLOCK_MAY_RETURN(mutex) ( { T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler(); if( DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS != osalHandler->MutexUnlock( mutex ) ) { return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER; } } )
#define UTIL_LINKLIST_IS_EMPTY(l) ( ((l).first == NULL) ? true : false )
/* Exported types ------------------------------------------------------------*/
typedef struct tagT_UtilListNode {
struct tagT_UtilListNode *next;
struct tagT_UtilListNode *prev;
void *data;
} T_UtilListNode;
typedef struct tagT_UtilLinkList {
T_UtilListNode *first;
T_UtilListNode *last;
uint32_t count;
} T_UtilLinkList;
/* Exported functions --------------------------------------------------------*/
UTIL_LINK_LIST_EXT void DjiUserUtil_ListNodeDeleteDataOnly( T_UtilListNode *node );
UTIL_LINK_LIST_EXT void DjiUserUtil_ListNodeDeleteNodeSelf( T_UtilListNode *node );
UTIL_LINK_LIST_EXT void DjiUserUtil_InitListNode( T_UtilListNode *node, void *data );
UTIL_LINK_LIST_EXT T_UtilListNode *DjiUserUtil_NewListNode( void *data );
UTIL_LINK_LIST_EXT void DjiUserUtil_LinkListDestory( T_UtilLinkList *linkList );
UTIL_LINK_LIST_EXT void DjiUserUtil_LinkListAddNodeFirst( T_UtilLinkList *linkList, T_UtilListNode *node );
UTIL_LINK_LIST_EXT void DjiUserUtil_LinkListAddNodeLast( T_UtilLinkList *linkList, T_UtilListNode *node );
UTIL_LINK_LIST_EXT void DjiUserUtil_InitLinkList( T_UtilLinkList *linkList );
UTIL_LINK_LIST_EXT T_UtilLinkList *DjiUserUtil_NewLinkList( void );
UTIL_LINK_LIST_EXT void DjiUserUtil_LinkListRemoveNodeOnly( T_UtilLinkList *linkList, T_UtilListNode *node );
#ifdef __cplusplus
}
#endif
#endif // UTIL_LINK_LIST_H
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/