CN115905095A - USB drive-free communication method, device, electronic equipment and storage medium - Google Patents

USB drive-free communication method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115905095A
CN115905095A CN202211352609.6A CN202211352609A CN115905095A CN 115905095 A CN115905095 A CN 115905095A CN 202211352609 A CN202211352609 A CN 202211352609A CN 115905095 A CN115905095 A CN 115905095A
Authority
CN
China
Prior art keywords
usb
equipment
usbfs
driver
drive
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211352609.6A
Other languages
Chinese (zh)
Inventor
赵飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fibocom Wireless Inc
Original Assignee
Fibocom Wireless Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fibocom Wireless Inc filed Critical Fibocom Wireless Inc
Priority to CN202211352609.6A priority Critical patent/CN115905095A/en
Publication of CN115905095A publication Critical patent/CN115905095A/en
Priority to PCT/CN2023/118583 priority patent/WO2024093542A1/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Information Transfer Systems (AREA)

Abstract

The application discloses a USB drive-free communication method, a USB drive-free communication device, electronic equipment and a storage medium, wherein the method comprises the following steps: enumerating the inserted USB equipment to obtain enumeration information of the USB equipment; determining a main device number and a secondary device number which are created in the host device by the USB device according to the enumeration information; creating character equipment according to the main equipment number and the secondary equipment number; binding the USB equipment with the usbfs drive through the character equipment; and communicating with the USB device through the usbfs driver. Therefore, the serial number of the primary device and the secondary device created by the USB device in the system is determined through enumeration information to create corresponding character devices, and then the IOCTL command is executed through the character devices to bind the USB device and the usbfs drive of the kernel. And then the USB device can directly use the universal usbfs driver in the kernel to carry out data communication without depending on the specific driver of a manufacturer.

Description

