First, confirm which PSDK link is used. If you are using the Manifold2 project, then in the payload-sdk\samples\sample_c\platform\linux\manifold2\application\dji_sdk_config.h file.
Check the setting of CONFIG_HARDWARE_CONNECTION.
The video stream function must be configured as BULK or NETWORK. It is recommended to use a USB network card for NETWORK. Currently, only AX88179 and RTL8152 models are supported. Other models of network cards are not supported. Developers who have used these models are advised to directly check the bottom component version confirmation steps.
Take BULK as an example:
From the environment troubleshooting, first check whether the bulk node is pulled up normally. If the official bulk configuration script is used, the command should be able to search for two nodes.
If you cannot search for two nodes, refer to this article to reconfigure: Linux平台配置BULK
After confirming that two bulk nodes are generated, you can use the following script to test the data transmission and reception of the BULK node to see if it is normal. (If you don't want to do too complicated tests, you can jump to the bottom and check the last step)
Among them, your_VID, your_PID and node information can be confirmed through this article. It should be noted that the tested node must be consistent with the node information configured in PSDK. PSDK代码中的BULK节点配置
gcc -o bulk_device bulk-device.c -I/usr/include -lusb-1.0 -lpthread
bulk-device.c
#include "stdint.h"
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <libusb-1.0/libusb.h>
#include "pthread.h"
void device_Thread()
{
int32_t ret;
int32_t ep1, ep2;
int32_t actualLen, len;
char sendbuf[] = "USB bulk device data ...";
char readbuf[128] = {0};
//device bulk
ep1 = open("/dev/usb-ffs/bulk/ep1", O_RDWR);
if (ep1 < 0)
{
printf("open ep1 failed, ret[%d]", ret);
return -1;
}
ep2 = open("/dev/usb-ffs/bulk/ep2", O_RDWR);
if (ep2 < 0)
{
printf("open ep2 failed, ret[%d]", ret);
return -1;
}
while(1)
{
//read
actualLen = read(ep2, (uint8_t *)&readbuf[0], 128);
if (actualLen < 0)
{
printf("USB device read failed[%d]\n",actualLen);
}
else
{
printf("USB device recive data\t\t[%s], \tlen[%d]\n", (uint8_t *)&readbuf[0], actualLen);
//send
actualLen = write(ep1, &sendbuf[0], strlen(sendbuf));
//printf("device send ... \n");
}
sleep(1);
}
close(ep1);
close(ep2);
return;
}
int main()
{
int32_t ret;
int32_t actualLen, len;
static pthread_t deviceThread = 0;
struct libusb_device_handle *handle = NULL;
char sendbuf[] = "USB bulk host data ...";
char readbuf[128] = {0};
//host libusb
//char sendbuf[] = "bulk linker loop";
//char readbuf[128] = {0};
ret = libusb_init(NULL);
if (ret < 0) {
printf("libusb_init failed\n");
return -1;
}
handle = libusb_open_device_with_vid_pid(NULL, your_VID, your_PID);
if (handle == NULL) {
printf("libusb_open_device_with_vid_pid failed\n");
return -1;
}
ret = libusb_claim_interface(handle, 2);//Num
if (ret != LIBUSB_SUCCESS) {
printf("libusb claim interface error, ret[%d]\n", ret);
libusb_close(handle);
return -1;
}
if (pthread_create(&deviceThread, NULL, device_Thread, NULL) != 0) {
printf("create monitor task fail.\n");
return -1;
}
sleep(2);
//send
ret = libusb_bulk_transfer(handle, 0x0*, (uint8_t *) sendbuf, strlen(sendbuf), &actualLen, 50);
if (ret < 0) {
printf("libusb_bulk_transfer send failed[%d], endpointOut[%x], len[%d]\n",ret, 0x0*, strlen(sendbuf));
//return -1;
}
while(1)
{
//read
memset(&readbuf[0], 0x0, sizeof(readbuf));
ret = libusb_bulk_transfer(handle, 0x**, &readbuf[0], 128, &actualLen, 50);
//printf("libusb_bulk_transfer read_len[%d], ret[%d]\n", actualLen, ret);
if (0 == ret)
printf("USB host recive data\t\t[%s], \tread_len[%d]\n", &readbuf[0], actualLen);
sleep(2);
ret = libusb_bulk_transfer(handle, 0x0*, (uint8_t *) sendbuf, strlen(sendbuf), &actualLen, 50);
if (ret < 0) {
printf("USB host send failed[%d]\n",ret);
//return -1;
}
}
return 0;
}
If there is no problem in sending and receiving test data, you can proceed to the next step to check the version and configuration of FFMPEG and OPENCV.
Component version confirmation:
The ffmpeg version and configuration used for local debugging are:
ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10 (Debian 10.2.1-6)
configuration: --enable-shared --enable-swscale --enable-gpl --enable-nonfree --enable-pic --enable-version3 --enable-postproc --enable-pthreads --enable-static --enable-libvorbis --enable-libvpx
rsp@CUBE:~$ opencv_version
4.9.0
In addition, if the LIBUSB component is not installed, it will also affect the normal use of this function. You can confirm it when using the cmake .. command. If it is not installed, you can use the following command to install it:
sudo apt update
sudo apt install libusb-1.0-0-dev
Verify that the installation is complete: dpkg -l | grep libusb
Problems that may be encountered:
1. Error
[167.697][core]-[Error]-[DjiLiveview_FindLiveviewSource:1165) Can not found the liveview source. Probably the payload is not mounted on position 0 correctly. Please check the mount position of payload.
[167.697][liveview]-[Error]-[DjiLiveview_StartH264Stream:546) Can't find source, errno: 0x00000100.
This means that there is no DJI payload camera mounted at position 0. You need to check whether the mounting position corresponds to the value called by the code. The code position 0/1/2 corresponds to the actual position facing the front of the aircraft, the lower right position of the fuselage (0), the lower left position of the fuselage (1), and the upper position of the fuselage (2).
2. If the above information is correct and the video stream still cannot be obtained, you can add some prints where the code is called to see where the code is stuck. We recommend using the project of Miaosuan 2. Other projects may not be updated in time or not maintained for a long time. In order to avoid the impact of known problems, it is recommended to use the project of Miaosuan 2.
3. Regarding link testing, there is another way to use DjiTest_LiveviewRunSample(1); to test. Just add a call directly in main.c.
Then add printing to the two callbacks DjiTest_FpvCameraStreamCallback and DjiTest_PayloadCameraStreamCallback in the payload-sdk\samples\sample_c\module_sample\liveview\test_liveview.c file. If these two callback functions are entered and a video stream file with the suffix .h264 is generated in the current directory, it means that there is no problem with the link to obtain the video stream. At this time, you can focus on troubleshooting problems related to the software environment.
Comments
0 comments
Please sign in to leave a comment.