PSDK 错误码

2022-07-25

PSDK 错误码的头文件为psdk_error.h,本文档描述了PSDK 错误码相关的宏定义和结构体的关键信息以及使用方法。

宏定义

  • 错误模块索引值偏移量
#define PSDK_ERROR_MODULE_INDEX_OFFSET  12u
  • 错误模块索引值掩码
#define PSDK_ERROR_MODULE_INDEX_MASK    0x00000000000FF000u
  • 原始错误码偏移量
#define PSDK_ERROR_RAW_CODE_OFFSET      0u
  • 原始错误码掩码
#define PSDK_ERROR_RAW_CODE_MASK        0x0000000000000FFFu
  • 错误码生成宏
#define PSDK_ERROR_CODE(moduleIndex, rawErrCode) \
((uint64_t)0 | \
((((uint64_t)(moduleIndex)) << (PSDK_ERROR_MODULE_INDEX_OFFSET)) & (PSDK_ERROR_MODULE_INDEX_MASK)) | \
((((uint64_t)(rawErrCode)) << (PSDK_ERROR_RAW_CODE_OFFSET)) & (PSDK_ERROR_RAW_CODE_MASK)))
  • 错误对象

    错误对象,依次表示错误码、错误描述、错误原因和错误恢复建议。请用户参考下表解决PSDK 错误。
#define PSDK_ERROR_OBJECTS \
/* system module error message */ \
{PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS, "Execution successfully.", NULL, NULL}, \
{PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_REQUEST_PARAMETER, "Request parameters are invalid.", NULL, "Please double-check requested parameters."}, \
{PSDK_ERROR_SYSTEM_MODULE_CODE_EXECUTING_HIGHER_PRIORITY_TASK, "A higher priority task is being executed.", NULL, "Please stop the higher priority task or try again later."}, \
{PSDK_ERROR_SYSTEM_MODULE_CODE_NONSUPPORT, "Operation is not supported.", NULL, "Please check input parameters or contact DJI for help."}, \
{PSDK_ERROR_SYSTEM_MODULE_CODE_TIMEOUT, "Execution timeout.", NULL, "Please contact DJI for help."}, \
{PSDK_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED, "Memory allocation failed.", NULL, "Please check system configure."}, \
{PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER, "Input parameters are invalid.", NULL, "Please double-check requested parameters."}, \
{PSDK_ERROR_SYSTEM_MODULE_CODE_NONSUPPORT_IN_CURRENT_STATE, "Operation is not supported in current state.", NULL, "Please try again later."}, \
{PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR, "System error.", NULL, "Please contact DJI for help."}, \
{PSDK_ERROR_SYSTEM_MODULE_CODE_HARDWARE_ERR, "Hardware error.", NULL, "Please contact DJI for help."}, \
{PSDK_ERROR_SYSTEM_MODULE_CODE_INSUFFICIENT_ELECTRICITY, "Low battery.", NULL, "Please replacement battery for machine and try again."}, \
{PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN, "Unknown error.", NULL, NULL}, \
{PSDK_ERROR_SYSTEM_MODULE_CODE_NOT_FOUND, "Parameters are not found.", NULL, NULL}, \
{PSDK_ERROR_SYSTEM_MODULE_CODE_OUT_OF_RANGE, "Out of range.", NULL, "Please check parameters."}, \
{PSDK_ERROR_SYSTEM_MODULE_CODE_BUSY, "System is busy.", NULL, "Please try again later."}, \
{PSDK_ERROR_SYSTEM_MODULE_CODE_DUPLICATE, "Have existed the same object.", NULL, "Please input valid parameters."}, \
{PSDK_ERROR_SYSTEM_MODULE_CODE_ADAPTER_NOT_MATCH, "PSDK adapter do not meet requirements.", NULL, "Please try again after replacing PSDK adapter."}, \
\
/* gimbal module error message */ \
{PSDK_ERROR_GIMBAL_MODULE_CODE_PITCH_REACH_POSITIVE_LIMIT, "Pitch axis gimbal reach positive limit.", NULL, "Please do not rotate towards positive direction."}, \
{PSDK_ERROR_GIMBAL_MODULE_CODE_PITCH_REACH_NEGATIVE_LIMIT, "Pitch axis gimbal reach negative limit.", NULL, "Please do not rotate towards negative direction."}, \
{PSDK_ERROR_GIMBAL_MODULE_CODE_ROLL_REACH_POSITIVE_LIMIT, "Roll axis gimbal reach positive limit.", NULL, "Please do not rotate towards positive direction."}, \
{PSDK_ERROR_GIMBAL_MODULE_CODE_ROLL_REACH_NEGATIVE_LIMIT, "Roll axis gimbal reach negative limit.", NULL, "Please do not rotate towards negative direction."}, \
{PSDK_ERROR_GIMBAL_MODULE_CODE_YAW_REACH_POSITIVE_LIMIT, "Yaw axis gimbal reach positive limit.", NULL, "Please do not rotate towards positive direction."}, \
{PSDK_ERROR_GIMBAL_MODULE_CODE_YAW_REACH_NEGATIVE_LIMIT, "Yaw axis gimbal reach negative limit.", NULL, "Please do not rotate towards negative direction."}, \
{PSDK_ERROR_GIMBAL_MODULE_CODE_NON_CONTROL_AUTHORITY, "Current device do not have control authority of the gimbal.", NULL, "Please do not control gimbal with other devices that have high control priority simultaneously."}, \
\
/* payload collaboration module error message */ \
{PSDK_ERROR_PAYLOAD_COLLABORATION_MODULE_CODE_POSITION_NOT_MATCH, "Payload mount position do not meet requirements.", NULL, "Please read API and user documentation, ensuring input parameters satisfy requirements."}, \
\
/* subscription module error message */ \
{PSDK_ERROR_SUBSCRIPTION_MODULE_CODE_INVALID_TOPIC_FREQ, "Frequency of topic is invalid.", NULL, "Please read API and user documentation, ensuring input parameters satisfy requirements."}, \
{PSDK_ERROR_SUBSCRIPTION_MODULE_CODE_TOPIC_DUPLICATE, "Topic is subscribed repeatedly.", NULL, "Please do not subscribe a topic repeatedly."}, \
{PSDK_ERROR_SUBSCRIPTION_MODULE_CODE_TOPIC_NOT_SUBSCRIBED, "Requested topic have not been subscribed.", NULL, "Please try to get value after subscribing topic."}, \
{PSDK_ERROR_SUBSCRIPTION_MODULE_CODE_TIMESTAMP_NOT_ENABLE, "Requested topic do not have timestamp data.", "Did not enable timestamp when subscribe topic.", "Please subscribe topic enabled timestamp."}, \
/* mop channel module error message */ \
{PSDK_ERROR_MOP_CHANNEL_MODULE_CODE_CONNECTION_CLOSE, "Connection of channel is closed.", "The peer channel do not work or abnormally be closed.", "Please confirm state of the peer channel and reaccept the connection request of MSDK/OSDK"}, \
  • 操作返回值(废弃)

    • 操作成功
    #define PSDK_RETURN_CODE_OK                 0
    • 空间分配错误
    #define PSDK_RETURN_CODE_ERR_ALLOC          1
    • 操作超时
    #define PSDK_RETURN_CODE_ERR_TIMEOUT        2
    • 对象不存在
    #define PSDK_RETURN_CODE_ERR_NOT_FOUND      3
    • 超出指定的范围
    #define PSDK_RETURN_CODE_ERR_OUT_OF_RANGE   4
    • 参数错误
    #define PSDK_RETURN_CODE_ERR_PARAM          5
    • 系统错误
    #define PSDK_RETURN_CODE_ERR_SYSTEM         6
    • 系统繁忙
    #define PSDK_RETURN_CODE_ERR_BUSY           7