USB drive-free communication method, device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of USB equipment data transmission, in particular to a USB drive-free communication method and device, electronic equipment and a storage medium.
Background
The wireless communication module is widely applied to products such as a PC (personal computer), a tablet computer, an industrial gateway and the like by means of a cellular communication network of an operator, and provides a wireless bridge for interconnection of everything for electronic terminal products such as consumption and industry. At present, if a wireless communication module needs to realize functions such as LOG capture or upgrade in an embedded linux host environment through a USB port, an existing chip solution supplier generally provides the functions which can be completed only by installing a special driver of a manufacturer. However, the embedded linux system cannot complete the drive integration of each manufacturer due to customer tailoring, high customization and cost reasons, so that the module application is limited.
Disclosure of Invention
In order to solve the above problems in the prior art, embodiments of the present application provide a USB drive-free communication method, apparatus, electronic device, and storage medium, which enable a USB device to directly use a usbfs driver that is commonly used in a kernel for data communication without relying on a specific driver of a manufacturer.
In a first aspect, an embodiment of the present application provides a USB drive-free communication method, which specifically includes:
enumerating the inserted USB equipment to obtain enumeration information of the USB equipment;
determining a main device number and a secondary device number which are created in the host device by the USB device according to the enumeration information;
creating character equipment according to the main equipment number and the secondary equipment number;
binding the USB equipment and the usbfs driver through character equipment, wherein the usbfs driver is configured in a kernel of the host equipment in advance;
and communicating with the USB device through the usbfs driver.
In one embodiment of the present invention, enumerating an inserted USB device to obtain enumeration information of the USB device includes:
reading the supplier identification and the product identification code of the USB equipment through the inserted interface;
and matching in a preset path directory according to the supplier identity and the product identification code to obtain enumeration information of the USB equipment.
In one embodiment of the present invention, the creating a character device according to a primary device number and a secondary device number includes:
and dynamically creating character equipment through an mknod interface according to the number of the main equipment and the number of the secondary equipment.
In an embodiment of the present invention, before the USB device is bound to the usbfs driver by the character device, the method further includes:
the IOCTL command is run through the character equipment, and whether the USB equipment loads the driver or not is determined;
and when the USB equipment loads the drive, releasing the binding relationship between the USB equipment and the drive.
In one embodiment of the present invention, the communicating with the USB device through the usbfs driver includes:
creating a read thread through usbfs driving;
and binding the read thread with the endpoint of the input direction so as to acquire the data in the USB equipment through reading the endpoint of the input direction in a thread-reading blocking mode.
In one embodiment of the present invention, the method for communicating with a USB device through a usbfs driver further includes:
creating a write thread through usbfs driving;
and binding the write thread with the endpoint of the output direction, so that the write thread writes data into the endpoint of the output direction and writes the data into the USB equipment.
In one embodiment of the present invention, writing data to an endpoint of an output direction by a write thread includes:
assembling data into a URB BULK packet through a write thread;
the URB BULK packet is written to the end of the output direction.
In a second aspect, an embodiment of the present application provides a USB drive-free communication device, which specifically includes:
the enumeration module is used for enumerating the inserted USB equipment to obtain enumeration information of the USB equipment;
the analysis module is used for determining a main device number and a secondary device number which are created in the host device by the USB device according to the enumeration information;
and the communication module is used for establishing character equipment according to the main equipment number and the secondary equipment number, binding the USB equipment with the usbfs driver through the character equipment, wherein the usbfs driver is preconfigured in the kernel of the host equipment, and communicating with the USB equipment through the usbfs driver.
In a third aspect, an embodiment of the present application provides an electronic device, including: a processor coupled to the memory, the memory for storing a computer program, the processor for executing the computer program stored in the memory to cause the electronic device to perform the method of the first aspect.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium storing a computer program, the computer program causing a computer to perform the method of the first aspect.
In a fifth aspect, embodiments of the present application provide a computer program product comprising a non-transitory computer readable storage medium storing a computer program, the computer operable to cause the computer to perform a method according to the first aspect.
The implementation of the embodiment of the application has the following beneficial effects:
in the embodiment of the application, the serial numbers of the primary device and the secondary device created by the USB device in the system are determined through enumeration information of the USB device, and then corresponding character devices are created according to the serial numbers of the primary device and the secondary device. And executing an IOCTL command through the character equipment, and binding the USB equipment and the usbfs drive of the kernel. Therefore, the USB device can directly use the usbfs driver commonly used in the kernel for data communication without depending on the specific driver of a manufacturer.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a schematic hardware structure diagram of a USB drive-free communication device according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of a USB drive-free communication method according to an embodiment of the present disclosure;
fig. 3 is a block diagram illustrating functional modules of a USB drive-free communication device according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without making creative efforts shall fall within the protection scope of the present application.
The terms "first," "second," "third," and "fourth," etc. in the description and claims of this application and in the accompanying drawings are used for distinguishing between different elements and not for describing a particular sequential order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, result, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
First, referring to fig. 1, fig. 1 is a schematic diagram of a hardware structure of a USB drive-free communication device according to an embodiment of the present disclosure. The USB drive-free communication device 100 includes at least one processor 101, a communication line 102, a memory 103, and at least one communication interface 104.
In this embodiment, the processor 101 may be a general processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more ics for controlling the execution of programs according to the present disclosure.
The communication link 102, which may include a path, carries information between the aforementioned components.
The communication interface 104 may be any transceiver or other device (e.g., an antenna, etc.) for communicating with other devices or communication networks, such as an ethernet, RAN, wireless Local Area Network (WLAN), etc.
The memory 103 may be, but is not limited to, a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a Random Access Memory (RAM) or other type of dynamic storage device that can store information and instructions, an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disk storage, optical disk storage (including compact disc, laser disc, optical disc, digital versatile disc, blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer.
In this embodiment, the memory 103 may be independent and connected to the processor 101 through the communication line 102. The memory 103 may also be integrated with the processor 101. The memory 103 provided in the embodiments of the present application may generally have a nonvolatile property. The memory 103 is used for storing computer-executable instructions for executing the scheme of the application, and is controlled by the processor 101 to execute. The processor 101 is configured to execute computer-executable instructions stored in the memory 103, thereby implementing the methods provided in the embodiments of the present application described below.
In alternative embodiments, computer-executable instructions may also be referred to as application code, which is not specifically limited in this application.
In alternative embodiments, processor 101 may include one or more CPUs, such as CPU0 and CPU1 of FIG. 1.
In an alternative embodiment, the USB drive-free communication device 100 may include a plurality of processors, such as the processor 101 and the processor 107 in fig. 1. Each of these processors may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor. A processor herein may refer to one or more devices, circuits, and/or processing cores that process data (e.g., computer program instructions).
In an alternative embodiment, if the USB drive-free communication device 100 is a server, for example, the USB drive-free communication device may be an independent server, or may be a cloud server that provides basic cloud computing services such as cloud service, cloud database, cloud computing, cloud function, cloud storage, web service, cloud communication, middleware service, domain name service, security service, content Delivery Network (CDN), big data, and artificial intelligence platform. The USB drive-free communication device 100 may further include an output device 105 and an input device 106. The output device 105 is in communication with the processor 101 and may display information in a variety of ways. For example, the output device 105 may be a Liquid Crystal Display (LCD), a Light Emitting Diode (LED) display device, a Cathode Ray Tube (CRT) display device, a projector (projector), or the like. The input device 106 is in communication with the processor 101 and may receive user input in a variety of ways. For example, the input device 106 may be a mouse, a keyboard, a touch screen device, or a sensing device, among others.
The USB drive-free communication apparatus 100 may be a general-purpose device or a special-purpose device. The embodiment of the present application does not limit the type of the USB drive-free communication device 100.
Hereinafter, the USB drive-free communication method disclosed in the present application will be described:
referring to fig. 2, fig. 2 is a schematic flowchart of a USB drive-free communication method according to an embodiment of the present disclosure, which may specifically include the following steps:
201: enumerating the inserted USB equipment to obtain enumeration information of the USB equipment.
Enumeration is to make host controller recognize USB device and prepare resources for it, and establish a data transfer mechanism between host and device. The operation at this stage is specified by the USB communication protocol, and therefore belongs to the ISO standard flow. The device enumeration phase also corresponds to five states of the USB device. Namely: after the USB equipment is inserted into the interface, the USB equipment is in an Attached state; the USB main controller can supply power to the USB equipment, and is in a Powered state at the moment; step 2 of the equipment enumeration stage, after the reset operation, the equipment is in a Default state; step 3 of the device enumeration stage, after the address setting operation, the device is in an Addressed state; after device enumeration is complete, the device is in the Configured state.
Specifically, the device enumeration phase may be divided into the following 8 steps: 1. acquiring a device descriptor; 2. resetting; 3. setting an address; 4. acquiring the device descriptor again; 5. acquiring a configuration descriptor; 6. acquiring an interface and an endpoint descriptor; 7. acquiring a character string descriptor; 8. a setting configuration is selected. Wherein, steps 1 and 4 are to obtain the device descriptor. However, only the fixed length field of the device descriptor is retrieved in step 1, while step 4 is to obtain all the fields of the device descriptor. Through the above 8 steps, in the device enumeration phase, the host controller acquires all the detailed information (5 large descriptors) of the USB device, and then allocates resources (sets addresses) to it.
Based on this, in this embodiment, the inserted USB device may be enumerated through the inserted interface, the device descriptor of the USB device is read, and then the vendor Identification Number (VID) and the Product Identification Number (PID) of the USB device are determined according to field division in the device descriptor. Then, according to the VID and PID of the USB device, in a preset path directory, for example: and matching in the sys/bus/USB directory to obtain enumeration information of the USB equipment.
202: and determining a primary device number and a secondary device number which are created in the host device by the USB device according to the enumeration information.
The Linux device management is tightly combined with a file system, and various devices are stored in a/dev directory in a file form, which is called a device file. The application program can open, close and read and write the device files to complete the operation on the device, just like operating ordinary data files. To manage these devices, the system numbers the devices, each device number being further divided into a primary device number and a secondary device number. Wherein the primary device number is used to distinguish between different types of devices and the secondary device number is used to distinguish between multiple devices of the same type. In this embodiment, the device file may be searched through enumeration information, bNumInterfaces information may be obtained, the number of ports enumerated by the current module may be obtained, and then the primary device number and the secondary device number created by the USB device in the host may be determined according to the uevent.
203: and creating character equipment according to the main equipment number and the secondary equipment number.
The character device is a self-defined device structure in Linux, can provide continuous data streams, and Input/Output (I/O) devices which can be read sequentially by an application program. Generally, reading and writing data by byte self/character is supported, and random access is not supported. Specifically, in this embodiment, a character device can be dynamically created through an mknow interface according to the primary device number and the secondary device number.
204: and binding the USB equipment with the usbfs drive through the character equipment.
In this embodiment, the usbfs driver is pre-configured in the kernel of the host device, that is, is a general driver with its own kernel. Specifically, before rebinding, it is also necessary to determine the driver loading condition of the USB device, i.e. whether some drivers are automatically loaded. In this embodiment, the USB device may be opened by the created character device through a system call open, and then the IOCTL USB flash _ get command is executed to query whether the USB device has loaded other drivers.
At this time, if the query result indicates that the USB device automatically loads the usbfs driver, the next step may be directly performed. And if the other drivers are loaded, removing the binding relationship between the USB equipment and the other drivers, and binding the USB equipment and the usbfs driver through an IOCTL USBDEVFS _ CLAIMINTERFACE command.
205: and communicating with the USB device through the usbfs driver.
In the present embodiment, first, a data port used by the USB device for communication is determined by PID, and an Endpoint (EP) in the input direction and an EP in the output direction of the USB device are set based on the data port.
Then, in this embodiment, the usbfs driver may create a read thread through the data port, and construct a usbdevfs _ BULK transfer BULK read request through the read thread, to request to bind an EP in the input direction. And then after binding is finished, acquiring data in the USB equipment to a user buffer area through the EP in the USBDEVFS _ BULK IOCTL blocking type reading input direction, and finishing reading the USB equipment.
Finally, in this embodiment, the usbfs driver may create a write thread through the data port, and construct a usbdevfs _ URB write request through the write thread, requesting to bind an EP in the output direction. And then after the binding is finished, assembling the data of the user buffer area into a URB BULK packet, writing the URB BULK packet into an EP (enhanced peripheral language) in the output direction through a USBDEVFS _ SUBMITURB IOCTL, transmitting the data of the user buffer area to a controller of the USB equipment, and finishing the writing of the USB equipment.
In summary, in the USB drive-free communication method provided by the present invention, the serial numbers of the primary device and the secondary device created by the USB device in the system are determined through the enumeration information of the USB device, and then the corresponding character devices are created according to the serial numbers of the primary device and the secondary device. And executing an IOCTL command through the character equipment, and binding the USB equipment and the usbfs drive of the kernel. And then the USB device can directly use the universal usbfs driver in the kernel to carry out data communication without depending on the specific driver of a manufacturer.
Referring to fig. 3, fig. 3 is a block diagram illustrating functional modules of a USB drive-free communication device according to an embodiment of the present invention, specifically, as shown in fig. 3, the USB drive-free communication device 300 includes:
an enumeration module 301, configured to enumerate the inserted USB device to obtain enumeration information of the USB device;
an analysis module 302, configured to determine, according to the enumeration information, a primary device number and a secondary device number that are created by the USB device in the host device;
the communication module 303 is configured to create a character device according to the primary device number and the secondary device number, and bind the USB device with the usbfs driver through the character device, where the usbfs driver is preconfigured in the kernel of the host device and communicates with the USB device through the usbfs driver.
In an embodiment of the present invention, in enumerating an inserted USB device to obtain enumeration information of the USB device, the enumeration module 301 is specifically configured to:
reading the supplier identification and the product identification code of the USB equipment through the inserted interface;
and matching in a preset path directory according to the supplier identity and the product identification code to obtain enumeration information of the USB equipment.
In the embodiment of the present invention, in terms of creating a character device according to the primary device number and the secondary device number, the communication module 303 is specifically configured to:
and dynamically creating character equipment through an mknow interface according to the number of the primary equipment and the number of the secondary equipment.
In an embodiment of the present invention, before the USB device is bound to the usbfs driver by the character device, the communication module 303 is further configured to:
the IOCTL command is run through the character equipment, and whether the USB equipment loads the driver or not is determined;
and when the USB equipment loads the driver, releasing the binding relationship between the USB equipment and the driver.
In the embodiment of the present invention, in terms of communicating with the USB device through the usbfs driver, the communication module 303 is specifically configured to:
creating a read thread through usbfs driving;
and binding the read thread with the endpoint of the input direction so as to acquire the data in the USB equipment through the endpoint of the read thread blocking type read input direction.
In the embodiment of the present invention, in terms of communicating with the USB device through the usbfs driver, the communication module 303 is further configured to:
creating a write thread through usbfs driving;
and binding the write thread with the endpoint of the output direction, so that the write thread writes data into the endpoint of the output direction and writes the data into the USB equipment.
In an embodiment of the present invention, in terms of writing data to an endpoint of an output direction through a write thread, the communication module 303 is specifically configured to:
assembling data into a URB BULK packet through a write thread;
the URB BULK packet is written to the end of the output direction.
Referring to fig. 4, fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. As shown in fig. 4, the electronic device 400 includes a transceiver 401, a processor 402, and a memory 403. Connected to each other by a bus 404. The memory 403 is used for storing computer programs and data, and may transmit the data stored in the memory 403 to the processor 402.
Wherein the processor 402 is configured to read the computer program in the memory 403 to perform the following operations:
enumerating the inserted USB equipment to obtain enumeration information of the USB equipment;
determining a main device number and a secondary device number which are created in the host device by the USB device according to the enumeration information;
creating character equipment according to the main equipment number and the secondary equipment number;
binding the USB equipment and the usbfs driver through character equipment, wherein the usbfs driver is configured in a kernel of the host equipment in advance;
and communicating with the USB device through the usbfs driver.
In an embodiment of the present invention, in terms of enumerating the plugged USB device to obtain enumeration information of the USB device, the processor 402 is specifically configured to perform the following operations:
reading the supplier identity and the product identification code of the USB equipment through the inserted interface;
and matching in a preset path directory according to the supplier identity and the product identification code to obtain enumeration information of the USB equipment.
In an embodiment of the present invention, in creating a character device according to the primary device number and the secondary device number, the processor 402 is specifically configured to perform the following operations:
and dynamically creating character equipment through an mknod interface according to the number of the main equipment and the number of the secondary equipment.
In an embodiment of the present invention, before the USB device is bound to the usbfs driver by the character device, the processor 402 is further configured to:
the IOCTL command is run through the character equipment, and whether the USB equipment loads the driver or not is determined;
and when the USB equipment loads the drive, releasing the binding relationship between the USB equipment and the drive.
In the embodiment of the present invention, in terms of communicating with the USB device through the usbfs driver, the processor 402 is specifically configured to perform the following operations:
creating a read thread through usbfs driving;
and binding the read thread with the endpoint of the input direction so as to acquire the data in the USB equipment through the endpoint of the read thread blocking type read input direction.
In the embodiment of the present invention, in terms of communicating with the USB device through the usbfs driver, the processor 402 is further configured to:
creating a write thread through usbfs driving;
and binding the write thread with the endpoint of the output direction, so that the write thread writes data into the endpoint of the output direction and writes the data into the USB equipment.
In an embodiment of the present invention, in terms of writing data to an endpoint of an output direction by a write thread, the processor 402 is specifically configured to:
assembling data into a URB BULK packet through a write thread;
the URB BULK packet is written to the end of the output direction.
It should be understood that the USB drive-free communication device in the present application may include a smart Phone (e.g., an Android Phone, an iOS Phone, a Windows Phone, etc.), a tablet computer, a palm computer, a notebook computer, a Mobile Internet device MID (MID), a robot, or a wearable device. The USB driver-free communication device is merely an example, and is not exhaustive, and includes but is not limited to the USB driver-free communication device. In practical applications, the USB drive-free communication device may further include: intelligent vehicle-mounted terminal, computer equipment and the like.
Through the above description of the embodiments, those skilled in the art will clearly understand that the present invention may be implemented by combining software and a hardware platform. With this understanding in mind, all or part of the technical solutions of the present invention that contribute to the background can be embodied in the form of a software product, which can be stored in a storage medium, such as a ROM/RAM, a magnetic disk, an optical disk, etc., and includes instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods according to the embodiments or some parts of the embodiments.
Therefore, the present application also provides a computer-readable storage medium, which stores a computer program, where the computer program is executed by a processor to implement part or all of the steps of any one of the USB drive-free communication methods as described in the above method embodiments. For example, the storage medium may include a hard disk, a floppy disk, an optical disk, a magnetic tape, a magnetic disk, a flash memory, and the like.
Embodiments of the present application further provide a computer program product comprising a non-transitory computer readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any one of the USB drive-free communication methods as described in the above method embodiments.
It should be noted that for simplicity of description, the above method embodiments are described as a series of acts, but those skilled in the art should understand that the present application is not limited by the described order of acts, as some steps may be performed in other orders or simultaneously according to the present application. Furthermore, those skilled in the art should also appreciate that the embodiments described in the specification are optional embodiments and that the acts and modules referred to are not necessarily required for the application.
In the above embodiments, the description of each embodiment has its own emphasis, and for parts not described in detail in a certain embodiment, reference may be made to the description of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one type of logical function division, and other division may be implemented in practice, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not implemented. In addition, the shown or discussed coupling or direct coupling or communication connection between each other may be through some interfaces, indirect coupling or communication connection between devices or units, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit. The integrated unit may be implemented in the form of hardware, or may be implemented in the form of a software program module.
The integrated units, if implemented in the form of software program modules and sold or used as stand-alone products, may be stored in a computer readable memory. Based on such understanding, the technical solution of the present application may be substantially implemented or a part of or all or part of the technical solution contributing to the prior art may be embodied in the form of a software product stored in a memory, and including several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method described in the embodiments of the present application. And the aforementioned memory comprises: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by associated hardware instructed by a program, which may be stored in a computer-readable memory, and the memory may include: flash Memory disks, read-Only memories (ROMs), random Access Memories (RAMs), magnetic or optical disks, and the like.
The foregoing detailed description of the embodiments of the present application has been presented to illustrate the principles and implementations of the present application, and the above description of the embodiments is only provided to help understand the methods and their core ideas of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, the specific implementation manner and the application scope may be changed, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A USB drive-free communication method, the method comprising:
enumerating the inserted USB equipment to obtain enumeration information of the USB equipment;
determining a primary device number and a secondary device number which are created in the host device by the USB device according to the enumeration information;
creating character equipment according to the main equipment number and the secondary equipment number;
binding the USB equipment with a usbfs driver through the character equipment, wherein the usbfs driver is pre-configured in a kernel of the host equipment;
and communicating with the USB equipment through the usbfs drive.
2. The method according to claim 1, wherein the enumerating the plugged-in USB device to obtain enumeration information of the USB device comprises:
reading the supplier identification and the product identification code of the USB equipment through the inserted interface;
and matching in a preset path directory according to the supplier identity and the product identification code to obtain enumeration information of the USB equipment.
3. The method of claim 1, wherein creating a character device from the primary device number and the secondary device number comprises:
and dynamically creating the character equipment through an mknod interface according to the main equipment number and the secondary equipment number.
4. The method of claim 1, wherein before the binding the USB device with the usbfs driver by the character device, the method further comprises:
running an IOCTL command through the character equipment to determine whether the USB equipment is loaded with a driver;
and when the USB equipment loads the driver, releasing the binding relationship between the USB equipment and the driver.
5. The method according to any of claims 1-4, wherein the communicating with the USB device through the usbfs driver comprises:
creating a read thread through the usbfs drive;
and binding the reading thread with the endpoint of the input direction so as to acquire the data in the USB equipment by reading the endpoint of the input direction in a reading thread blocking manner.
6. The method according to any of claims 1-4, wherein the communicating with the USB device via the usbfs driver further comprises:
creating a write thread through the usbfs drive;
and binding the write thread with an endpoint in the output direction, so as to write data into the endpoint in the output direction through the write thread and write the data into the USB equipment.
7. The method of claim 6, wherein the writing data to the end point of the output direction by the write thread comprises:
assembling data into a URB BULK packet through the write thread;
and writing the URB BULK packet into the end point of the output direction.
8. A USB drive-free communication device, the device comprising:
the enumeration module is used for enumerating the inserted USB equipment to obtain enumeration information of the USB equipment;
the analysis module is used for determining a main device number and a secondary device number which are created in the host device by the USB device according to the enumeration information;
and the communication module is used for establishing character equipment according to the main equipment number and the secondary equipment number, binding the USB equipment with the usbfs drive through the character equipment, wherein the usbfs drive is preconfigured in the kernel of the host equipment, and communicating with the USB equipment through the usbfs drive.
9. An electronic device comprising a processor, memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, the one or more programs including instructions for performing the steps of any of claims 1-7.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which is executed by a processor to implement the method according to any one of claims 1-7.
CN202211352609.6A 2022-10-31 2022-10-31 USB drive-free communication method, device, electronic equipment and storage medium Pending CN115905095A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202211352609.6A CN115905095A (en) 2022-10-31 2022-10-31 USB drive-free communication method, device, electronic equipment and storage medium
PCT/CN2023/118583 WO2024093542A1 (en) 2022-10-31 2023-09-13 Usb drive-free communication method and apparatus, and electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211352609.6A CN115905095A (en) 2022-10-31 2022-10-31 USB drive-free communication method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115905095A true CN115905095A (en) 2023-04-04

Family

ID=86494170

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211352609.6A Pending CN115905095A (en) 2022-10-31 2022-10-31 USB drive-free communication method, device, electronic equipment and storage medium

Country Status (2)

Country Link
CN (1) CN115905095A (en)
WO (1) WO2024093542A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024093542A1 (en) * 2022-10-31 2024-05-10 深圳市广和通无线股份有限公司 Usb drive-free communication method and apparatus, and electronic device and storage medium
CN118075115A (en) * 2024-04-19 2024-05-24 深圳奇迹智慧网络有限公司 Mounting method of Internet of things equipment, mounting device of Internet of things equipment and medium
CN118075115B (en) * 2024-04-19 2024-07-09 深圳奇迹智慧网络有限公司 Mounting method of Internet of things equipment, mounting device of Internet of things equipment and medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105488000B (en) * 2015-12-23 2018-09-14 数安时代科技股份有限公司 Realize the method and system that USB device quickly accesses
CN109947482B (en) * 2017-12-21 2022-07-29 深圳Tcl新技术有限公司 Loading method of USB (universal serial bus) equipment, storage medium and smart television
CN109144586A (en) * 2018-08-03 2019-01-04 彩讯科技股份有限公司 A kind of driving adaptation method, device, computer equipment and storage medium
US10963406B2 (en) * 2019-06-18 2021-03-30 Intel Corporation Persistent universal serial bus (USB) device enumeration
CN111104075B (en) * 2019-12-18 2023-11-07 北京数衍科技有限公司 USB equipment simulation device and method
CN115905095A (en) * 2022-10-31 2023-04-04 深圳市广和通无线股份有限公司 USB drive-free communication method, device, electronic equipment and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024093542A1 (en) * 2022-10-31 2024-05-10 深圳市广和通无线股份有限公司 Usb drive-free communication method and apparatus, and electronic device and storage medium
CN118075115A (en) * 2024-04-19 2024-05-24 深圳奇迹智慧网络有限公司 Mounting method of Internet of things equipment, mounting device of Internet of things equipment and medium
CN118075115B (en) * 2024-04-19 2024-07-09 深圳奇迹智慧网络有限公司 Mounting method of Internet of things equipment, mounting device of Internet of things equipment and medium

Also Published As

Publication number Publication date
WO2024093542A1 (en) 2024-05-10

Similar Documents

Publication Publication Date Title
US10282192B1 (en) Updating device code through a bus
US10241951B1 (en) Device full memory access through standard PCI express bus
CN106557340B (en) Configuration method and device
US8645594B2 (en) Driver-assisted base address register mapping
JPH0836539A (en) Pcmcia interface and method for communication between user application and pc card
US9098640B2 (en) Controller, electronic equipment unit, and USB device control method
CN103645945A (en) Automatic probing and drive loading method of virtual network interface card
CN113010470B (en) Edge node remote control system, method, equipment and storage medium
CN103858111A (en) Methods, equipment and system for realizing memory sharing in aggregation virtualization
WO2024093542A1 (en) Usb drive-free communication method and apparatus, and electronic device and storage medium
US6105080A (en) Host adapter DMA controller with automated host reply capability
CN112214247A (en) System starting method and related equipment
KR20200001208A (en) Convergence Semiconductor Apparatus and Operation Method Thereof, Stacked Memory Apparatus Having the Same
CN103092648A (en) Method and system of mirror image upgrade and user device and personal computer
CN112506676B (en) Inter-process data transmission method, computer device and storage medium
CN104714792A (en) Multi-process shared data processing method and device
CN112860595B (en) PCI (peripheral component interconnect express) equipment or PCIE (peripheral component interconnect express) equipment, data access method and related assembly
CN115878327A (en) Bus reservation method, device, server, electronic equipment and storage medium
CN106922189B (en) Equipment agent device and control method thereof
CN101561760A (en) Method for upgrading firmware of interface card
CN101562007A (en) Display control device capable of automatically updating firmware and update method thereof
CN111427817A (en) Method for sharing I2C interface by dual cores of AMP system, storage medium and intelligent terminal
US10803008B2 (en) Flexible coupling of processor modules
CN101436134A (en) Method and system for setting state of hardware apparatus
CN113141603B (en) Data communication method, system, master terminal device and slave terminal device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination