CameraLink data transmission method and device based on PCIe bus and storage medium

文档序号:7479 发布日期:2021-09-17 浏览:39次 中文

1. A CameraLink data transmission method based on PCIe bus is characterized in that the method comprises the following specific steps:

the method comprises the steps that a PCIe device driver is preassembled, and a plurality of kernel buffers, at least two DMA engines, BAR space resources and interrupt resources are applied in the initialization process of the device driver;

each PCIe device is automatically provided with a virtual serial port driver, and the virtual serial port driver applies for a unique serial port number and serial port interrupt resources to each PCIe device;

the virtual serial port device simulates at least two serial port devices and binds the virtual serial port device and the PCIe acquisition device through a shared read-write kernel buffer zone;

and uploading and downloading the Camera Link control data and the image data respectively through a PCIe acquisition device driver.

2. The CameraLink data transmission method based on the PCIe bus as recited in claim 1, wherein the two serial devices include a public serial device used for read-write access by a user and a private serial device used for read-write access by a PCIe device.

3. The CameraLink data transmission method based on the PCIe bus as recited in claim 2, wherein the specific step of uploading and downloading CameraLink control data through a PCIe acquisition device driver includes:

after receiving the write port request packet, the virtual serial port encapsulates data to be written into a PCIe request packet and sends the data to be written into a PCIe acquisition device driver;

the PCIe acquisition equipment analyzes the request content after receiving the PCIe request packet and transmits the data to be written to a lower computer through a BAR space;

after the lower computer receives a certain amount of data, the data is written into the kernel buffer area 0 through the DMA0 channel, and the PCIe acquisition device driver is informed through an interrupt signal;

when the PCIe acquisition device driver receives an interrupt signal, the valid data in the current kernel buffer area 0 is analyzed, and a request packet is sent to the private serial port device through a write-in port;

after receiving the write port request packet, the private serial port device detects whether the public serial port device has a suspended read request;

if the valid data exist, the valid data are filled into a buffer area of the read request and the request is completed, and if the valid data do not exist, the data are discarded.

4. The CameraLink data transmission method based on the PCIe bus as recited in claim 3, wherein the specific step of uploading CameraLink image data through a PCIe acquisition device driver includes:

when the lower computer starts to collect, the PCIe collection equipment drives a read-write pointer of the annular buffer area to be reset;

when the lower computer completes the transmission of one buffer area, the lower computer informs a PCIe acquisition device driver through an interrupt signal, and the PCIe acquisition device driver adds 1 to the write-in pointer;

adding 1 to the reading pointer when the PCIe acquisition device driver completes data transmission from the kernel buffer area to the user buffer area;

when the read-write pointer is approximately overlapped, the PCIe acquisition device driver stops data transmission until the kernel buffer area has enough idle buffer areas, and then data transmission is carried out again.

5. A data transmission apparatus, characterized by further comprising:

at least one processor;

at least one memory for storing at least one program;

when executed by the at least one processor, the at least one program causes the at least one processor to implement a method for PCIe bus based CameraLink data transfer as recited in any of claims 1-4.

6. A storage medium having stored therein instructions executable by a processor, the storage medium comprising: the processor-executable instructions, when executed by a processor, are for implementing a method for PCIe bus based CameraLink data transfer as recited in any one of claims 1-4.

Background

The scale of the china industrial camera market remains on the whole rising trend. Industry 4.0 does not leave intelligent manufacturing, and intelligent manufacturing does not leave machine vision. Machine vision is one of the important means for realizing industrial automation and intelligence, and is equivalent to the extension of human vision on machines. And vision cannot leave the industrial smart camera. The permeability of the industrial camera industry is low, and the growth performance is high. The image acquisition card plays a role in transmitting camera image data to a user computer as a necessary product in a machine vision system, a domestic machine vision user expects a universal-function image acquisition card which can be adapted to a linear array camera and a planar array camera which are common in the market, abundant hardware trigger interfaces are provided to customize an image acquisition mode, and an SDK interface function is provided for a user to develop a program secondarily.

The prior art has the defects that no relevant technology and equipment for stable work exist at present, image data can be transmitted to a PC memory, and meanwhile, the real-time communication with a CameraLink camera is supported by using a virtual serial port technology.

Disclosure of Invention

The present invention is directed to overcoming the deficiencies of the prior art, and to achieve the above objectives, a CameraLink data transmission method, apparatus and storage medium based on PCIe bus are adopted to solve the problems set forth in the background art.

A CameraLink data transmission method based on PCIe bus includes the following steps:

the method comprises the steps that a PCIe device driver is preassembled, and a plurality of kernel buffers, at least two DMA engines, BAR space resources and interrupt resources are applied in the initialization process of the device driver;

each PCIe device is automatically provided with a virtual serial port driver, and the virtual serial port driver applies for a unique serial port number and serial port interrupt resources to each PCIe device;

the virtual serial port device simulates at least two serial port devices and binds the virtual serial port device and the PCIe acquisition device through a shared read-write kernel buffer zone;

and determining that the PCIe acquisition device driver respectively uploads and downloads Camera Link control data and image data.

As a further aspect of the invention: the two serial devices comprise public serial devices used for being read and written by users to access and private serial devices used for being read and written by PCIe devices to access.

As a further aspect of the invention: the specific steps of uploading and downloading CameraLink control data through a PCIe acquisition device driver include:

after receiving the write port request packet, the virtual serial port encapsulates data to be written into a PCIe request packet and sends the data to be written into a PCIe acquisition device driver;

the PCIe acquisition equipment analyzes the request content after receiving the PCIe request packet and transmits the data to be written to a lower computer through a BAR space;

after the lower computer receives a certain amount of data, the data is written into the kernel buffer area 0 through the DMA0 channel, and the PCIe acquisition device driver is informed through an interrupt signal;

when the PCIe acquisition device driver receives an interrupt signal, the valid data in the current kernel buffer area 0 is analyzed, and a request packet is sent to the private serial port device through a write-in port;

after receiving the write port request packet, the private serial port device detects whether the public serial port device has a suspended read request;

if the valid data exist, the valid data are filled into a buffer area of the read request and the request is completed, and if the valid data do not exist, the data are discarded.

As a further aspect of the invention: the uploading of the CameraLink image data through the PCIe acquisition device driver specifically includes:

when the lower computer starts to collect, the PCIe collection equipment drives a read-write pointer of the annular buffer area to be reset;

when the lower computer completes the transmission of one buffer area, the lower computer informs a PCIe acquisition device driver through an interrupt signal, and the PCIe acquisition device driver adds 1 to the write-in pointer;

adding 1 to the reading pointer when the PCIe acquisition device driver completes data transmission from the kernel buffer area to the user buffer area;

when the read-write pointer is approximately overlapped, the PCIe acquisition device driver stops data transmission until the kernel buffer area has enough idle buffer areas, and then data transmission is carried out again.

A data transmission apparatus, further comprising:

at least one processor;

at least one memory for storing at least one program;

when the at least one program is executed by the at least one processor, the at least one processor is enabled to implement the CameraLink data transmission method based on the PCIe bus as described in any one of the above.

A storage medium having stored therein processor-executable instructions for implementing a CameraLink data transfer method over a PCIe bus as described in any one of the above when executed by a processor.

Compared with the prior art, the invention has the following technical effects:

by adopting the technical scheme, the PCIe device driver is pre-installed, and meanwhile, in the initialization process, a kernel buffer area, a DMA transmission engine, BAR space resources and interrupt resources are applied. Then, through parameter setting, the image data is transmitted to a computer kernel buffer area from a lower computer through a DMA channel 0, and the computer copies the image memory to a user memory after receiving an interrupt signal; the control data is transmitted to a computer kernel buffer area from the lower computer through the DMA channel 1, and the computer copies the control data to a serial port memory after receiving the interrupt signal. Therefore, the method and the device can transmit image data to the memory of the computer and support real-time communication with the CameraLink camera by using a virtual serial port technology. Meanwhile, the data transmission time and the CPU utilization rate of the computer end are saved, and the requirement of machine vision high-speed data transmission can be met.

Drawings

