A8 mini User Manual v1.5
43
2023 SIYI Technology Co., Ltd, All Rights Reserved
}
/* Set IP addresses and port number of gimbal camera
sin_family: ipv4 addresses
sin_addr.s_addr: IP addresses of gimbal camera
sin_port: port of gimbal camera
*/
memset(&send_addr, 0, sizeof(send_addr));
send_addr.sin_family = AF_INET;
send_addr.sin_addr.s_addr = inet_addr(SERVER_IP);
send_addr.sin_port = htons(SERVER_PORT);
/* Send frame data
sockfd: descriptor of socket
send_buf: head address in RAM of the sending data
sizeof(send_buf): length of sending data
0: sending mark, usually it is 0
(struct sockaddr *)&send_addr: structure pointer of the receiving data addresses
(including IP addresses and port)
addr_len: structure size of the receiving data addresses
*/
printf("Send HEX data\n");
socklen_t addr_len = sizeof(struct sockaddr_in);
if(sendto(sockfd, send_buf, sizeof(send_buf), 0, (struct sockaddr *)&send_addr, addr_len) < 0)
{
perror("sendto");
exit(1);
}
/* Receive the responding data from gimbal camera
sockfd: descriptor of “sockfd” socket
recv_buf: head address in RAM of the responding data
RECV_BUUF_SIZE: size of the buffer, which is the length of the max data to
receive
0: receiving mark, usually it is 0
(struct sockaddr *)&recv_addr: the target structure will be filled with addresses (including
IP addresses and port) from the data sender
&addr_len: the target storage position, the structure size of
“src_addr” and “addrlen” should be filled before calling, the actual size of the sender will be filled after calling
*/
recv_len = recvfrom(sockfd, recv_buf, RECV_BUUF_SIZE, 0, (struct sockaddr *)&recv_addr,
&addr_len);
if (recv_len < 0) {
perror("recvfrom");