【问题标题】:On Raspberry Pi 4 with Ubuntu 22.04 don't work ioctl在带有 Ubuntu 22.04 的 Raspberry Pi 4 上不工作 ioctl
【发布时间】:2022-09-07 23:14:40
【问题描述】:

我安装了 OS Ubuntu 22.04 LTS 64 位的 Raspberry Pi 4 (aarch64 Cortex-A72)。我尝试从网络摄像头英特尔实感 ID 解决方案 F455 读取帧。

buffer V4lNode::Read()
{
    buffer res;
    struct v4l2_buffer buf = {0};
    struct timeval tv = {0}; 
    tv.tv_sec = 0; // max time to wait for next frame
    tv.tv_usec =100;

    buf.type = _type;
    buf.memory = V4L2_MEMORY_MMAP;
    buf.index = 0;

    fd_set fds;
    FD_ZERO(&fds);
    FD_SET(_fd, &fds);
    ThrowIfFailed("wait for frame", select(_fd, &fds, NULL, NULL, &tv));

    if (ioctl(_fd, VIDIOC_DQBUF, &buf) == FAILED_V4L){ // dequeue frame from buffer.
        std::cout << "V4lNode failed  dequeue frame from buffer: " << strerror(errno) << std::endl;
        return res; //returns zero-length buffer
    }
    res = _buffers[buf.index];
    res.size = buf.bytesused;
    
    buf.type = _type; 
    buf.memory = V4L2_MEMORY_MMAP;
    ThrowIfFailed("qbuffer", ioctl(_fd, VIDIOC_QBUF, &buf)); // queue next frame

    return res;
}

当我运行此代码时:

if (ioctl(fd, VIDIOC_DQBUF, &buf) < 0) {
    std::cout << "V4lNode failed  dequeue frame from buffer: " << strerror(errno) << std::endl;
}

我得到输出结果:

V4lNode 从缓冲区中出列帧失败:资源暂时不可用

但设备打开成功:

fd = open(path.c_str(), O_RDWR | O_NONBLOCK, 0);
std::cout << "V4lNode open files discription: " << strerror(errno) << std::endl;

输出结果:

V4lNode打开文件说明:成功

当我在终端中运行此命令时:

pi@pi:~$ v4l2-compliance
v4l2-compliance 1.22.1, 64 bits, 64-bit time_t

Compliance test for uvcvideo device /dev/video0:

我得到错误:

Control ioctls (Input 0):
        fail: v4l2-test-controls.cpp(246): missing control class for class 00980000
    test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: FAIL

完整的 tets 输出:

pi@pi:~$ v4l2-compliance 
v4l2-compliance 1.22.1, 64 bits, 64-bit time_t

Compliance test for uvcvideo device /dev/video0:

Driver Info:
    Driver name      : uvcvideo
    Card type        : Intel F450
    Bus info         : usb-0000:01:00.0-1.1
    Driver version   : 5.15.39
    Capabilities     : 0x84a00001
        Video Capture
        Metadata Capture
        Streaming
        Extended Pix Format
        Device Capabilities
    Device Caps      : 0x04200001
        Video Capture
        Streaming
        Extended Pix Format
Media Driver Info:
    Driver name      : uvcvideo
    Model            : Intel F450
    Serial           : 00.00.01
    Bus info         : usb-0000:01:00.0-1.1
    Media version    : 5.15.39
    Hardware revision: 0x00000100 (256)
    Driver version   : 5.15.39
Interface Info:
    ID               : 0x03000002
    Type             : V4L Video
Entity Info:
    ID               : 0x00000001 (1)
    Name             : Intel F450
    Function         : V4L2 I/O
    Flags            : default
    Pad 0x01000007   : 0: Sink
      Link 0x02000010: from remote pad 0x100000a of entity 'Extension 3' (Video Pixel Formatter): Data, Enabled, Immutable

Required ioctls:
    test MC information (see 'Media Driver Info' above): OK
    test VIDIOC_QUERYCAP: OK
    test invalid ioctls: OK

Allow for multiple opens:
    test second /dev/video0 open: OK
    test VIDIOC_QUERYCAP: OK
    test VIDIOC_G/S_PRIORITY: OK
    test for unlimited opens: OK

Debug ioctls:
    test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
    test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
    test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
    test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
    test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
    test VIDIOC_ENUMAUDIO: OK (Not Supported)
    test VIDIOC_G/S/ENUMINPUT: OK
    test VIDIOC_G/S_AUDIO: OK (Not Supported)
    Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
    test VIDIOC_G/S_MODULATOR: OK (Not Supported)
    test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
    test VIDIOC_ENUMAUDOUT: OK (Not Supported)
    test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
    test VIDIOC_G/S_AUDOUT: OK (Not Supported)
    Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
    test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
    test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
    test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
    test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls (Input 0):
        fail: v4l2-test-controls.cpp(246): missing control class for class 00980000
    test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: FAIL
    test VIDIOC_QUERYCTRL: OK
    test VIDIOC_G/S_CTRL: OK
        warn: v4l2-test-controls.cpp(757): g_ext_ctrls(0) invalid error_idx 0
    test VIDIOC_G/S/TRY_EXT_CTRLS: OK
    test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
    test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
    Standard Controls: 1 Private Controls: 0