* 暂不支持
#define PSDK_RETURN_CODE_ERR_UNSUPPORT      8
* 未知错误
#define PSDK_RETURN_CODE_ERR_UNKNOWN        0xFF

类型

  • 错误模块
typedef enum {
PSDK_ERROR_MODULE_SYSTEM = 0,
PSDK_ERROR_MODULE_PLATFORM,
PSDK_ERROR_MODULE_LOGGER,
PSDK_ERROR_MODULE_TIME_SYNC,
PSDK_ERROR_MODULE_COMMAND,
PSDK_ERROR_MODULE_CAMERA,
PSDK_ERROR_MODULE_GIMBAL,
PSDK_ERROR_MODULE_XPORT,
PSDK_ERROR_MODULE_PAYLOAD_COLLABORATION,
PSDK_ERROR_MODULE_WIDGET,
PSDK_ERROR_MODULE_CORE,
PSDK_ERROR_MODULE_IDENTITY,
PSDK_ERROR_MODULE_TRANSMISSION,
PSDK_ERROR_MODULE_DATA_CHANNEL,
PSDK_ERROR_MODULE_SUBSCRIPTION,
PSDK_ERROR_MODULE_MOP_CHANNEL,
PSDK_ERROR_MODULE_POSITIONING,
PSDK_ERROR_MODULE_POWER_MANAGEMENT,
PSDK_ERROR_MODULE_AIRCRAFTINFO,
PSDK_ERROR_MODULE_PRODUCTINFO,
PSDK_ERROR_MODULE_FLOWCONTROLLER,
PSDK_ERROR_MODULE_DOWNLOADER,
PSDK_ERROR_MODULE_PARAMETER,
PSDK_ERROR_MODULE_UTIL,
PSDK_ERROR_MODULE_USER,
PSDK_ERROR_MODULE_NEGOTIATE,
PSDK_ERROR_MODULE_UPGRADE,
PSDK_ERROR_MODULE_ERROR,
} E_PsdkErrorModule;
  • 系统通用模块原始错误码
