diff --git a/samples/sample_c/module_sample/camera_emu/test_payload_cam_emu_base.c b/samples/sample_c/module_sample/camera_emu/test_payload_cam_emu_base.c index 2c9eb2b..39e395b 100644 --- a/samples/sample_c/module_sample/camera_emu/test_payload_cam_emu_base.c +++ b/samples/sample_c/module_sample/camera_emu/test_payload_cam_emu_base.c @@ -119,6 +119,13 @@ static uint32_t s_tapZoomNewestTargetHybridFocalLength = 0; // unit: 0.1mm static T_DjiMutexHandle s_tapZoomMutex = NULL; static E_DjiCameraVideoStreamType s_cameraVideoStreamType; +static int sockfd; +static struct sockaddr_in server; +static struct sockaddr_in client; +static socklen_t addrlen; + +char s_positionMessage[100]=" "; + /* Private functions declaration ---------------------------------------------*/ //用于s_commonHandler中的回调函数:相机类基础功能 static T_DjiReturnCode GetSystemState(T_DjiCameraSystemState *systemState); @@ -587,6 +594,9 @@ static T_DjiReturnCode SetFocusTarget(T_DjiCameraPointInScreen target) USER_LOG_INFO("set focus target x:%.2f y:%.2f", target.focusX, target.focusY); memcpy(&s_cameraFocusTarget, &target, sizeof(T_DjiCameraPointInScreen)); + sprintf(s_positionMessage, "%.2f,%.2f", target.focusX, target.focusY); + sendto(sockfd, s_positionMessage, strlen(s_positionMessage), 0, (struct sockaddr *)&server, sizeof(server)); + return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS; } @@ -1399,6 +1409,15 @@ T_DjiReturnCode DjiTest_CameraEmuBaseStartService(void) s_isCamInited = true; + // 创建UDP套接字 + if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { + perror("Creatingsocket failed."); + } + bzero(&server, sizeof(server)); + server.sin_family = AF_INET; + server.sin_port = htons(POSITION_PORT_RLX); + server.sin_addr.s_addr = htonl(INADDR_ANY); + return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS; } diff --git a/samples/sample_c/module_sample/camera_emu/test_payload_cam_emu_base.h b/samples/sample_c/module_sample/camera_emu/test_payload_cam_emu_base.h index 5601b8d..578b554 100644 --- a/samples/sample_c/module_sample/camera_emu/test_payload_cam_emu_base.h +++ b/samples/sample_c/module_sample/camera_emu/test_payload_cam_emu_base.h @@ -31,6 +31,13 @@ #include "dji_typedef.h" #include "dji_payload_camera.h" +#include +#include +#include +#include + +#define POSITION_PORT_RLX 20005 + #ifdef __cplusplus extern "C" { #endif