Power Management
Overview
When a payload device developed based on the PSDK is installed on the aircraft’s gimbal, the payload device can receive high power through a power request. Therefore, high-power payload devices must support the use of low power as well. To prevent data loss or accidental damage when the payload device is not properly shut down, the PSDK also provides the function to send a shutdown notification.
Using Power Management Features
1. Pin Control for High Power
If the payload device is connected to the aircraft through the P-Port and requires high power to function properly, you can control the A8 (SBU2) pin to a low level after the payload has completed registration to enable the aircraft to output high power. For more details, refer to Drone Hardware Interface.
2. Requesting High Power
If the payload device is connected to the aircraft via the P-Port Lite interface and requires high power to function properly, you can call the UAV_PowerManagement_ApplyHighPowerSync()
interface after the payload has registered to request high power. For more details, refer to Power Management Interface.
Note:
- The current version does not support requesting high power mode when using network communication.
Using Shutdown Notification Feature
The process of the aircraft sending a shutdown notification is as follows:
- When the aircraft receives the shutdown notification from the user, it will send a shutdown notification to the payload device developed using PSDK.
- When the payload device receives the shutdown notification from the aircraft, it will complete the necessary operations before shutdown and change the shutdown preparation status.
- When the aircraft receives the shutdown preparation status from all payload devices, it will immediately shut down.
Note:
- After receiving the shutdown notification, the aircraft will force shutdown after a certain period. The exact force shutdown time can be found in the corresponding product specification.
1. Constructing the Shutdown Status Callback Function
Once the developer has implemented the shutdown preparation function for the payload device, they need to register the function for shutdown preparation with the specified interface.
static T_UAVReturnCode UAV_PowerManagement_PowerOffNotificationCallback(bool *powerOffPreparationFlag)
{
// The function for the payload device to perform shutdown preparation
// ...
// Set shutdown preparation status
*powerOffPreparationFlag = true;
return UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
2. Register Shutdown Callback Function
After registering the function for the payload device to perform shutdown preparation, the payload device will execute the shutdown preparation action and change the shutdown preparation status upon receiving the shutdown notification:
returnCode = UAV_PowerManagement_PowerOffNotificationCallback(UAVPowerManagement_PowerOffNotificationCallback);
if(UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS != returnCode) {
LOG_INFO("register power off notification callback failed");
return returnCode;
}
3. Subscribe to Shutdown Notification
The payload can also actively subscribe to the aircraft's shutdown actions and notifications, so that the payload device can promptly perform the shutdown preparation operation when the aircraft shuts down. For details, refer to Data Subscription.
static void UAV_PowerManagement_SubscribePowerOffHandler(void *data)
{
// Handling Aircraft Shutdown Messages
}
if(UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS != UAV_Subscribe_Topic(UAV_SUBSCRIPTION_TOPIC_UAV_POWER_OFF, UAV_DATA_SUBSCRIPTION_TOPIC_20_HZ, UAV_PowerManagement_SubscribePowerOffHandler))
{
LOG_ERROR("UAV_Subscribe_Topic UAV_SUBSCRIPTION_TOPIC_UAV_POWER_OFF failed");
return;
}