typedef enum {
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_SUCCESS = 0x000,
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_INVALID_REQUEST_PARAMETER = 0x0D4,
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_EXECUTING_HIGHER_PRIORITY_TASK = 0x0D7,
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_NONSUPPORT = 0x0E0,
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_TIMEOUT = 0x0E1,
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_MEMORY_ALLOC_FAILED = 0x0E2,
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_INVALID_PARAMETER = 0x0E3,
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_NONSUPPORT_IN_CURRENT_STATE = 0x0E4,
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_SYSTEM_ERROR = 0x0EC,
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_HARDWARE_ERR = 0x0FA,
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_INSUFFICIENT_ELECTRICITY = 0x0FB,
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_UNKNOWN = 0x0FF,
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_NOT_FOUND = 0x100,
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_OUT_OF_RANGE = 0x101,
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_BUSY = 0x102,
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_DUPLICATE = 0x103,
PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_ADAPTER_NOT_MATCH = 0x104,
} E_PsdkErrorSystemModuleRawCode;
  • 云台模块原始错误码
typedef enum {
PSDK_ERROR_GIMBAL_MODULE_RAW_CODE_PITCH_REACH_POSITIVE_LIMIT = 0x000,
PSDK_ERROR_GIMBAL_MODULE_RAW_CODE_PITCH_REACH_NEGATIVE_LIMIT = 0x001,
PSDK_ERROR_GIMBAL_MODULE_RAW_CODE_ROLL_REACH_POSITIVE_LIMIT = 0x002,
PSDK_ERROR_GIMBAL_MODULE_RAW_CODE_ROLL_REACH_NEGATIVE_LIMIT = 0x003,
PSDK_ERROR_GIMBAL_MODULE_RAW_CODE_YAW_REACH_POSITIVE_LIMIT = 0x004,
PSDK_ERROR_GIMBAL_MODULE_RAW_CODE_YAW_REACH_NEGATIVE_LIMIT = 0x005,
PSDK_ERROR_GIMBAL_MODULE_RAW_CODE_NON_CONTROL_AUTHORITY = 0x006,
} E_PsdkErrorGimbalModuleRawCode;
  • 负载协同模块原始错误码
typedef enum {
PSDK_ERROR_PAYLOAD_COLLABORATION_MODULE_RAW_CODE_POSITION_NOT_MATCH = 0x000,
} E_PsdkErrorPayloadCollaborationModuleRawCode;
  • 数据订阅模块原始错误码
typedef enum {
PSDK_ERROR_SUBSCRIPTION_MODULE_RAW_CODE_INVALID_TOPIC_FREQ = 0x000,
PSDK_ERROR_SUBSCRIPTION_MODULE_RAW_CODE_TOPIC_DUPLICATE = 0x001,
PSDK_ERROR_SUBSCRIPTION_MODULE_RAW_CODE_TOPIC_NOT_SUBSCRIBED = 0x002,
PSDK_ERROR_SUBSCRIPTION_MODULE_RAW_CODE_TIMESTAMP_NOT_ENABLE = 0x003,
} E_PsdkErrorSubscriptionModuleRawCode;
  • SDK 互联互通模块原始错误码
typedef enum {
PSDK_ERROR_MOP_CHANNEL_MODULE_RAW_CODE_CONNECTION_CLOSE = 0x011,
} E_PsdkErrorMopChannelModuleRawCode;
  • PSDK 错误码

    PSDK 错误码全集。用户可以搜索到所有错误码信息。请参考错误对象获取错误描述、错误原因以及错误恢复建议。