Format ioctls (Input 0):
    test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
    test VIDIOC_G/S_PARM: OK
    test VIDIOC_G_FBUF: OK (Not Supported)
    test VIDIOC_G_FMT: OK
    test VIDIOC_TRY_FMT: OK
        warn: v4l2-test-formats.cpp(1036): Could not set fmt2
    test VIDIOC_S_FMT: OK
    test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
    test Cropping: OK (Not Supported)
    test Composing: OK (Not Supported)
    test Scaling: OK (Not Supported)

Codec ioctls (Input 0):
    test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
    test VIDIOC_G_ENC_INDEX: OK (Not Supported)
    test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls (Input 0):
    test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
    test VIDIOC_EXPBUF: OK
    test Requests: OK (Not Supported)

Total for uvcvideo device /dev/video0: 46, Succeeded: 45, Failed: 1, Warnings: 2

混淆了很多笔记(Not Supported)

升级版:

输出格式:

pi@pi:~$ v4l2-ctl --list-formats
ioctl: VIDIOC_ENUM_FMT
    Type: Video Capture

    [0]: 'YUYV' (YUYV 4:2:2)

输出dmesg 错误:

[    0.823576] zswap: compressor zstd not available, using default lzo
[    0.829609] zswap: zpool z3fold not available, using default zbud
[  102.238315] uvcvideo 1-1.1:1.1: Failed to resubmit video URB (-1).
[  102.238626] uvcvideo 1-1.1:1.1: Failed to resubmit video URB (-1).
[ 5822.239686] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5822.249854] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5822.259913] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5822.269949] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5822.280057] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5822.290139] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5822.391565] usb 1-1.1: Failed to query (SET_CUR) UVC control 4 on unit 1: -32 (exp. 4).
[ 5822.401637] usb 1-1.1: Failed to query (SET_CUR) UVC control 4 on unit 1: -32 (exp. 4).
[ 5822.411679] usb 1-1.1: Failed to query (SET_CUR) UVC control 4 on unit 1: -32 (exp. 4).
[ 5822.421697] usb 1-1.1: Failed to query (SET_CUR) UVC control 4 on unit 1: -32 (exp. 4).
[ 5822.431779] usb 1-1.1: Failed to query (SET_CUR) UVC control 4 on unit 1: -32 (exp. 4).
[ 5822.441885] usb 1-1.1: Failed to query (SET_CUR) UVC control 4 on unit 1: -32 (exp. 4).
[ 5822.532650] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5822.563375] usb 1-1.1: Failed to query (SET_CUR) UVC control 4 on unit 1: -32 (exp. 4).
[ 5822.622056] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5823.168241] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5823.270367] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).

我试过这个解决方案Recording usb cam on raspberry pi with ffmpeg - usb troubleshooting - 没用

【问题讨论】:

    标签: raspberry-pi linux-kernel linux-device-driver ioctl realsense


    【解决方案1】:

    根据 Ubuntu 22 尚不支持 realsense(2022 年 9 月 7 日) https://github.com/IntelRealSense/librealsense/issues/10439

    我只能通过带有这个 Dockerfile 的 docker 在 Ubuntu 22 上运行它:

    FROM python:3.7.4
    
    WORKDIR /home
    
    ENV DEBIAN_FRONTEND=noninteractive 
    ENV TZ=Europe/Minsk
    
    RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
    
    RUN apt-get update && apt-get install -y  
        sudo  
        cmake 
        git 
        curl 
        libopencv-dev  
        libjpeg-dev  
        libpng-dev  
        libtiff-dev   
        libgtk2.0-dev  
        python-numpy  
        python-pycurl  
        keyboard-configuration 
        libgl1-mesa-dev 
        libglu1-mesa-dev 
        libusb-1.0-0-dev 
        libglfw3-dev 
        freeglut3 
        at 
        freeglut3-dev 
        nano 
        curl 
        libglfw3-dev 
        libgl1-mesa-dev 
        libglu1-mesa-dev 
        at  
        udev 
        linux-headers-* 
        libusb-1.0-0-dev 
    
    #update cmake
    RUN sudo apt remove cmake -y && 
        wget https://github.com/Kitware/CMake/releases/download/v3.23.0/cmake-3.23.0.tar.gz && 
        tar -xf cmake-3.23.0.tar.gz && 
        cd cmake-3.23.0 && 
        ./configure && 
        make -j$(nproc)  && 
        sudo make install -j$(nproc) 
    
    
    #install realsense
    RUN git clone https://github.com/IntelRealSense/librealsense && 
        cd librealsense && 
        git checkout v2.51.1 && 
        mkdir -p /etc/udev/rules.d && 
        mkdir build && cd build && 
        cmake .. && 
        make install -j$(nproc) && 
        make -j$(nproc)
    

    构建为:

    docker build -t realsense .
    

    如果您需要使用任何 GUI,请在运行容器之前运行它:

    export DISPLAY=:1
    xhost +
    

    (根据您的显示索引,您可能需要使用DISPLAY=:0

    并使用以下命令运行容器:

    sudo docker run -it --privileged -v /etc/udev/*:/etc/udev/* 
        -v /dev/bus/usb:/dev/bus/usb 
        -v /dev/:/dev/ 
        -v /tmp/.X11-unix:/tmp/.X11-unix 
        -e DISPLAY=$DISPLAY -h $HOSTNAME -v $HOME/.Xauthority:/home/.Xauthority realsense:latest bash
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-13
      • 1970-01-01
      • 2022-08-15
      • 1970-01-01
      • 2021-03-11
      • 1970-01-01
      • 2020-10-16
      • 1970-01-01
      相关资源
      最近更新 更多