HMS Customization
Overview
Health Management System (HMS) is a system that observes the operational health status of aircraft modules. An interactive interface has been provided on DJI Pilot 2 to check whether the working status of aircraft modules is abnormal. PSDK provides a basic interface to obtain custom error codes, so that developers can know the working status of the aircraft on Pilot 2.
Basic Concept
HMS Error Code
A single HMS error code includes an error ID, an error index, and an error level. After PSDK reports a custom HMS error code, the corresponding message will be displayed on Pilot 2.
Currently HMS customization only supports Chinese and English.
HMS error codes range in severity from lowest (0) to highest (4).
DJI_HMS_ERROR_LEVEL_NONE = 0,
DJI_HMS_ERROR_LEVEL_HINT = 1,
DJI_HMS_ERROR_LEVEL_WARN = 2,
DJI_HMS_ERROR_LEVEL_CRITICAL = 3,
DJI_HMS_ERROR_LEVEL_FATAL = 4,
Message Specifications for HMS Customization
Configuring message information needs to follow the guidelines. When an error code is reported, Pilot 2 parses the custom HMS configuration to obtain the message corresponding to the error code. If the configuration does not conform to the specifications, the message will not be displayed.
- hms_position_desc: Specifies the payload location
- hms_error_code_list: Specifies error code list
- hms_error_code: Specifies custom error code. Available range is 0x1E020000 - 0x1E02FFFF
- hms_interface: Specifies the error message displayed on the HMS interface of Pilot 2
- message_title: Specifies the message title displayed on the HMS interface of Pilot 2
- message_content: Specifies the message content displayed on the HMS interface of Pilot 2
- fpv_interface: Specifies the error message displayed on the camera view Pilot 2
- message_on_the_ground: Specifies the error message displayed on the camera view Pilot 2 when the aircraft is on the ground
- is_keep_history_on_the_ground: Specifies whether to keep a record of reported error codes when the aircraft is on the ground
- message_in_the_sky: Specifies the error message displayed on the camera view of Pilot 2 when the aircraft is in the sky
- is_keep_history_in_the_sky: Specifies whether to keep a record of reported error codes when the aircraft is in the sky
"hms_database": {
"hms_position_desc": "Payload%position_index",
"hms_error_code_list": [
{
"hms_error_code": "0x1E020000",
"hms_interface": {
"message_title": "HMS test text: I am error code Title 0",
"message_content": "HMS test text: I am error code Content 0"
},
"fpv_interface": {
"message_on_the_ground": "HMS test text: I got error on the ground 0",
"is_keep_history_on_the_ground": false,
"message_in_the_sky": "HMS test text: I got error in the sky 0",
"is_keep_history_in_the_sky": false
}
}
]
}
For example, the message title and content displayed on the HMS interface of Pilot 2 are shown in the figure below.
For example, when the aircraft is on the ground, the message and error code displayed on the camera view of Pilot 2 are shown in the figure below.
Using HMS Customization
1. Initialize HMS Customization Module
Before using the related interfaces of the HMS customization, you need to call the DjiHmsCustomization_Init
interface to initialize the HMS customization module.
returnCode = DjiHmsCustomization_Init();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Hms init error, error code:0x%08llX", returnCode);
return returnCode;
}
2. Register Message Configuration
When developing payload devices on Linux and RTOS systems, developers need to register the configuration for HMS customization. For example, developers need to register the default message configuration and the configuration files applied to different system languages. Therefore, Pilot 2 can obtain message configuration and correctly display the message.
Register Message Configuration (Linux)
//Step 2: Set hms text Config (Linux environment)
returnCode = DjiUserUtil_GetCurrentFileDirPath(__FILE__, HMS_DIR_PATH_LEN_MAX, curFileDirPath);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get file current path error, stat = 0x%08llX", returnCode);
return returnCode;
}
if (s_isHmsConfigFileDirPathConfigured == true) {
snprintf(tempPath, HMS_DIR_PATH_LEN_MAX, "%shms_text/en", s_hmsConfigFileDirPath);
} else {
snprintf(tempPath, HMS_DIR_PATH_LEN_MAX, "%shms_text/en", curFileDirPath);
}
//Set default hms text config path
returnCode = DjiHmsCustomization_RegDefaultHmsTextConfigByDirPath(tempPath);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Add default hms text config error, stat = 0x%08llX", returnCode);
return returnCode;
}
//Set hms text config for English language
returnCode = DjiHmsCustomization_RegHmsTextConfigByDirPath(DJI_MOBILE_APP_LANGUAGE_ENGLISH,
tempPath);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Add hms text config error, stat = 0x%08llX", returnCode);
return returnCode;
}
//Set hms text config for Chinese language
if (s_isHmsConfigFileDirPathConfigured == true) {
snprintf(tempPath, HMS_DIR_PATH_LEN_MAX, "%shms_text/cn", s_hmsConfigFileDirPath);
} else {
snprintf(tempPath, HMS_DIR_PATH_LEN_MAX, "%shms_text/cn", curFileDirPath);
}
returnCode = DjiHmsCustomization_RegHmsTextConfigByDirPath(DJI_MOBILE_APP_LANGUAGE_CHINESE,
tempPath);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Add hms text config error, stat = 0x%08llX", returnCode);
return returnCode;
}
Register Message Configuration (RTOS)
//Step 2 : Set hms text Config (RTOS environment)
T_DjiHmsBinaryArrayConfig enHmsTextBinaryArrayConfig = {
.binaryArrayCount = sizeof(s_EnHmsTextConfigFileBinaryArrayList) / sizeof(T_DjiHmsFileBinaryArray),
.fileBinaryArrayList = s_EnHmsTextConfigFileBinaryArrayList
};
//Set default hms text config
returnCode = DjiHmsCustomization_RegDefaultHmsTextConfigByBinaryArray(&enHmsTextBinaryArrayConfig);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Add default hms text config error, stat = 0x%08llX", returnCode);
return returnCode;
}
3. Report HMS Error Codes
Custom HMS error codes can be reported by calling the DjiHmsCustomization_InjectHmsErrorCode
interface. When an error occurs in the PSDK devices, developers can obtain the error code and the corresponding message on Pilot 2 in real time.
DjiHmsCustomization_InjectHmsErrorCode(0x1E020000, DJI_HMS_ERROR_LEVEL_FATAL);
DjiHmsCustomization_InjectHmsErrorCode(0x1E020001, DJI_HMS_ERROR_LEVEL_CRITICAL);
DjiHmsCustomization_InjectHmsErrorCode(0x1E020002, DJI_HMS_ERROR_LEVEL_WARN);
DjiHmsCustomization_InjectHmsErrorCode(0x1E020003, DJI_HMS_ERROR_LEVEL_HINT);
4. Report HMS Error Codes
Note: Once reported, the HMS error codes will continue to be displayed on Pilot 2. To clear the display, developers need to call the
DjiHmsCustomization_EliminateHmsErrorCode
interface.
Developers can clear the custom error codes of the PSDK device displayed on Pilot 2 by calling the DjiHmsCustomization_EliminateHmsErrorCode
interface.
DjiHmsCustomization_EliminateHmsErrorCode(0x1E020000);
DjiHmsCustomization_EliminateHmsErrorCode(0x1E020001);
DjiHmsCustomization_EliminateHmsErrorCode(0x1E020002);
DjiHmsCustomization_EliminateHmsErrorCode(0x1E020003);