FIX: fix the usb bulk crash bug and other issues
Signed-off-by: DJI-Martin <DJI-Martin@dji.com>
This commit is contained in:
@ -269,7 +269,9 @@ void DjiUser_RunStereoVisionViewSample(void)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#ifdef OPEN_CV_INSTALLED
|
||||
cv::destroyAllWindows();
|
||||
#endif
|
||||
}
|
||||
|
||||
DestroyTask:
|
||||
|
@ -52,13 +52,16 @@
|
||||
#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*/
|
||||
/* 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)
|
||||
|
||||
/* The speaker initialization parameters */
|
||||
#define WIDGET_SPEAKER_DEFAULT_VOLUME (50)
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
|
||||
/* Private values -------------------------------------------------------------*/
|
||||
@ -122,6 +125,28 @@ T_DjiReturnCode DjiTest_WidgetSpeakerStartService(void)
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
returnCode = osalHandler->MutexLock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("lock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
s_speakerState.state = DJI_WIDGET_SPEAKER_STATE_IDEL;
|
||||
s_speakerState.workMode = DJI_WIDGET_SPEAKER_WORK_MODE_VOICE;
|
||||
s_speakerState.playMode = DJI_WIDGET_SPEAKER_PLAY_MODE_SINGLE_PLAY;
|
||||
|
||||
returnCode = osalHandler->MutexUnlock(s_speakerMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("unlock mutex error: 0x%08llX.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
returnCode = SetVolume(WIDGET_SPEAKER_DEFAULT_VOLUME);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Set speaker volume 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) {
|
||||
@ -633,6 +658,7 @@ static T_DjiReturnCode ReceiveAudioData(E_DjiWidgetTransmitDataEvent event,
|
||||
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");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
DjiTest_DecodeAudioData();
|
||||
|
@ -30,7 +30,10 @@
|
||||
#define LINUX_USB_BULK_TRANSFER_TIMEOUT_MS (50)
|
||||
#define LINUX_USB_BULK_TRANSFER_WAIT_FOREVER (-1)
|
||||
|
||||
#define LINUX_USB_BULK_DEV1 "/dev/usb-ffs/bulk"
|
||||
#define LINUX_USB_BULK_EP_OUT "/dev/usb-ffs/bulk/ep1"
|
||||
#define LINUX_USB_BULK_EP_IN "/dev/usb-ffs/bulk/ep2"
|
||||
#define LINUX_USB_PID (0x0955)
|
||||
#define LINUX_USB_VID (0x7020)
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
@ -80,12 +83,12 @@ T_DjiReturnCode HalUsbBulk_Init(T_DjiHalUsbBulkInfo usbBulkInfo, T_DjiUsbBulkHan
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->handle = handle;
|
||||
memcpy(&((T_HalUsbBulkObj *) *usbBulkHandle)->usbBulkInfo, &usbBulkInfo, sizeof(usbBulkInfo));
|
||||
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep1 = open("/dev/usb-ffs/bulk/ep1", O_RDWR);
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep1 = open(LINUX_USB_BULK_EP_OUT, O_RDWR);
|
||||
if (((T_HalUsbBulkObj *) *usbBulkHandle)->ep1 < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 = open("/dev/usb-ffs/bulk/ep2", O_RDWR);
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 = open(LINUX_USB_BULK_EP_IN, O_RDWR);
|
||||
if (((T_HalUsbBulkObj *) *usbBulkHandle)->ep2 < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
@ -177,19 +180,9 @@ T_DjiReturnCode HalUsbBulk_ReadData(T_DjiUsbBulkHandle usbBulkHandle, uint8_t *b
|
||||
|
||||
T_DjiReturnCode HalUsbBulk_GetDeviceInfo(T_DjiHalUsbBulkDeviceInfo *deviceInfo)
|
||||
{
|
||||
//attention: need confirm your usb config in device mode.
|
||||
deviceInfo->vid = 0x0955;
|
||||
deviceInfo->pid = 0x7020;
|
||||
|
||||
deviceInfo->bulkChannelNum = 2;
|
||||
|
||||
deviceInfo->channelInfo[0].interfaceNum = 0;
|
||||
deviceInfo->channelInfo[0].endPointIn = 0x01;
|
||||
deviceInfo->channelInfo[0].endPointOut = 0x81;
|
||||
|
||||
deviceInfo->channelInfo[1].interfaceNum = 0;
|
||||
deviceInfo->channelInfo[1].endPointIn = 0x02;
|
||||
deviceInfo->channelInfo[1].endPointOut = 0x82;
|
||||
//attention: this interface only be called in usb device mode.
|
||||
deviceInfo->vid = LINUX_USB_VID;
|
||||
deviceInfo->pid = LINUX_USB_PID;
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -162,127 +162,127 @@ void DjiUser_StartTask(void const *argument)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_POWER_MANAGEMENT_ON
|
||||
T_DjiTestApplyHighPowerHandler applyHighPowerHandler = {
|
||||
.pinInit = DjiTest_HighPowerApplyPinInit,
|
||||
.pinWrite = DjiTest_WriteHighPowerApplyPin,
|
||||
};
|
||||
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_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");
|
||||
}
|
||||
returnCode = DjiTest_PowerManagementStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("power management init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_CAMERA_ON
|
||||
returnCode = DjiTest_CameraEmuBaseStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("camera emu common init error");
|
||||
goto out;
|
||||
}
|
||||
returnCode = DjiTest_CameraEmuBaseStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("camera emu common init error");
|
||||
goto out;
|
||||
}
|
||||
#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 sample init error");
|
||||
}
|
||||
returnCode = DjiTest_WidgetInteractionStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget sample init error");
|
||||
}
|
||||
#else
|
||||
returnCode = DjiTest_WidgetStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget sample init error");
|
||||
}
|
||||
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
|
||||
returnCode = DjiTest_DataTransmissionStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget sample init error");
|
||||
}
|
||||
returnCode = DjiTest_DataTransmissionStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget sample 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");
|
||||
}
|
||||
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) {
|
||||
if (DjiTest_GimbalStartService() != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("psdk gimbal init error");
|
||||
}
|
||||
if (aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V2) {
|
||||
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");
|
||||
}
|
||||
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_PAYLOAD_COLLABORATION_ON
|
||||
if (aircraftInfoBaseInfo.mountPosition != DJI_MOUNT_POSITION_EXTENSION_PORT) {
|
||||
returnCode = DjiTest_PayloadCollaborationStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Payload collaboration sample init error\n");
|
||||
}
|
||||
if (aircraftInfoBaseInfo.mountPosition != DJI_MOUNT_POSITION_EXTENSION_PORT) {
|
||||
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_TIME_SYNC_ON
|
||||
T_DjiTestTimeSyncHandler testTimeSyncHandler = {
|
||||
.PpsSignalResponseInit = DjiTest_PpsSignalResponseInit,
|
||||
.GetNewestPpsTriggerLocalTimeUs = DjiTest_GetNewestPpsTriggerLocalTimeUs,
|
||||
};
|
||||
T_DjiTestTimeSyncHandler testTimeSyncHandler = {
|
||||
.PpsSignalResponseInit = DjiTest_PpsSignalResponseInit,
|
||||
.GetNewestPpsTriggerLocalTimeUs = DjiTest_GetNewestPpsTriggerLocalTimeUs,
|
||||
};
|
||||
|
||||
if (DjiTest_TimeSyncRegHandler(&testTimeSyncHandler) != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("regsiter time sync handler error");
|
||||
goto out;
|
||||
}
|
||||
if (DjiTest_TimeSyncRegHandler(&testTimeSyncHandler) != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("regsiter time sync handler error");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (DjiTest_TimeSyncStartService() != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("psdk time sync init error");
|
||||
}
|
||||
if (DjiTest_TimeSyncStartService() != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("psdk time sync init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_POSITIONING_ON
|
||||
if (DjiTest_PositioningStartService() != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("psdk positioning init error");
|
||||
}
|
||||
if (DjiTest_PositioningStartService() != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("psdk positioning init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_UPGRADE_ON
|
||||
T_DjiTestUpgradePlatformOpt stm32UpgradePlatformOpt = {
|
||||
.rebootSystem = DjiUpgradePlatformStm32_RebootSystem,
|
||||
.cleanUpgradeProgramFileStoreArea = DjiUpgradePlatformStm32_CleanUpgradeProgramFileStoreArea,
|
||||
.createUpgradeProgramFile = DjiUpgradePlatformStm32_CreateUpgradeProgramFile,
|
||||
.writeUpgradeProgramFile = DjiUpgradePlatformStm32_WriteUpgradeProgramFile,
|
||||
.readUpgradeProgramFile = DjiUpgradePlatformStm32_ReadUpgradeProgramFile,
|
||||
.closeUpgradeProgramFile = DjiUpgradePlatformStm32_CloseUpgradeProgramFile,
|
||||
.replaceOldProgram = DjiUpgradePlatformStm32_ReplaceOldProgram,
|
||||
.setUpgradeRebootState = DjiUpgradePlatformStm32_SetUpgradeRebootState,
|
||||
.getUpgradeRebootState = DjiUpgradePlatformStm32_GetUpgradeRebootState,
|
||||
.cleanUpgradeRebootState = DjiUpgradePlatformStm32_CleanUpgradeRebootState,
|
||||
};
|
||||
T_DjiTestUpgradeConfig testUpgradeConfig = {
|
||||
.firmwareVersion = {1, 0, 0, 0},
|
||||
.transferType = DJI_FIRMWARE_TRANSFER_TYPE_DCFTP,
|
||||
.needReplaceProgramBeforeReboot = false
|
||||
};
|
||||
if (DjiTest_UpgradeStartService(&stm32UpgradePlatformOpt, testUpgradeConfig) !=
|
||||
DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
printf("psdk upgrade init error");
|
||||
}
|
||||
T_DjiTestUpgradePlatformOpt stm32UpgradePlatformOpt = {
|
||||
.rebootSystem = DjiUpgradePlatformStm32_RebootSystem,
|
||||
.cleanUpgradeProgramFileStoreArea = DjiUpgradePlatformStm32_CleanUpgradeProgramFileStoreArea,
|
||||
.createUpgradeProgramFile = DjiUpgradePlatformStm32_CreateUpgradeProgramFile,
|
||||
.writeUpgradeProgramFile = DjiUpgradePlatformStm32_WriteUpgradeProgramFile,
|
||||
.readUpgradeProgramFile = DjiUpgradePlatformStm32_ReadUpgradeProgramFile,
|
||||
.closeUpgradeProgramFile = DjiUpgradePlatformStm32_CloseUpgradeProgramFile,
|
||||
.replaceOldProgram = DjiUpgradePlatformStm32_ReplaceOldProgram,
|
||||
.setUpgradeRebootState = DjiUpgradePlatformStm32_SetUpgradeRebootState,
|
||||
.getUpgradeRebootState = DjiUpgradePlatformStm32_GetUpgradeRebootState,
|
||||
.cleanUpgradeRebootState = DjiUpgradePlatformStm32_CleanUpgradeRebootState,
|
||||
};
|
||||
T_DjiTestUpgradeConfig testUpgradeConfig = {
|
||||
.firmwareVersion = {1, 0, 0, 0},
|
||||
.transferType = DJI_FIRMWARE_TRANSFER_TYPE_DCFTP,
|
||||
.needReplaceProgramBeforeReboot = false
|
||||
};
|
||||
if (DjiTest_UpgradeStartService(&stm32UpgradePlatformOpt, testUpgradeConfig) !=
|
||||
DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
printf("psdk upgrade init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
returnCode = DjiCore_ApplicationStart();
|
||||
@ -412,7 +412,7 @@ static T_DjiReturnCode DjiUser_FillInUserInfo(T_DjiUserInfo *userInfo)
|
||||
if (!strcmp(USER_APP_NAME, "your_app_name") ||
|
||||
!strcmp(USER_APP_ID, "your_app_id") ||
|
||||
!strcmp(USER_APP_KEY, "your_app_key") ||
|
||||
!strcmp(USER_BAUD_RATE, "your_app_license") ||
|
||||
!strcmp(USER_APP_LICENSE, "your_app_license") ||
|
||||
!strcmp(USER_DEVELOPER_ACCOUNT, "your_developer_account") ||
|
||||
!strcmp(USER_BAUD_RATE, "your_baud_rate")) {
|
||||
USER_LOG_ERROR(
|
||||
|
Reference in New Issue
Block a user