NEW: release DJI Payload-SDK version 3.2
Signed-off-by: DJI-Martin <DJI-Martin@dji.com>
This commit is contained in:
34
samples/sample_c/platform/linux/common/3rdparty/FindLIBUSB.cmake
vendored
Normal file
34
samples/sample_c/platform/linux/common/3rdparty/FindLIBUSB.cmake
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
#
|
||||
# Find the native LIBUSB includes and library
|
||||
#
|
||||
# This module defines
|
||||
# LIBUSB_INCLUDE_DIR, where to find libusb.h
|
||||
# LIBUSB_LIBRARY, the libraries to link against to use LIBUSB.
|
||||
# LIBUSB_FOUND, If false, do not try to use LIBUSB.
|
||||
|
||||
FIND_PATH(LIBUSB_INCLUDE_DIR libusb.h
|
||||
PATHS
|
||||
/usr/local/include/libusb-1.0
|
||||
/usr/include/libusb-1.0
|
||||
/opt/local/include
|
||||
/opt/include
|
||||
)
|
||||
|
||||
get_filename_component(LIBUSB_INCLUDE_DIR ${LIBUSB_INCLUDE_DIR} ABSOLUTE)
|
||||
|
||||
FIND_LIBRARY(LIBUSB_LIBRARY usb-1.0
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
)
|
||||
|
||||
IF (LIBUSB_INCLUDE_DIR)
|
||||
IF (LIBUSB_LIBRARY)
|
||||
SET(LIBUSB_FOUND "YES")
|
||||
ENDIF (LIBUSB_LIBRARY)
|
||||
ENDIF (LIBUSB_INCLUDE_DIR)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
LIBUSB_INCLUDE_DIR
|
||||
LIBUSB_LIBRARY
|
||||
LIBUSB_FOUND
|
||||
)
|
34
samples/sample_c/platform/linux/common/3rdparty/FindOPUS.cmake
vendored
Normal file
34
samples/sample_c/platform/linux/common/3rdparty/FindOPUS.cmake
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
#
|
||||
# Find the native OPUS includes and library
|
||||
#
|
||||
# This module defines
|
||||
# OPUS_INCLUDE_DIR, where to find opus.h
|
||||
# OPUS_LIBRARY, the libraries to link against to use OPUS.
|
||||
# OPUS_FOUND, If false, do not try to use OPUS.
|
||||
|
||||
FIND_PATH(OPUS_INCLUDE_DIR opus.h
|
||||
PATHS
|
||||
/usr/local/include/opus
|
||||
/usr/include/opus
|
||||
/opt/local/include
|
||||
/opt/include
|
||||
)
|
||||
|
||||
get_filename_component(OPUS_INCLUDE_DIR ${OPUS_INCLUDE_DIR} ABSOLUTE)
|
||||
|
||||
FIND_LIBRARY(OPUS_LIBRARY opus
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
)
|
||||
|
||||
IF (OPUS_INCLUDE_DIR)
|
||||
IF (OPUS_LIBRARY)
|
||||
SET(OPUS_FOUND "YES")
|
||||
ENDIF (OPUS_LIBRARY)
|
||||
ENDIF (OPUS_INCLUDE_DIR)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
OPUS_INCLUDE_DIR
|
||||
OPUS_LIBRARY
|
||||
OPUS_FOUND
|
||||
)
|
@ -30,6 +30,10 @@
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
|
||||
/* Private values -------------------------------------------------------------*/
|
||||
static uint32_t s_localTimeMsOffset = 0;
|
||||
static uint64_t s_localTimeUsOffset = 0;
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
@ -279,6 +283,12 @@ T_DjiReturnCode Osal_GetTimeMs(uint32_t *ms)
|
||||
gettimeofday(&time, NULL);
|
||||
*ms = (time.tv_sec * 1000 + time.tv_usec / 1000);
|
||||
|
||||
if (s_localTimeMsOffset == 0) {
|
||||
s_localTimeMsOffset = *ms;
|
||||
} else {
|
||||
*ms = *ms - s_localTimeMsOffset;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@ -289,6 +299,12 @@ T_DjiReturnCode Osal_GetTimeUs(uint64_t *us)
|
||||
gettimeofday(&time, NULL);
|
||||
*us = (time.tv_sec * 1000000 + time.tv_usec);
|
||||
|
||||
if (s_localTimeUsOffset == 0) {
|
||||
s_localTimeUsOffset = *us;
|
||||
} else {
|
||||
*us = *us - s_localTimeMsOffset;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,33 @@ add_executable(${PROJECT_NAME}
|
||||
${MODULE_SAMPLE_SRC}
|
||||
${MODULE_COMMON_SRC}
|
||||
${MODULE_HAL_SRC})
|
||||
target_link_libraries(${PROJECT_NAME} m usb-1.0)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../common/3rdparty)
|
||||
find_package(OPUS REQUIRED)
|
||||
if (OPUS_FOUND)
|
||||
message(STATUS "Found OPUS installed in the system")
|
||||
message(STATUS " - Includes: ${OPUS_INCLUDE_DIR}")
|
||||
message(STATUS " - Libraries: ${OPUS_LIBRARY}")
|
||||
|
||||
add_definitions(-DOPUS_INSTALLED)
|
||||
target_link_libraries(${PROJECT_NAME} /usr/local/lib/libopus.a)
|
||||
else ()
|
||||
message(STATUS "Cannot Find OPUS")
|
||||
endif (OPUS_FOUND)
|
||||
|
||||
find_package(LIBUSB REQUIRED)
|
||||
if (LIBUSB_FOUND)
|
||||
message(STATUS "Found LIBUSB installed in the system")
|
||||
message(STATUS " - Includes: ${LIBUSB_INCLUDE_DIR}")
|
||||
message(STATUS " - Libraries: ${LIBUSB_LIBRARY}")
|
||||
|
||||
add_definitions(-DLIBUSB_INSTALLED)
|
||||
target_link_libraries(${PROJECT_NAME} usb-1.0)
|
||||
else ()
|
||||
message(STATUS "Cannot Find LIBUSB")
|
||||
endif (LIBUSB_FOUND)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} m)
|
||||
|
||||
add_custom_command(TARGET ${PROJECT_NAME}
|
||||
PRE_LINK COMMAND cmake ..
|
||||
|
@ -162,6 +162,11 @@ int main(int argc, char **argv)
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget interaction sample init error");
|
||||
}
|
||||
|
||||
returnCode = DjiTest_WidgetSpeakerStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget speaker test init error");
|
||||
}
|
||||
} else {
|
||||
#ifdef CONFIG_MODULE_SAMPLE_CAMERA_EMU_ON
|
||||
returnCode = DjiTest_CameraEmuBaseStartService();
|
||||
@ -216,11 +221,9 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE_SAMPLE_WIDGET_SPEAKER_ON
|
||||
if (aircraftInfoBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_NONE) {
|
||||
returnCode = DjiTest_WidgetSpeakerStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget speaker test init error");
|
||||
}
|
||||
returnCode = DjiTest_WidgetSpeakerStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget speaker test init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -32,12 +32,16 @@
|
||||
|
||||
#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)
|
||||
#define LINUX_USB_PID (0x7020)
|
||||
#define LINUX_USB_VID (0x0955)
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
#ifdef LIBUSB_INSTALLED
|
||||
libusb_device_handle *handle;
|
||||
#else
|
||||
void *handle;
|
||||
#endif
|
||||
int32_t ep1;
|
||||
int32_t ep2;
|
||||
T_DjiHalUsbBulkInfo usbBulkInfo;
|
||||
@ -59,6 +63,7 @@ T_DjiReturnCode HalUsbBulk_Init(T_DjiHalUsbBulkInfo usbBulkInfo, T_DjiUsbBulkHan
|
||||
}
|
||||
|
||||
if (usbBulkInfo.isUsbHost == true) {
|
||||
#ifdef LIBUSB_INSTALLED
|
||||
ret = libusb_init(NULL);
|
||||
if (ret < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
@ -78,7 +83,7 @@ T_DjiReturnCode HalUsbBulk_Init(T_DjiHalUsbBulkInfo usbBulkInfo, T_DjiUsbBulkHan
|
||||
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->handle = handle;
|
||||
memcpy(&((T_HalUsbBulkObj *) *usbBulkHandle)->usbBulkInfo, &usbBulkInfo, sizeof(usbBulkInfo));
|
||||
|
||||
#endif
|
||||
} else {
|
||||
((T_HalUsbBulkObj *) *usbBulkHandle)->handle = handle;
|
||||
memcpy(&((T_HalUsbBulkObj *) *usbBulkHandle)->usbBulkInfo, &usbBulkInfo, sizeof(usbBulkInfo));
|
||||
@ -109,9 +114,11 @@ T_DjiReturnCode HalUsbBulk_DeInit(T_DjiUsbBulkHandle usbBulkHandle)
|
||||
handle = ((T_HalUsbBulkObj *) usbBulkHandle)->handle;
|
||||
|
||||
if (((T_HalUsbBulkObj *) usbBulkHandle)->usbBulkInfo.isUsbHost == true) {
|
||||
#ifdef LIBUSB_INSTALLED
|
||||
libusb_release_interface(handle, ((T_HalUsbBulkObj *) usbBulkHandle)->usbBulkInfo.channelInfo.interfaceNum);
|
||||
osalHandler->TaskSleepMs(100);
|
||||
libusb_exit(NULL);
|
||||
#endif
|
||||
} else {
|
||||
close(((T_HalUsbBulkObj *) usbBulkHandle)->ep1);
|
||||
close(((T_HalUsbBulkObj *) usbBulkHandle)->ep2);
|
||||
@ -136,18 +143,21 @@ T_DjiReturnCode HalUsbBulk_WriteData(T_DjiUsbBulkHandle usbBulkHandle, const uin
|
||||
handle = ((T_HalUsbBulkObj *) usbBulkHandle)->handle;
|
||||
|
||||
if (((T_HalUsbBulkObj *) usbBulkHandle)->usbBulkInfo.isUsbHost == true) {
|
||||
#ifdef LIBUSB_INSTALLED
|
||||
ret = libusb_bulk_transfer(handle, ((T_HalUsbBulkObj *) usbBulkHandle)->usbBulkInfo.channelInfo.endPointOut,
|
||||
(uint8_t *) buf, len, &actualLen, LINUX_USB_BULK_TRANSFER_TIMEOUT_MS);
|
||||
if (ret < 0) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
USER_LOG_ERROR("Write usb bulk data failed, errno = %d", ret);
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
*realLen = actualLen;
|
||||
#endif
|
||||
} else {
|
||||
*realLen = write(((T_HalUsbBulkObj *) usbBulkHandle)->ep1, buf, len);
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode HalUsbBulk_ReadData(T_DjiUsbBulkHandle usbBulkHandle, uint8_t *buf, uint32_t len,
|
||||
@ -164,13 +174,16 @@ T_DjiReturnCode HalUsbBulk_ReadData(T_DjiUsbBulkHandle usbBulkHandle, uint8_t *b
|
||||
handle = ((T_HalUsbBulkObj *) usbBulkHandle)->handle;
|
||||
|
||||
if (((T_HalUsbBulkObj *) usbBulkHandle)->usbBulkInfo.isUsbHost == true) {
|
||||
#ifdef LIBUSB_INSTALLED
|
||||
ret = libusb_bulk_transfer(handle, ((T_HalUsbBulkObj *) usbBulkHandle)->usbBulkInfo.channelInfo.endPointIn,
|
||||
buf, len, &actualLen, LINUX_USB_BULK_TRANSFER_WAIT_FOREVER);
|
||||
if (ret < 0) {
|
||||
USER_LOG_ERROR("Read usb bulk data failed, errno = %d", ret);
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
*realLen = actualLen;
|
||||
#endif
|
||||
} else {
|
||||
*realLen = read(((T_HalUsbBulkObj *) usbBulkHandle)->ep2, buf, len);
|
||||
}
|
||||
|
@ -38,10 +38,13 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#include "dji_platform.h"
|
||||
|
||||
#ifdef LIBUSB_INSTALLED
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user