A PCIe device access method, communication system, device and electronic device

By establishing connections and managing handles with PCIe devices on the server through the PCIe Device Control Packet Service, the problem of single-channel PCIe devices being unable to be accessed by multiple processes is solved, enabling concurrent access by multiple processes and improving enumeration efficiency.

CN116828026BActive Publication Date: 2026-02-06HANGZHOU HIKROBOT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310759419.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-26
Publication Date
2026-02-06
Estimated Expiration
2043-06-26

AI Technical Summary

Technical Problem

In the existing technology, a single-channel PCIe device can only be accessed by one process, which makes it impossible for other processes to know its status and thus makes it impossible for multiple processes to access the same PCIe device.

Method used

The PCIe Device Control Packet Service establishes connections with each PCIe device on the server, generates device handles, maintains their ownership, receives and forwards response information for access requests, and enables multi-process access.

Benefits of technology

This enables multiple processes to access PCIe devices simultaneously, avoiding direct connections between processes and devices, reducing enumeration time, and improving system access efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116828026B_ABST
    Figure CN116828026B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a PCIe device access method, a communication system, a device and an electronic device, a control packet service is set, so that a plurality of processes do not need to be directly connected with a PCIe device, access requests of various access services are received by the control packet service, then the control packet service accesses the PCIe device, after receiving response information of the access request, the response information is forwarded to the access service, so that multiple processes simultaneously access the PCIe device are realized.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of machine vision, in particular to a PCIe device access method, a communication system, an apparatus and an electronic device. BACKGROUND

[0002] In the field of machine vision, a capture card is a PCIe device, and through the capture card, a camera is connected and an image is captured, which can reduce CPU occupancy and avoid the occurrence of frame loss.

[0003] However, a single-channel capture card can only be accessed and controlled by one process at a time, which results in that the PCIe device cannot be accessed by other processes during use, and other processes cannot know the status of the used PCIe device. Therefore, how to solve the access of multiple processes to the same PCIe device is a problem that needs to be solved at present. SUMMARY

[0004] The purpose of the embodiments of the present application is to provide a PCIe device access method, a communication system, an apparatus and an electronic device to realize the access of multiple processes to the same PCIe device. The specific technical solutions are as follows:

[0005] The embodiments of the present application provide a PCIe device access method, which comprises:

[0006] The PCIe device control package service establishes a connection with each PCIe device through a PCIe protocol and generates a device handle of each PCIe device, wherein, for any one PCIe device, after the PCIe device control package service establishes a connection with the PCIe device, the PCIe device control package service keeps occupying the PCIe device;

[0007] In the case that the PCIe device control package service obtains access requests of multiple access services for a target PCIe device, the PCIe device control package service accesses the target PCIe device through a target device handle and receives response information of each access request returned by the target PCIe device, wherein the target PCIe device is one of the PCIe devices, and the target device handle is a device handle of the target PCIe device;

[0008] For each access service, the PCIe device control package service returns the response information of the access request of the access service to the access service.

[0009] In a possible embodiment, the PCIe device control package service establishes a connection with each PCIe device through a PCIe protocol and generates a device handle of each PCIe device, comprising:

[0010] The PCIe device control packet service enumerates each PCIe device in the system and establishes a connection between the PCIe device control packet service and each enumerated PCIe device according to the PCIe protocol.

[0011] For each PCIe device, the PCIe device control packet service generates a device handle representing the connection with the PCIe device.

[0012] In one possible embodiment, the method further comprises:

[0013] For each PCIe device, the PCIe device control packet service enumerates each terminal connected to the PCIe device through the device handle of the PCIe device and generates a terminal handle for each terminal connected to the PCIe device.

[0014] In one possible embodiment, when the PCIe device control packet service obtains access requests for a target PCIe device from multiple access services, the PCIe device control packet service accesses the target PCIe device through a target device handle and receives response information returned by the target PCIe device for each access request, including:

[0015] When the PCIe device control packet service obtains access requests for a target PCIe device from multiple access services, the PCIe device control packet service selects a current access request to be executed from the access requests according to a preset execution order.

[0016] The PCIe device control packet service sends the current access request to be executed to the target PCIe device through the target device handle.

[0017] The PCIe device control packet service receives response information returned by the target PCIe device for the current access request to be executed.

[0018] The PCIe device control packet service selects a next access request as the current access request to be executed from the access requests according to the preset execution order, and returns to the step of sending the current access request to be executed to the target PCIe device through the target device handle until each access request is sent completely.

[0019] In one possible embodiment, when the PCIe device control packet service obtains access requests for a target PCIe device from multiple access services, the PCIe device control packet service accesses the target PCIe device through a target device handle and receives response information returned by the target PCIe device for each access request, including:

[0020] In a case where the PCIe device control package service obtains access requests of a plurality of access services for a target PCIe device, the PCIe device control package service generates an access message for each access request, wherein the access message comprises a message identifier, and the message identifiers of the access messages generated within a preset time period are different;

[0021] The PCIe device control package service sends each access message to the target PCIe device through a target device handle;

[0022] The PCIe device control package service receives response information of each access message returned by the target PCIe device, wherein the response information comprises an information identifier, and the message identifier and the information identifier correspond to each other.

[0023] Embodiments of the present application also provide a communication system, comprising a server and a plurality of PCIe devices, wherein the server runs a PCIe device control package service;

[0024] The server is configured to establish a connection with each PCIe device through the PCIe device control package service based on a PCIe protocol, and generate a device handle of each PCIe device, wherein, for any PCIe device, the PCIe device control package service keeps occupying the PCIe device after the PCIe device control package service establishes a connection with the PCIe device;

[0025] In a case where the PCIe device control package service obtains access requests of a plurality of access services for a target PCIe device, the PCIe device control package service accesses the target PCIe device through a target device handle, and receives response information of each access request returned by the target PCIe device, wherein the target PCIe device is one of the plurality of PCIe devices, and the target device handle is a device handle of the target PCIe device;

[0026] For each access service, the PCIe device control package service returns response information of the access request of the access service to the access service.

[0027] In a possible embodiment, the server is specifically configured to:

[0028] The PCIe device control package service enumerates each PCIe device in the system, and establishes a connection between the PCIe device control package service and each enumerated PCIe device based on a PCIe protocol;

[0029] For each PCIe device, a device handle representing the connection with the PCIe device is generated by the PCIe device control packet service.

[0030] In a possible embodiment, the system further comprises a plurality of terminals; each of the PCIe devices is connected to at least one terminal;

[0031] The server is further configured to: for each PCIe device, enumerate each terminal connected to the PCIe device by the device handle of the PCIe device through the PCIe device control packet service, and generate a terminal handle of each terminal connected to the PCIe device.

[0032] In a possible embodiment, the server is specifically configured to:

[0033] In a case where the PCIe device control packet service obtains access requests of a plurality of access services for a target PCIe device, a current access request to be executed is selected from the access requests according to a preset execution order.

[0034] The PCIe device control packet service sends the current access request to be executed to the target PCIe device through the target device handle.

[0035] The PCIe device control packet service receives response information of the current access request to be executed returned by the target PCIe device.

[0036] The next access request is selected as the current access request to be executed from the access requests according to the preset execution order, and the execution step of sending the current access request to be executed to the target PCIe device through the target device handle by the PCIe device control packet service is returned until the access requests are all sent.

[0037] In a possible embodiment, the server is specifically configured to: in a case where the PCIe device control packet service obtains access requests of a plurality of access services for a target PCIe device, for each access request, the PCIe device control packet service generates an access message of the access request, wherein the access message includes a message identifier, and the message identifiers of the access messages generated within a preset time period are different; and the PCIe device control packet service sends the access messages to the target PCIe device through the target device handle.

[0038] The target PCIe device is configured to, after receiving an access message, execute a request corresponding to the access message to obtain an execution result of the access message, generate an information identifier corresponding to a message identifier of the access message, add the information identifier corresponding to the access message to the execution result of the access message to obtain response information of the access message, and send the response information of the access message to the PCIe device control package service.

[0039] The server is specifically configured to receive the response information of each access message returned by the target PCIe device, wherein the response information includes an information identifier, and the message identifier and the information identifier correspond to each other.

[0040] Embodiments of the present application also provide a PCIe device access apparatus, and the apparatus comprises:

[0041] The first processing module is configured to establish a connection with each PCIe device through a PCIe protocol by using a PCIe device control package service, and generate a device handle of each PCIe device, wherein, for any one PCIe device, the PCIe device control package service keeps occupying the PCIe device after the PCIe device control package service establishes a connection with the PCIe device.

[0042] The second processing module is configured to, when the PCIe device control package service obtains access requests of multiple access services for a target PCIe device, access the target PCIe device through a target device handle by using the PCIe device control package service, and receive response information of each access request returned by the target PCIe device, wherein the target PCIe device is one of the PCIe devices, and the target device handle is a device handle of the target PCIe device.

[0043] The return module is configured to, for each access service, return, by using the PCIe device control package service, the response information of the access request of the access service to the access service.

[0044] In a possible embodiment, the first processing module is specifically configured to:

[0045] Enumerate each PCIe device in a system by using a PCIe device control package service, and establish a connection between the PCIe device control package service and each enumerated PCIe device according to a PCIe protocol;

[0046] For each PCIe device, generate, by using the PCIe device control package service, a device handle representing a connection with the PCIe device.

[0047] In a possible embodiment, the apparatus further includes:

[0048] The second processing module is configured to, for each PCIe device, enumerate each terminal connected to the PCIe device via a device handle of the PCIe device by using the PCIe device control packet service, and generate a terminal handle of each terminal connected to the PCIe device.

[0049] In a possible embodiment, the second processing module is specifically configured to:

[0050] In a case where the PCIe device control packet service obtains access requests of a plurality of access services for a target PCIe device, a next access request is selected as a current access request to be executed in the access requests according to a preset execution order.

[0051] The PCIe device control packet service is used to send the current access request to be executed to the target PCIe device via the target device handle.

[0052] The PCIe device control packet service is used to receive response information of the current access request to be executed returned by the target PCIe device.

[0053] The next access request is selected as the current access request to be executed in the access requests according to the preset execution order, and the execution step is returned: the PCIe device control packet service is used to send the current access request to be executed to the target PCIe device via the target device handle, until the access requests are all sent.

[0054] In a possible embodiment, the second processing module is specifically configured to:

[0055] In a case where the PCIe device control packet service obtains access requests of a plurality of access services for a target PCIe device, for each access request, the PCIe device control packet service is used to generate an access message of the access request, wherein the access message includes a message identifier, and message identifiers of access messages generated within a preset time period are different.

[0056] The PCIe device control packet service is used to send the access messages to the target PCIe device via a target device handle.

[0057] Response information of the access messages returned by the target PCIe device is received, wherein the response information includes an information identifier, and the message identifier and the information identifier correspond to each other.

[0058] In a possible embodiment, the watermark picture further includes a device identifier of the playing device.

[0059] The embodiment of the application further provides an electronic device, comprising a processor, a memory;

[0060] The memory is used for storing a computer program.

[0061] The processor is used for executing the program stored in the memory, and the PCIe device access method described above is realized.

[0062] The embodiment of the application further provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a processor to realize the PCIe device access method described above.

[0063] The embodiment of the application further provides a computer program product containing instructions, which, when running on a computer, causes the computer to execute the PCIe device access method described above.

[0064] The embodiment of the application has the following beneficial effects:

[0065] The PCIe device access method, communication system, device and electronic device provided by the embodiment of the application run the PCIe device control package service on the server, then use the PCIe device control package service to establish the connection between the server and each PCIe device through the PCIe protocol, generate the device handle of each PCIe device by the server, and keep the PCIe device occupied by the PCIe device control package service after the PCIe device control package service establishes the connection with the PCIe device, so as to avoid that other processes access the PCIe device. When the access service needs to access the data of the PCIe device, the access request can be sent to the PCIe device control package service, the PCIe device control package service accesses the PCIe device through the PCIe device handle to obtain the response information of the access request, and then the PCIe device control package service returns the response information of the access request of the access service to the access service. By setting the control package service, multiple processes do not need to be directly connected with the PCIe device, and each access request of each access service is received by the control package service, then the control package service accesses the PCIe device, and after the response information of the access request is received, the access service is forwarded, so that multiple processes simultaneously access the PCIe device.

[0066] Of course, implementing any product or method of the application does not necessarily need to achieve all the advantages described above. BRIEF DESCRIPTION OF DRAWINGS

[0067] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced. Obviously, the accompanying drawings in the following description only represent some embodiments of the present application, and other drawings can be obtained by those of ordinary skill in the art based on these drawings.

[0068] Figure 1-1 The first structure diagram of a communication system provided by the embodiments of the present application is shown in the following figure.

[0069] Figure 1-2 The first flow diagram of the processing of a server in a communication system provided by the embodiments of the present application is shown in the following figure.

[0070] Figure 1-3 The second structure diagram of a communication system provided by the embodiments of the present application is shown in the following figure.

[0071] Figure 1-4 The second flow diagram of the processing of a server in a communication system provided by the embodiments of the present application is shown in the following figure.

[0072] Figure 1-5 The processing of a communication system provided by the embodiments of the present application is shown in the following figure.

[0073] Figure 2 The flow diagram of a PCIe device access method provided by the embodiments of the present application is shown in the following figure.

[0074] Figure 3 The structure diagram of a PCIe device access device provided by the embodiments of the present application is shown in the following figure.

[0075] Figure 4 The structure diagram of an electronic device provided by the embodiments of the present application is shown in the following figure. DETAILED DESCRIPTION

[0076] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments only represent some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art based on the present application are within the scope of protection of the present application.

[0077] First, the terms in the present application are introduced:

[0078] PCIe: PCI-Express (peripheral component interconnect express) is a high-speed serial computer expansion bus standard.

[0079] Acquisition Card: Acquisition cards are mainly used to capture analog signals such as photoelectric, video, and audio signals from the outside world and digitize them for importing into a computer for digital processing. They are mainly image acquisition cards, video acquisition cards, audio acquisition cards (such as sound cards), and data acquisition cards. Acquisition cards belong to PCIe devices.

[0080] Control packet: A control packet is a data packet that interacts with the device and controls the device parameters. This data packet does not refer to a specific protocol.

[0081] Control Packet Service: A background program that interacts with the device and runs continuously within the operating system.

[0082] To enable multiple processes to access the same PCIe device, embodiments of this application provide a PCIe device access method, communication system, apparatus, electronic device, computer-readable storage medium, and computer program product containing instructions.

[0083] The communication system provided in the embodiments of this application will be described below.

[0084] like Figure 1-1 As shown, Figure 1-1 This is a schematic diagram of a first structure of a communication system provided in an embodiment of the present application. The system includes: a server 010 and multiple PCIe devices 020.

[0085] The aforementioned server 010 is used to establish connections with each PCIe device 020 via the PCIe protocol using the PCIe device 020 control packet service, and to generate device handles for each of the aforementioned PCIe devices 020.

[0086] When the PCIe device 020 control packet service obtains multiple access requests for the target PCIe device 020, it uses the PCIe device 020 control packet service to access the target PCIe device 020 through the target device handle and receives the response information of each access request returned by the target PCIe device 020.

[0087] For each access service, the PCIe device O20 control packet service described above is used to return the response information of the access request to the access service.

[0088] Server 010 can be a computer, industrial control computer, etc. Server 010 runs PCIe device 020 control packet service. Server 010 can establish connections with each PCIe device 020 through the PCIe protocol. For any PCIe device 020, after the PCIe device 020 control packet service establishes a connection with the PCIe device 020, the PCIe device 020 control packet service will keep occupying the PCIe device 020.

[0089] For each PCIe device 020, after the server 010 establishes a connection with the PCIe device 020, the server 010 generates a device handle of the PCIe device 020. For example, the PCIe device control packet service enumerates each PCIe device in the system, and establishes a connection between the PCIe device control packet service and each enumerated PCIe device according to the PCIe protocol. For each PCIe device, the PCIe device control packet service generates a device handle representing the connection with the PCIe device.

[0090] Since the device handle is an identifier used to identify a PCIe device, for each PCIe device, when the PCIe device control packet service obtains multiple access requests of the access service for the PCIe device, the PCIe device control packet service can access the PCIe device through the device handle of the PCIe device, and then receive the response information of each access request returned by the PCIe device. In the case where the PCIe device control packet service obtains multiple access requests of the access service for the target PCIe device, the PCIe device control packet service can access the target PCIe device through the target device handle, and receive the response information of each access request returned by the target PCIe device. The way of determining the access request to be executed according to the preset execution sequence, or determining the access request to be executed by using the access message for each access request, is described in detail below in combination with another embodiment.

[0091] For each access service, after the PCIe device control packet service receives the response information of the access request returned by the PCIe device, the PCIe device control packet service returns the response information of the access request of the access service to the access service.

[0092] The PCIe device control package service is run on the server, and then the PCIe device control package service establishes a connection between the server and each PCIe device through the PCIe protocol respectively, a device handle of each PCIe device is generated by the server, and after the PCIe device control package service establishes a connection with the PCIe device, the PCIe device control package service keeps occupying the PCIe device to avoid other processes accessing the PCIe device. When an access service needs to access data of the PCIe device, an access request can be sent to the PCIe device control package service, the PCIe device control package service accesses the PCIe device through the PCIe device handle to obtain response information of the access request, and after the response information of the access request is obtained, the PCIe device control package service returns the response information of the access request of the access service to the access service. By setting the control package service, multiple processes do not need to be directly connected with the PCIe device, and each access request of each access service is received by a control package service, then the control package service accesses the PCIe device, and after the response information of the access request is received, the response information of the access request is forwarded to the access service, so that multiple processes can simultaneously access the PCIe device.

[0093] In a possible embodiment, the server 010 is specifically configured to:

[0094] The PCIe device 020 control package service is used to enumerate each PCIe device 020 in the system, and a connection between the PCIe device 020 control package service and each enumerated PCIe device 020 is established according to the PCIe protocol.

[0095] For each PCIe device 020, a device handle representing a connection with the PCIe device 020 is generated by the PCIe device 020 control package service.

[0096] The PCIe device control package service is run on the server, and then the PCIe device control package service enumerates each PCIe device in the system and establishes a connection between the PCIe device control package service and each enumerated PCIe device according to the PCIe protocol. Figure 1-2 As shown in Figure 1-2 The first flowchart for processing of the server in the communication system provided by the embodiment of the application includes:

[0097] S101, enumerate each PCIe device;

[0098] S102, determine whether a PCIe device is enumerated, if yes, perform step S103, and if not, perform step S101;

[0099] S103, establish connections between the PCIe device control packet service and the enumerated PCIe devices according to the PCIe protocol, and generate a device handle representing the connection with the PCIe device.

[0100] Because a device handle is an identifier used to identify a PCIe device, for each PCIe device, when the PCIe Device Control Packet Service receives multiple access requests for that PCIe device from the access services, it can use the PCIe Device Control Packet Service to access the PCIe device through its device handle, and then receive the response information for each access request returned by the PCIe device. This allows multiple processes to access the PCIe device simultaneously.

[0101] Moreover, the device handles are all generated using the PCIe device control packet service. In other words, when the access service needs to access a PCIe device, it does not directly access the PCIe device, but instead uses the PCIe device control packet service to provide information about the enumerated PCIe devices and then provides this information to the access service. In this way, the control packet service can enable multiple processes to access PCIe devices while also reducing the time spent enumerating PCIe devices.

[0102] like Figure 1-3 As shown, Figure 1-3 The diagram illustrates a second structural design of the communication system provided in this application. In one possible embodiment, the system further includes: multiple terminals 030; each of the aforementioned PCIe devices 020 is connected to at least one terminal 030.

[0103] The aforementioned server 010 is also used to: for each PCIe device 020, use the PCIe device 020 control packet service to enumerate each terminal 030 connected to the PCIe device 020 through the device handle of the PCIe device 020, and generate terminal handles for each terminal 030 connected to the PCIe device 020.

[0104] Each of the PCIe devices can be connected to one terminal or multiple terminals. For example, the PCIe device has a capture card, which can be an image capture card, a video capture card, an audio capture card (such as a sound card), a data capture card, etc. The capture card belongs to the PCIe device, and the capture card is connected to a capture terminal, such as a camera, a sound card, a video recorder, etc. The PCIe device can be connected to only one camera, sound card, or video recorder, or the PCIe device can be connected to at least one camera, sound card, or video recorder. Therefore, the PCIe device can be enumerated based on the capture card. For each PCIe device, the PCIe device control package service is used to enumerate the terminals connected to the PCIe device through the device handle of the PCIe device, and the terminal handle of each terminal connected to the PCIe device is generated. Figure 1-4 Figure 1-4 The second flow diagram for processing by the server in the communication system provided by the embodiments of the present application is shown in FIG. 27. The PCIe device is connected to a camera. The capture card is enumerated based on the capture card. The capture card belongs to the PCIe device. It is determined whether the capture card device is enumerated. If yes, the capture card handle is generated. If no, the capture card is continuously enumerated. The camera connected to the capture card is enumerated after the capture card handle is generated. It is determined whether the camera is enumerated. If yes, the camera handle is generated. If no, the camera connected to the capture card is continuously enumerated.

[0105] For each PCIe device, the PCIe device control package service is used to enumerate the terminals connected to the PCIe device through the device handle of the PCIe device, and the terminal handle of each terminal connected to the PCIe device is generated.

[0106] The device handle and the terminal handle are both generated by the PCIe device control package service. That is, when the access service needs to access the PCIe device, the PCIe device is not directly accessed, but the PCIe device information enumerated by the control package service is provided to the access service, so that the PCIe device can be accessed by the control package service while multiple processes are accessing the PCIe device, and the time consumption of enumeration of the PCIe device and the terminal can be reduced.

[0107] In one example, in the case that the PCIe device 020 is connected to multiple terminals 030, for each PCIe device 020, the PCIe device 020 control package service is used to enumerate the terminals 030 connected to the PCIe device 020 based on a preset time period through the device handle of the PCIe device 020.

[0108] ​If the PCIe device is connected with multiple terminals, for example, the PCIe device is connected with multiple cameras, the PCIe device connected cameras can be enumerated by the control package service based on a preset time period, wherein the preset time period can be set based on actual conditions, for example, 10s, 20s, or 0s, that is, the control package service always enumerates the PCIe device connected cameras through the device handle of the PCIe device, because the control package service always enumerates the PCIe device connected cameras, when multiple access services send access requests to the target PCIe device, the enumeration result can be directly fed back to the terminal device information, so as to reduce the time-consuming.

[0109] Based on the above Figures 1-3 to 1-4 embodiments, in one example, the server is further configured to, in a case where the PCIe device control package service obtains an access request of an access service to a target PCIe device, set an access permission of the access service by using the PCIe device control package service.

[0110] The access permission is used to limit the permission range that the access service can access, for example, read-write permission, read-only permission, etc.

[0111] In one example, when multiple access services send access requests to the target PCIe device, the PCIe device control package service can randomly determine a preset number of access services from the multiple access services, obtain target access services, set the access permission of the target access service to read-write permission, and set the access permission of the other access services except the target access service to read-only permission. The preset number can be set based on actual conditions, for example, the preset number is 1, 2, etc. The preset number can also be set based on the number of access services, for example, after obtaining the number of access services, the number of access services is multiplied by a preset coefficient, and the number of target access services is obtained by rounding up (down).

[0112] For example, the access service corresponds to a priority, and the priority of each access service is preset.

[0113] After obtaining the number of target access services, the target access services can be determined based on the priority of the access service. For example, there are currently 5 access services sending access requests, and the number of target access services is determined to be 2, wherein the priority of the access service 1 is the highest priority, the priorities of the access services 2-4 are the lowest priority, and the priority of the access service 5 is the medium priority. According to the order from high to low, the access service 1 and the access service 5 can be determined as the target access services.

[0114] In one possible embodiment, as shown in Figure 1-5 ,Figure 1-5 A schematic diagram of a communication system for performing the method according to an embodiment of the application.

[0115] First, install the acquisition card SDK (Software Development Kit), then install the acquisition card SDK control package service, the user calls the acquisition card SDK interface, calls the enumeration acquisition card interface, accesses the control package service, and obtains the acquisition card device information. Enumerate the camera information connected to the acquisition card device.

[0116] In a possible embodiment, the server 010 is specifically configured to:

[0117] In the case where the PCIe device 020 control package service obtains a plurality of access requests for the target PCIe device 020 from the access service, the current access request to be executed is selected from the access requests according to a preset execution order.

[0118] The PCIe device 020 control package service sends the current access request to be executed to the target PCIe device 020 through the target device handle.

[0119] The PCIe device 020 control package service receives the response information of the current access request to be executed returned by the target PCIe device 020.

[0120] The next access request is selected as the current access request to be executed according to the preset execution order, and the execution step of sending the current access request to be executed to the target PCIe device 020 through the target device handle by the PCIe device 020 control package service is returned until all the access requests are sent.

[0121] If the PCIe device control package service obtains a plurality of access requests for the target PCIe device from the access service, the current access request to be executed is selected from the access requests according to a preset execution order. After selecting the current access request to be executed, the PCIe device control package service sends the current access request to be executed to the target PCIe device through the target device handle, and then the PCIe device control package service receives the response information of the current access request to be executed returned by the target PCIe device. After receiving the response message, the next access request is selected as the current access request to be executed according to the preset execution order, and the execution step of sending the current access request to be executed to the target PCIe device through the target device handle by the PCIe device control package service is returned until all the access requests are sent.

[0122] In a possible embodiment, the server 010 is specifically configured to:

[0123] In a case where the PCIe device 020 control packet service obtains multiple access requests for the target PCIe device 020, the PCIe device 020 control packet service generates an access message for each access request, wherein the access message includes a message identifier, and the message identifiers of the access messages generated within a preset time period are different.

[0124] The PCIe device 020 control packet service sends each access message to the target PCIe device 020 through a target device handle.

[0125] The target PCIe device 020 is configured to, after receiving an access message, execute the request corresponding to the access message to obtain an execution result of the access message, generate an information identifier corresponding to the message identifier of the access message, add the information identifier corresponding to the access message to the execution result of the access message to obtain response information of the access message, and send the response information of the access message to the PCIe device 020 control packet service.

[0126] The server 010 is configured to receive the response information of each access message returned by the target PCIe device 020, wherein the response information includes an information identifier, and the message identifier and the information identifier correspond to each other.

[0127] If the PCIe device control packet service obtains multiple access requests for a target PCIe device, the PCIe device control packet service can generate an access message including a message identifier for each access request, wherein the message identifier is unique identifier information representing the access request within a valid time of the access request. That is, the message identifier can uniquely represent a valid access request, for example, the message identifier can be globally unique identifier information representing the access request, that is, one message identifier can represent the identifier information of only one access request. In one embodiment, for each access request, a timestamp of obtaining the access request can be used as the identifier information of the access request, or a timestamp of generating an access message of the access request by the PCIe device control packet service can be used as the identifier information of the access request.

[0128] Alternatively, the message identifier uniquely represents a valid access request, that is, the message identifier of an invalid access request can be the same as that of a current valid access request. For example, the valid time of an access request is 5 seconds, as long as the generated message identifier uniquely represents the access request within the 5 seconds.

[0129] In one embodiment, a field with a preset number of bits is set in the message header reserved bit as an identifier, for example, a ten-bit field is set in the message header reserved bit as an identifier. The field can be monotonically increased, and when the maximum value that can be represented by the field with the preset number of bits is reached, the field is set from zero. The length of the field with the preset number of bits can be set according to the time limit of the access request to ensure uniqueness within the time limit of the request.

[0130] After generating the access messages of the access request, the PCIe device control package service can be used to send the access messages to the target PCIe device through the target device handle, and then receive the response information of the access messages returned by the target PCIe device. The response information includes an information identifier, and the message identifier and the information identifier correspond to each other.

[0131] Next, the PCIe device access method provided by the embodiments of the present application will be introduced. The method is applied to any electronic device that can provide PCIe device access services, such as a network video recorder, a personal computer, a server, etc. The PCIe device access method provided by the embodiments of the present application can be implemented by at least one of software, hardware circuit and logic circuit in the electronic device.

[0132] As shown in Figure 2 , a flowchart of the PCIe device access method provided by the embodiments of the present application is shown. The method includes: Figure 2

[0133] S210, the PCIe device control package service is used to establish a connection with each PCIe device through the PCIe protocol, and a device handle of each PCIe device is generated. For any one PCIe device, after the PCIe device control package service establishes a connection with the PCIe device, the PCIe device control package service keeps occupying the PCIe device.

[0134] S220, when the PCIe device control package service obtains access requests of multiple access services for a target PCIe device, the PCIe device control package service is used to access the target PCIe device through a target device handle, and receive response information of each access request returned by the target PCIe device. The target PCIe device is one of the PCIe devices, and the target device handle is the device handle of the target PCIe device.

[0135] S230, for each access service, the PCIe device control package service is used to return the response information of the access request of the access service to the access service.

[0136] ​In one possible embodiment, the above-mentioned use of the PCIe Device Control Packet Service to establish connections with each PCIe device via the PCIe protocol and generate device handles for each of the aforementioned PCIe devices includes:

[0137] The PCIe device control packet service is used to enumerate each PCIe device in the system, and connections are established between the PCIe device control packet service and each enumerated PCIe device according to the PCIe protocol.

[0138] For each PCIe device, a device handle representing the connection to that PCIe device is generated using the PCIe Device Control Packet Service.

[0139] In one possible embodiment, the above method further includes:

[0140] For each PCIe device, the PCIe device control packet service is used to enumerate each terminal connected to the PCIe device through the device handle of the PCIe device, and generate terminal handles for each terminal connected to the PCIe device.

[0141] In one possible embodiment, when the PCIe Device Control Packet Service obtains multiple access requests for the target PCIe device from the access services, the PCIe Device Control Packet Service accesses the target PCIe device through the target device handle and receives response information for each access request returned by the target PCIe device, including:

[0142] When the PCIe device control packet service obtains multiple access requests for the target PCIe device, the access request to be executed is selected from the above access requests according to the preset execution order.

[0143] Using the aforementioned PCIe device control packet service, a currently pending access request is sent to the aforementioned target PCIe device via the aforementioned target device handle;

[0144] The above-mentioned PCIe device control packet service is used to receive the response information of the currently pending access request returned by the target PCIe device;

[0145] According to the preset execution order, select the next access request from the above access requests as the current access request to be executed, and return to the execution steps: use the above PCIe device control packet service to send the current access request to be executed to the above target PCIe device through the above target device handle until all the above access requests have been sent.

[0146] In a possible embodiment, in the case that the PCIe device control packet service obtains access requests of multiple access services for a target PCIe device, the PCIe device control packet service accesses the target PCIe device through a target device handle and receives response information of each access request returned by the target PCIe device, including:

[0147] In the case that the PCIe device control packet service obtains access requests of multiple access services for a target PCIe device, for each access request, the PCIe device control packet service generates an access message of the access request, wherein the access message includes a message identifier, and message identifiers of access messages generated within a preset time period are different.

[0148] The PCIe device control packet service sends each access message to the target PCIe device through the target device handle.

[0149] The PCIe device control packet service receives response information of each access message returned by the target PCIe device, wherein the response information includes an information identifier, and the message identifier and the information identifier correspond to each other.

[0150] Based on the method embodiment, the embodiment of the application provides a PCIe device access device, as shown in Figure 3 The PCIe device access device provided by the embodiment of the application has the structure shown in Figure 3 The PCIe device access device provided by the embodiment of the application has the structure shown in

[0151] The first processing module 310 is configured to establish connections with each PCIe device through a PCIe protocol by using a PCIe device control packet service and generate a device handle of each PCIe device, wherein for any PCIe device, after the PCIe device control packet service establishes a connection with the PCIe device, the PCIe device control packet service keeps occupying the PCIe device.

[0152] The second processing module 320 is configured to, in the case that the PCIe device control packet service obtains access requests of multiple access services for a target PCIe device, access the target PCIe device through a target device handle by using the PCIe device control packet service and receive response information of each access request returned by the target PCIe device, wherein the target PCIe device is one of the PCIe devices, and the target device handle is a device handle of the target PCIe device.

[0153] The return module 330 is configured to, for each access service, return, by using the PCIe device control packet service, response information of an access request of the access service to the access service.

[0154] In a possible embodiment, the first processing module 310 is specifically configured to:

[0155] The PCIe device control packet service is used to enumerate each PCIe device in the system, and a connection between the PCIe device control packet service and each enumerated PCIe device is established according to the PCIe protocol.

[0156] For each PCIe device, the PCIe device control packet service generates a device handle representing the connection with the PCIe device.

[0157] In a possible embodiment, the apparatus further includes:

[0158] The second processing module is configured to, for each PCIe device, use the PCIe device control packet service to enumerate each terminal connected to the PCIe device through the device handle of the PCIe device, and generate a terminal handle of each terminal connected to the PCIe device.

[0159] In a possible embodiment, the second processing module 320 is specifically configured to:

[0160] When the PCIe device control packet service obtains access requests of a plurality of access services for a target PCIe device, a current access request to be executed is selected from the access requests according to a preset execution order.

[0161] The PCIe device control packet service is used to send the current access request to be executed to the target PCIe device through the target device handle.

[0162] The PCIe device control packet service is used to receive response information of the current access request to be executed returned by the target PCIe device.

[0163] The next access request is selected as the current access request to be executed from the access requests according to the preset execution order, and the step of sending the current access request to be executed to the target PCIe device through the target device handle by using the PCIe device control packet service is returned until the sending of each access request is completed.

[0164] In a possible embodiment, the second processing module 320 is specifically configured to:

[0165] In a case where the PCIe device control packet service obtains access requests of multiple access services for a target PCIe device, the PCIe device control packet service generates an access message for each access request, wherein the access message includes a message identifier, and the message identifiers of the access messages generated within a preset time period are different.

[0166] The PCIe device control packet service sends the access messages to the target PCIe device through a target device handle.

[0167] The PCIe device control packet service receives response information of the access messages returned by the target PCIe device, wherein the response information includes an information identifier, and the message identifier and the information identifier correspond to each other.

[0168] As to the apparatus in the above embodiments, the specific manners in which the modules perform operations have been described in detail in the embodiments of the method, and thus will not be described in detail here.

[0169] The embodiments of the present application also provide an electronic device, as shown in the accompanying drawings, comprising: Figure 4

[0170] The memory 401 is used to store a computer program.

[0171] The processor 402 is used to execute the program stored in the memory 401, and implement the following steps:

[0172] The PCIe device control packet service establishes connections with the PCIe devices through the PCIe protocol respectively, and generates device handles of the PCIe devices, wherein, for any PCIe device, the PCIe device control packet service keeps occupying the PCIe device after the PCIe device control packet service establishes a connection with the PCIe device.

[0173] In a case where the PCIe device control packet service obtains access requests of multiple access services for a target PCIe device, the PCIe device control packet service accesses the target PCIe device through a target device handle, and receives response information of the access requests returned by the target PCIe device; wherein the target PCIe device is one of the PCIe devices, and the target device handle is the device handle of the target PCIe device.

[0174] For each access service, the PCIe device control packet service returns the response information of the access request of the access service to the access service.

[0175] ​And the electronic device can further include a communication bus and / or a communication interface, and the processor 402, the communication interface and the memory 401 can communicate with each other through the communication bus.

[0176] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus or the like. The communication bus can be divided into an address bus, a data bus, a control bus and the like. For the convenience of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or only one type of bus.

[0177] The communication interface is used for communication between the electronic device and other devices.

[0178] The memory can include a Random Access Memory (RAM) and can also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory can also be at least one storage device located away from the aforementioned processor.

[0179] The processor mentioned above can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP) and the like; can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.

[0180] In another embodiment provided in the present application, a computer readable storage medium is also provided, and the computer readable storage medium stores a computer program. When the computer program is executed by a processor, the steps of any of the PCIe device access methods described above are implemented.

[0181] In another embodiment provided in the present application, a computer program product containing instructions is also provided, and when the computer program product is run on a computer, the computer is caused to execute any of the PCIe device access methods in the above embodiments.

[0182] In the embodiments described above, all or some of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or some of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded into and executed by a computer, all or some of the processes or functions according to the embodiments described in the specification are generated. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions can be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode. The computer readable storage medium can be any available medium accessible by a computer or a data storage device such as a server, data center, etc. integrated with one or more available media. The available media can be magnetic media (for example, floppy disk, hard disk, magnetic tape), optical media (for example, DVD), solid state disk (SSD) and the like.

[0183] It should be noted that, in this document, the relationship terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between the entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0184] Each of the embodiments in the specification is described in a related manner, and the same and similar parts between each of the embodiments can be referred to each other. Each of the embodiments focuses on the difference from other embodiments. In particular, for the method, device, electronic device, computer readable storage medium and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiment.

[0185] The above merely provides the preferred embodiment of the present application, and not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A PCIe device access method, characterized in that, The method comprises: establishing a connection with each PCIe device respectively through a PCIe protocol by using a PCIe device control package service, and generating a device handle of each PCIe device, wherein, for any one PCIe device, after the PCIe device control package service establishes a connection with the PCIe device, the PCIe device control package service keeps occupying the PCIe device; the control package service is a background program for data interaction with a device; in a case where the PCIe device control package service obtains access requests of multiple access services for a target PCIe device, accessing the target PCIe device through a target device handle by using the PCIe device control package service, and receiving response information of each access request returned by the target PCIe device; wherein the target PCIe device is one of the PCIe devices, and the target device handle is a device handle of the target PCIe device; for each access service, returning the response information of the access request of the access service to the access service by using the PCIe device control package service.

2. The method of claim 1, wherein, The method comprises: enumerating each PCIe device in the system by using a PCIe device control package service, and establishing a connection between the PCIe device control package service and each enumerated PCIe device according to a PCIe protocol; for each PCIe device, generating a device handle representing the connection with the PCIe device by using the PCIe device control package service.

3. The method according to claim 1 or 2, characterized in that, The method further comprises: for each PCIe device, enumerating each terminal connected to the PCIe device through the device handle of the PCIe device by using the PCIe device control package service, and generating a terminal handle of each terminal connected to the PCIe device.

4. The method of claim 1, wherein, The method further comprises: in a case where the PCIe device control package service obtains access requests of multiple access services for a target PCIe device, selecting a current to-be-executed access request from each access request according to a preset execution order; sending the current to-be-executed access request to the target PCIe device through the target device handle by using the PCIe device control package service; receiving the response information of the current to-be-executed access request returned by the target PCIe device by using the PCIe device control package service; According to a preset execution sequence, a next access request is selected as a current to-be-executed access request from the access requests, and a step of executing is returned: using the PCIe device control package service to send the current to-be-executed access request to the target PCIe device through the target device handle, until all the access requests are sent.

5. The method of claim 1, wherein, In the case that the PCIe device control package service obtains multiple access requests of access services for a target PCIe device, the PCIe device control package service is used to access the target PCIe device through a target device handle, and response information of each access request returned by the target PCIe device is received. In the case that the PCIe device control package service obtains multiple access requests of access services for a target PCIe device, for each access request, the PCIe device control package service generates an access message of the access request, wherein the access message includes a message identifier, and the message identifiers of the access messages generated within a preset time period are different. Each access message is sent to the target PCIe device through the target device handle using the PCIe device control package service. Response information of each access message returned by the target PCIe device is received, wherein the response information includes an information identifier, and the message identifier and the information identifier correspond one by one.

6. A communication system characterized by Comprise: A server and multiple PCIe devices, the server runs a PCIe device control package service; the control package service is a background program for data interaction with devices; The server is configured to use the PCIe device control package service to establish connections with the PCIe devices through the PCIe protocol respectively, and generate device handles of the PCIe devices, wherein for any PCIe device, after the PCIe device control package service establishes a connection with the PCIe device, the PCIe device control package service keeps occupying the PCIe device; In the case that the PCIe device control package service obtains multiple access requests of access services for a target PCIe device, the PCIe device control package service is used to access the target PCIe device through a target device handle, and response information of each access request returned by the target PCIe device is received; wherein the target PCIe device is one of the PCIe devices, and the target device handle is the device handle of the target PCIe device; For each access service, the PCIe device control package service returns response information of the access request of the access service to the access service.

7. The system of claim 6, wherein, The server is specifically configured to: Use the PCIe device control package service to enumerate all PCIe devices in the system, and establish connections between the PCIe device control package service and the enumerated PCIe devices according to the PCIe protocol respectively; For each PCIe device, the PCIe device control package service generates a device handle representing the connection with the PCIe device.

8. The system of claim 6 or 7, wherein, The system further comprises a plurality of terminals; each of the PCIe devices is connected to at least one terminal; The server is further configured to: for each PCIe device, use the PCIe device control package service to enumerate each terminal connected to the PCIe device through a device handle of the PCIe device, and generate a terminal handle of each terminal connected to the PCIe device.

9. The system of claim 6, wherein, The server is specifically configured to: In a case where the PCIe device control package service obtains access requests of a plurality of access services for a target PCIe device, select a current access request to be executed among the access requests according to a preset execution order; use the PCIe device control package service to send the current access request to be executed to the target PCIe device through the target device handle; use the PCIe device control package service to receive response information of the current access request to be executed returned by the target PCIe device; select a next access request as the current access request to be executed among the access requests according to the preset execution order, and return to the step of using the PCIe device control package service to send the current access request to be executed to the target PCIe device through the target device handle until all the access requests are sent.

10. The system of claim 6, wherein, The server is specifically configured to: in a case where the PCIe device control package service obtains access requests of a plurality of access services for a target PCIe device, for each access request, use the PCIe device control package service to generate an access message of the access request, wherein the access message comprises a message identifier, and message identifiers of access messages generated within a preset time period are different; and use the PCIe device control package service to send the access messages to the target PCIe device through the target device handle; The target PCIe device is configured to: after receiving the access messages, for each access message, execute a request corresponding to the access message to obtain an execution result of the access message; generate an information identifier uniquely corresponding to the message identifier of the access message; add the information identifier corresponding to the access message to the execution result of the access message to obtain response information of the access message; and send the response information of the access message to the PCIe device control package service; The server is specifically configured to: receive the response information of each access message returned by the target PCIe device, wherein the response information comprises an information identifier, and the message identifier and the information identifier one-to-one correspond.

11. A PCIe device access apparatus, characterized by, The device comprises: A first processing module is configured to use a PCIe device control package service to establish connections with each PCIe device through a PCIe protocol respectively, and generate a device handle of each PCIe device, wherein for any one PCIe device, the PCIe device control package service keeps occupying the PCIe device after the PCIe device control package service establishes a connection with the PCIe device; and the control package service is a background program for data interaction with a device. The second processing module is configured to, in a case where the PCIe device control packet service obtains access requests of a plurality of access services for a target PCIe device, access the target PCIe device through a target device handle by using the PCIe device control packet service, and receive response information of each of the access requests returned by the target PCIe device; wherein the target PCIe device is one of the plurality of PCIe devices, and the target device handle is a device handle of the target PCIe device. The returning module is configured to, for each access service, return, by using the PCIe device control packet service, response information of an access request of the access service to the access service.

12. The apparatus of claim 11, wherein, The first processing module is specifically configured to: enumerate each PCIe device in a system by using a PCIe device control packet service, and establish connections of the PCIe device control packet service and each PCIe device enumerated according to a PCIe protocol; for each PCIe device, generate a device handle representing a connection of the PCIe device by using the PCIe device control packet service; The device further comprises: The second processing module is configured to, for each PCIe device, enumerate each terminal connected to the PCIe device by using the PCIe device control packet service through a device handle of the PCIe device, and generate a terminal handle of each terminal connected to the PCIe device. The second processing module is specifically configured to: in a case where the PCIe device control packet service obtains access requests of a plurality of access services for a target PCIe device, select, in each of the access requests, a current to-be-executed access request according to a preset execution order; send, by using the PCIe device control packet service, the current to-be-executed access request to the target PCIe device through the target device handle; receive, by using the PCIe device control packet service, response information of the current to-be-executed access request returned by the target PCIe device; select, in each of the access requests, a next access request as the current to-be-executed access request according to the preset execution order, and return to the step of sending, by using the PCIe device control packet service, the current to-be-executed access request to the target PCIe device through the target device handle until each of the access requests is sent completely; The second processing module is specifically configured to: in a case where the PCIe device control packet service obtains access requests of a plurality of access services for a target PCIe device, for each access request, generate, by using the PCIe device control packet service, an access message of the access request, wherein the access message comprises a message identifier, and message identifiers of access messages generated within a preset time period are different; send, by using the PCIe device control packet service, each of the access messages to the target PCIe device through a target device handle; receive response information of each of the access messages returned by the target PCIe device, wherein the response information comprises an information identifier, and the message identifier and the information identifier correspond to each other.

13. An electronic device, comprising: comprise: a memory for storing a computer program; A processor is configured to implement the method of any one of claims 1-5 when executing a program stored in a memory.

14. A computer-readable storage medium, characterized in that, A computer program is stored in the computer readable storage medium and is configured to implement the method of any one of claims 1-5 when executed by a processor.

Citation Information

Patent Citations

  • Computing system

    CN109166074A

  • Data processing method and device and electronic equipment

    CN113364818A