The following detailed description of embodiments of the invention refers to the accompanying drawings in which:

FIG. 1 is a schematic diagram illustrating the steps of a CameraLink data transmission method based on PCIe bus according to some embodiments of the disclosure;

FIG. 2 is a block flow diagram of transmitting CameraLink control data over a PCIe bus in accordance with some embodiments disclosed herein;

fig. 3 is a block flow diagram of transmitting CameraLink image data over a PCIe bus according to some embodiments disclosed herein.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

Referring to fig. 1, in an embodiment of the present invention, a CameraLink data transmission method based on a PCIe bus includes the specific steps of:

s1, pre-installing PCIe device driver, applying for a plurality of kernel buffers, at least two DMA engines, BAR space resources and interrupt resources in the initialization process of the device driver;

in the specific implementation mode, in the initialization process, N kernel buffers are applied for, and two DMA engines are applied for.

S2, automatically installing a virtual serial port driver for each PCIe device, and applying for a unique serial port number and serial port interrupt resources for each PCIe device by the virtual serial port driver;

s3, simulating at least two serial devices by the virtual serial device, and binding the virtual serial device and the PCIe acquisition device by sharing the read-write kernel buffer area;

in a specific embodiment, the two serial devices include a Public serial device used for being read and written by a user and a Private serial device used for being read and written by a PCIe device, that is, Public COM and Private COM.

And S4, uploading and downloading the CameraLink control data and the image data respectively through a PCIe acquisition device driver.

S41, the specific steps of uploading and downloading the CameraLink control data include:

as shown in fig. 2, a flow chart for controlling the uploading and downloading of data is illustrated.

After receiving a Write port request packet (Write COM IRP), the virtual serial port encapsulates data to be written into a PCIe request packet and sends the data to a PCIe acquisition device driver;

the PCIe acquisition equipment analyzes the request content after receiving the PCIe request packet and transmits the data to be written to a lower computer through a BAR space;

after the lower computer receives a certain amount of data, the data is written into the kernel buffer area 0 through the DMA0 channel, and the PCIe acquisition device driver is informed through an interrupt signal;

when the PCIe acquisition device driver receives an interrupt signal, analyzing valid data in a current kernel buffer area 0, and sending the valid data to a Private serial port device (Private COM) through a Write port request packet (Write COM IRP);

when a Private serial port device (Private COM) receives a Write port request packet (Write COM IRP), whether a Public serial port device (Public COM) has a suspended read request is detected;

if the valid data exist, the valid data are filled into a buffer area of the read request and the request is completed, and if the valid data do not exist, the data are discarded.

S42, the uploading of CameraLink image data by PCIe acquisition device driver includes:

as shown in fig. 3, a flowchart of uploading image data is illustrated.

When the lower computer starts to collect, the PCIe collection equipment drives a read-write pointer of the annular buffer area to be reset;

when the lower computer completes the transmission of one buffer area, the lower computer informs a PCIe acquisition device driver through an interrupt signal, and the PCIe acquisition device driver adds 1 to the write-in pointer;

adding 1 to the reading pointer when the PCIe acquisition device driver completes data transmission from the kernel buffer area to the user buffer area;

when the read-write pointer is approximately overlapped, the PCIe acquisition device driver stops data transmission until the kernel buffer area has enough idle buffer areas, and then data transmission is carried out again. Thereby avoiding read-write memory access conflicts.

A data transmission apparatus comprising:

at least one processor;

at least one memory for storing at least one program;

when the at least one program is executed by the at least one processor, the at least one processor is caused to implement the CameraLink data transmission method based on the PCIe bus as described above.

The contents in the above method embodiments are all applicable to the present apparatus embodiment, the functions specifically implemented by the present apparatus embodiment are the same as those in the above method embodiments, and the advantageous effects achieved by the present apparatus embodiment are also the same as those achieved by the above method embodiments.

A storage medium having stored therein processor-executable instructions for implementing a CameraLink data transfer method over a PCIe bus as described above when executed by a processor.

Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that changes, modifications, substitutions and alterations can be made in these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents, which should be construed as being within the scope of the invention.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:一种实现SPI从设备主动申请传输的方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!