enum PsdkErrorCode {
/* system module error code, including some common error code */
PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_SUCCESS),
PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_REQUEST_PARAMETER = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_INVALID_REQUEST_PARAMETER),
PSDK_ERROR_SYSTEM_MODULE_CODE_EXECUTING_HIGHER_PRIORITY_TASK = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_EXECUTING_HIGHER_PRIORITY_TASK),
PSDK_ERROR_SYSTEM_MODULE_CODE_NONSUPPORT = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_NONSUPPORT),
PSDK_ERROR_SYSTEM_MODULE_CODE_TIMEOUT = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_TIMEOUT),
PSDK_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_MEMORY_ALLOC_FAILED),
PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_INVALID_PARAMETER),
PSDK_ERROR_SYSTEM_MODULE_CODE_NONSUPPORT_IN_CURRENT_STATE = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_NONSUPPORT_IN_CURRENT_STATE),
PSDK_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_SYSTEM_ERROR),
PSDK_ERROR_SYSTEM_MODULE_CODE_HARDWARE_ERR = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_HARDWARE_ERR),
PSDK_ERROR_SYSTEM_MODULE_CODE_INSUFFICIENT_ELECTRICITY = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_INSUFFICIENT_ELECTRICITY),
PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_UNKNOWN),
PSDK_ERROR_SYSTEM_MODULE_CODE_NOT_FOUND = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_NOT_FOUND),
PSDK_ERROR_SYSTEM_MODULE_CODE_OUT_OF_RANGE = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_OUT_OF_RANGE),
PSDK_ERROR_SYSTEM_MODULE_CODE_BUSY = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_BUSY),
PSDK_ERROR_SYSTEM_MODULE_CODE_DUPLICATE = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_DUPLICATE),
PSDK_ERROR_SYSTEM_MODULE_CODE_ADAPTER_NOT_MATCH = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SYSTEM, PSDK_ERROR_SYSTEM_MODULE_RAW_CODE_ADAPTER_NOT_MATCH),

/* gimbal module error code */
PSDK_ERROR_GIMBAL_MODULE_CODE_PITCH_REACH_POSITIVE_LIMIT = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_GIMBAL, PSDK_ERROR_GIMBAL_MODULE_RAW_CODE_PITCH_REACH_POSITIVE_LIMIT),
PSDK_ERROR_GIMBAL_MODULE_CODE_PITCH_REACH_NEGATIVE_LIMIT = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_GIMBAL, PSDK_ERROR_GIMBAL_MODULE_RAW_CODE_PITCH_REACH_NEGATIVE_LIMIT),
PSDK_ERROR_GIMBAL_MODULE_CODE_ROLL_REACH_POSITIVE_LIMIT = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_GIMBAL, PSDK_ERROR_GIMBAL_MODULE_RAW_CODE_ROLL_REACH_POSITIVE_LIMIT),
PSDK_ERROR_GIMBAL_MODULE_CODE_ROLL_REACH_NEGATIVE_LIMIT = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_GIMBAL, PSDK_ERROR_GIMBAL_MODULE_RAW_CODE_ROLL_REACH_NEGATIVE_LIMIT),
PSDK_ERROR_GIMBAL_MODULE_CODE_YAW_REACH_POSITIVE_LIMIT = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_GIMBAL, PSDK_ERROR_GIMBAL_MODULE_RAW_CODE_YAW_REACH_POSITIVE_LIMIT),
PSDK_ERROR_GIMBAL_MODULE_CODE_YAW_REACH_NEGATIVE_LIMIT = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_GIMBAL, PSDK_ERROR_GIMBAL_MODULE_RAW_CODE_YAW_REACH_NEGATIVE_LIMIT),
PSDK_ERROR_GIMBAL_MODULE_CODE_NON_CONTROL_AUTHORITY = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_GIMBAL, PSDK_ERROR_GIMBAL_MODULE_RAW_CODE_NON_CONTROL_AUTHORITY),

/* payload collaboration module error code */
PSDK_ERROR_PAYLOAD_COLLABORATION_MODULE_CODE_POSITION_NOT_MATCH = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_PAYLOAD_COLLABORATION, PSDK_ERROR_PAYLOAD_COLLABORATION_MODULE_RAW_CODE_POSITION_NOT_MATCH),

/* subscription module error code */
PSDK_ERROR_SUBSCRIPTION_MODULE_CODE_INVALID_TOPIC_FREQ = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SUBSCRIPTION, PSDK_ERROR_SUBSCRIPTION_MODULE_RAW_CODE_INVALID_TOPIC_FREQ),
PSDK_ERROR_SUBSCRIPTION_MODULE_CODE_TOPIC_DUPLICATE = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SUBSCRIPTION, PSDK_ERROR_SUBSCRIPTION_MODULE_RAW_CODE_TOPIC_DUPLICATE),
PSDK_ERROR_SUBSCRIPTION_MODULE_CODE_TOPIC_NOT_SUBSCRIBED = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SUBSCRIPTION, PSDK_ERROR_SUBSCRIPTION_MODULE_RAW_CODE_TOPIC_NOT_SUBSCRIBED),
PSDK_ERROR_SUBSCRIPTION_MODULE_CODE_TIMESTAMP_NOT_ENABLE = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_SUBSCRIPTION, PSDK_ERROR_SUBSCRIPTION_MODULE_RAW_CODE_TIMESTAMP_NOT_ENABLE),

/* mop channel module error code */
PSDK_ERROR_MOP_CHANNEL_MODULE_CODE_CONNECTION_CLOSE = PSDK_ERROR_CODE(PSDK_ERROR_MODULE_MOP_CHANNEL, PSDK_ERROR_MOP_CHANNEL_MODULE_RAW_CODE_CONNECTION_CLOSE),
};