Data transmission method, device, computer equipment and readable storage medium

By detecting the network connection status between the USB device and the host device and enabling appropriate auxiliary communication functions, the problem of low data transmission efficiency when performing different functions of the USB device is solved, and efficient data transmission and flexible communication function applications are achieved.

CN119739666APending Publication Date: 2025-04-01BEIJING SMARTMORE INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411599426.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-04-01

AI Technical Summary

Technical Problem

USB devices need to switch data transmission channels when performing different functions, resulting in low data transmission efficiency.

Method used

Connect to the host device through a USB interface, detect the network connection status, determine the candidate auxiliary communication function, and enable the appropriate auxiliary communication function for data transmission based on the pre-entered communication configuration information.

Benefits of technology

It realizes the functional integration and adaptability of multiple auxiliary communication functions of USB devices, improves data transmission efficiency, meets the communication needs of USB devices, and saves the resource usage of unnecessary auxiliary communication functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119739666A_ABST
    Figure CN119739666A_ABST
Patent Text Reader

Abstract

The present application relates to a data transmission method, device, computer equipment and computer-readable storage medium. The method comprises: connecting with a host device through a USB interface, detecting the network connection status with the host device; determining a candidate auxiliary communication function from a plurality of auxiliary communication functions provided by the USB device based on the network connection status; determining an auxiliary communication function to be enabled from the candidate auxiliary communication functions based on pre-entered communication configuration information; switching the working state of the auxiliary communication function to be enabled to an on state, and performing data transmission with the host device based on the enabled auxiliary communication function. The use of this method can improve the efficiency of data transmission.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data transmission, and in particular to a data transmission method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art

[0002] A USB device is a piece of hardware at the end of a USB (Universal Serial Bus) cable that can perform user functions, such as a barcode scanner, touchpad, display, etc. A USB device communicates with a host device (such as a computer) through a USB cable. However, since a USB cable has a single function, such as the HID (Human Interface Device) function, when a USB device performs different functions and transmits different data to a host device, it is necessary to switch the corresponding data transmission channel. For example, when configuring a USB device, it is necessary to switch the network communication function to configure the USB device, resulting in low data transmission efficiency of the USB device. Summary of the invention

[0003] Based on this, it is necessary to provide a data transmission method, apparatus, computer equipment, computer-readable storage medium and computer program product that can improve the data transmission efficiency of USB devices in response to the above technical problems.

[0004] In a first aspect, the present application provides a data transmission method, comprising:

[0005] Connect to the host device via the USB interface to detect the network connection status with the host device;

[0006] Based on the network connection state, determining a candidate auxiliary communication function from a plurality of auxiliary communication functions provided by the USB device;

[0007] Based on the pre-recorded communication configuration information, determining the auxiliary communication function to be enabled from the candidate auxiliary communication functions;

[0008] The working state of the auxiliary communication function to be enabled is switched to an on state, and data is transmitted with the host device based on the enabled auxiliary communication function.

[0009] In a second aspect, the present application also provides a data transmission device, including:

[0010] A network detection module is used to connect to a host device through a USB interface and detect the network connection status with the host device;

[0011] The auxiliary communication module is selected to determine a candidate auxiliary communication function from a plurality of auxiliary communication functions provided by the USB device based on the network connection state; and to determine an auxiliary communication function to be enabled from the candidate auxiliary communication functions based on the pre-entered communication configuration information;

[0012] The auxiliary communication enabling module is used to switch the working state of the auxiliary communication function to be enabled to the on state, and to perform data transmission with the host device based on the enabled auxiliary communication function.

[0013] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0014] Connect to the host device via the USB interface to detect the network connection status with the host device;

[0015] Based on the network connection state, determining a candidate auxiliary communication function from a plurality of auxiliary communication functions provided by the USB device;

[0016] Based on the pre-recorded communication configuration information, determining the auxiliary communication function to be enabled from the candidate auxiliary communication functions;

[0017] The working state of the auxiliary communication function to be enabled is switched to an on state, and data is transmitted with the host device based on the enabled auxiliary communication function.

[0018] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:

[0019] Connect to the host device via the USB interface to detect the network connection status with the host device;

[0020] Based on the network connection state, determining a candidate auxiliary communication function from a plurality of auxiliary communication functions provided by the USB device;

[0021] Based on the pre-recorded communication configuration information, determining the auxiliary communication function to be enabled from the candidate auxiliary communication functions;

[0022] The working state of the auxiliary communication function to be enabled is switched to an on state, and data is transmitted with the host device based on the enabled auxiliary communication function.

[0023] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0024] Connect to the host device via the USB interface to detect the network connection status with the host device;

[0025] Based on the network connection state, determining a candidate auxiliary communication function from a plurality of auxiliary communication functions provided by the USB device;

[0026] Based on the pre-recorded communication configuration information, determining the auxiliary communication function to be enabled from the candidate auxiliary communication functions;

[0027] The working state of the auxiliary communication function to be enabled is switched to an on state, and data is transmitted with the host device based on the enabled auxiliary communication function.

[0028] The above-mentioned data transmission method, apparatus, computer equipment, computer-readable storage medium and computer program product, when connected to a host device via a USB interface of a USB device, detect the network connection status with the host device, determine a candidate auxiliary communication function from a plurality of auxiliary communication functions provided by the USB device according to the network status, and determine the auxiliary communication function to be enabled from the candidate auxiliary communication functions according to the communication configuration information, can realize the functional integration of a plurality of auxiliary communication functions through the USB device, and adaptively determine the auxiliary communication function to be enabled according to the network connection status and the communication configuration information, and perform data transmission with the host device through the enabled auxiliary communication function, thereby realizing the flexible application of the auxiliary communication function of the USB device, thereby improving the data transmission efficiency of the USB device; further, through the flexible application of the auxiliary communication function of the USB device, the communication requirements of the USB device are met, and the resources occupied by unnecessary auxiliary communication functions are saved. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0030] Figure 1 is an application environment diagram of a data transmission method in an embodiment;

[0031] Figure 2 A schematic diagram of a flow chart of a data transmission method in an embodiment;

[0032] Figure 3 A schematic diagram of a flow chart of a data transmission step in an embodiment;

[0033] Figure 4 A schematic diagram of a flow chart of a data transmission method in another embodiment;

[0034] Figure 5 A schematic diagram of device connection in an embodiment;

[0035] Figure 6 A schematic diagram of a barcode scanner startup process in one embodiment;

[0036] Figure 7 is a structural block diagram of a data transmission device in one embodiment;

[0037] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0038] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0039] The data transmission method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the USB device 102 communicates with the host device 104 through a USB cable. The USB device 102 is connected to the host device 104 through a USB interface, and detects the network connection status with the host device 104; the USB device 102 determines the candidate auxiliary communication function from the multiple auxiliary communication functions provided by the USB device 102 based on the network connection status; the USB device 102 determines the auxiliary communication function to be enabled from the candidate auxiliary communication functions based on the pre-entered communication configuration information; the USB device 102 switches the working state of the auxiliary communication function to be enabled to the on state, and transmits data with the host device 104 based on the enabled auxiliary communication function. Among them, the USB device 102 can be, but not limited to, various functional devices, such as storage devices: such as U disk, external hard disk drive, etc., input devices: such as keyboard, game controller, barcode scanner, etc., output devices: such as printer, display, etc. The host device 104 can be a computer device, a terminal, etc., and the terminal can be, but not limited to, various personal computers, laptops, smart phones, tablet computers, etc.

[0040] In an exemplary embodiment, Figure 2 As shown, a data transmission method is provided, which is applied to Figure 1 The USB device in the example is used as an example to illustrate, including the following steps:

[0041] Step 202, connecting to a host device via a USB interface, and detecting a network connection status with the host device.

[0042] Step 204 : determining a candidate auxiliary communication function from a plurality of auxiliary communication functions provided by the USB device based on the network connection status.

[0043] Among them, the host device is a device that transmits data with the USB device, which can be a computer device, terminal, etc., which is used to control and manage the USB device, and the USB device can be used as a slave device of the host device. The network connection status refers to the status of the physical network connection between the USB device and the host device, such as the network connection established by a physical network cable. The auxiliary communication function refers to the function of the supplementary communication capability provided by the USB device, such as the virtual network communication function, the physical serial port communication function, the virtual serial port communication function, etc. The candidate auxiliary communication function refers to the selectable auxiliary communication function that currently corresponds to the network connection status.

[0044] Specifically, the USB device is pre-deployed with auxiliary communication functions of various communication types, and is connected to the host device through the USB interface of the USB cable. After the USB device is connected to the host device through the USB interface, a network test instruction is sent to the host device, and the network connection status between the USB device and the host device is determined according to the response information of the host device based on the network test instruction, including a connected state and a disconnected state. Specifically, the network test instruction can be used to detect whether the USB cable has physical network cable hardware, and the network connection status refers to the physical network connection status based on the physical network cable hardware. When the USB cable has physical network cable hardware, when the USB device is connected to the host device through the USB cable, the physical network between the USB device and the host device is connected through the physical network hardware; when the USB device does not have physical network cable hardware, when the USB device is connected to the host device through the USB cable, the physical network between the USB device and the host device is not connected.

[0045] The USB device then determines a candidate auxiliary communication function from each auxiliary communication function based on the network connection status and the communication types corresponding to each auxiliary communication function. For example, it determines whether to use an auxiliary communication function with a communication type of network connection as a candidate auxiliary communication function based on the network connection status, thereby avoiding repeated network connections.

[0046] Step 206: Determine the auxiliary communication function to be enabled from the candidate auxiliary communication functions based on the pre-recorded communication configuration information.

[0047] The communication configuration information refers to the configuration information of the auxiliary communication function to be enabled in the USB device set according to the user's requirements. The auxiliary communication function to be enabled refers to the auxiliary communication function to be enabled in the current USB device.

[0048] Specifically, the USB device obtains pre-recorded communication configuration information from the local storage, and the communication configuration information records the enabling flags of various auxiliary communication functions provided by the USB device, such as 1 for enabling and 0 for not enabling. The USB device determines the auxiliary communication function to be enabled from the candidate auxiliary communication functions according to the enabling flags of various auxiliary communication functions in the communication configuration information.

[0049] Step 208: Switch the working state of the auxiliary communication function to be enabled to an on state, and perform data transmission with the host device based on the enabled auxiliary communication function.

[0050] Specifically, after determining the auxiliary communication function to be enabled, the USB device calls the software program corresponding to the auxiliary communication function to be enabled, and executes the corresponding program instructions through the processor to switch the working state of the auxiliary communication function to be enabled to the on state, thereby obtaining the enabled auxiliary communication function, and the USB device establishes a corresponding communication channel with the host device through the enabled auxiliary communication function. When the USB device receives the control instruction of the host device, it selects the corresponding communication channel according to the instruction content to transmit data to the host device in response to the control instruction.

[0051] In the above data transmission method, when the USB device is connected to the host device through the USB interface, the network connection status with the host device is detected, and a candidate auxiliary communication function is determined from a plurality of auxiliary communication functions provided by the USB device according to the network status, and the auxiliary communication function to be enabled is determined from the candidate auxiliary communication functions according to the communication configuration information. The function integration of the plurality of auxiliary communication functions can be realized through the USB device, and the auxiliary communication function to be enabled is adaptively determined according to the network connection status and the communication configuration information. Data is transmitted with the host device through the enabled auxiliary communication function, thereby realizing the flexible application of the auxiliary communication function of the USB device, thereby improving the data transmission efficiency of the USB device; further, through the flexible application of the auxiliary communication function of the USB device, the communication needs of the USB device are met, and the resources occupied by unnecessary auxiliary communication functions are saved.

[0052] In an exemplary embodiment, Figure 3 As shown, step 204, based on the network connection state, determines a candidate auxiliary communication function from a plurality of auxiliary communication functions provided by the USB device, including:

[0053] Step 302, when the network connection state is not connected, multiple auxiliary communication functions provided by the USB device are used as candidate auxiliary communication functions;

[0054] Step 304: when the network connection state is connected, determine the auxiliary communication function whose communication type belongs to non-network communication among the multiple auxiliary communication functions provided by the USB device as a candidate auxiliary communication function.

[0055] Specifically, the multiple auxiliary communication functions include auxiliary communication functions whose communication type is network communication and auxiliary communication functions whose communication type is non-network communication. When the USB device sends a network test instruction to the host device, and identifies that the network connection state is not connected according to the response information returned by the host device, it means that the physical network between the USB device and the host device is not connected. At this time, the auxiliary communication function whose communication type is network communication is also needed as a function to supplement the network communication, and the USB device will use all the auxiliary communication functions that can be provided as candidate auxiliary communication functions. When the USB device identifies that the network connection state is connected according to the response information returned by the host device, it means that the physical network between the USB device and the host device is connected, and the USB device will determine the auxiliary communication function whose communication type is non-network communication as a candidate auxiliary communication function among the auxiliary communication functions that can be provided.

[0056] In this embodiment, by determining whether to use the auxiliary communication function whose communication type is network communication as a candidate auxiliary communication function according to the network connection state, repeated network connection and waste of resources of the network connection can be avoided.

[0057] In an exemplary embodiment, step 206, switching the working state of the auxiliary communication function to be enabled to an on state, includes:

[0058] Based on the communication configuration information, configure the communication protocol and communication port corresponding to the auxiliary communication function to be enabled;

[0059] Based on the communication protocol and the communication port, establish a communication connection corresponding to the auxiliary communication function to be enabled between the host device and the host device;

[0060] When the connection test of the communication connection passes, the working state of the auxiliary communication function to be enabled is switched to the on state.

[0061] Specifically, the communication configuration information also includes the communication port and communication protocol corresponding to the auxiliary communication function to be enabled in the USB device set by the user, such as the serial communication protocol, the HID communication protocol, etc. After determining the auxiliary communication function to be enabled, the USB device allocates the corresponding communication port in the USB device to the corresponding auxiliary communication function to be enabled according to the communication configuration information, and configures the corresponding communication protocol. Then the USB device calls the software program corresponding to the auxiliary communication function to be enabled, executes the corresponding program instructions according to the communication port, and establishes a communication connection corresponding to the auxiliary communication function to be enabled with the host device. The USB device sends a test instruction to the host device according to the communication protocol through the established communication connection of the auxiliary communication function, and after receiving the response information of the host device to the test instruction, it is determined that the connection test of the communication connection has passed, and the working state of the auxiliary communication function to be enabled is switched to the on state, so as to obtain the enabled auxiliary communication function.

[0062] In this embodiment, by configuring the communication protocol and communication port according to the communication configuration information, a communication connection corresponding to the auxiliary communication function to be enabled is established between the USB device and the host device, and a connection test is performed to ensure the validity of the enabled auxiliary communication function.

[0063] In an exemplary embodiment, in step 202, before connecting to a host device through a USB interface and detecting a network connection status with the host device, the method further includes:

[0064] Get the communication function configuration information corresponding to the USB device;

[0065] Determine multiple auxiliary communication functions corresponding to the USB device based on the communication function configuration information, and generate execution scripts corresponding to the multiple auxiliary communication functions;

[0066] The application framework deployed in the USB device is called, and the execution script is run based on the application framework to obtain multiple auxiliary communication functions provided by the USB device.

[0067] The communication function configuration information refers to the configuration information of the auxiliary communication function to be provided in the USB device according to the user's requirements. The application framework is used to simulate the communication function in the USB device.

[0068] Specifically, a Linux system is running in the USB device, and an application framework, which may be a Gadget framework, is pre-deployed in the Linux system. The USB device obtains the corresponding communication function configuration information, determines the multiple auxiliary communication functions corresponding to the USB device according to the communication function configuration information, and generates the execution script corresponding to each auxiliary communication function according to the execution parameters in the communication function configuration information. The corresponding execution script is run, and a device communication directory corresponding to the USB device is created in the application framework, and a device descriptor is set in the newly created device communication directory to define the identity and characteristics of the USB device. A communication function directory corresponding to each auxiliary communication function is created under the device communication directory, and the parameters of the auxiliary communication function are configured according to the communication function configuration information to obtain the created auxiliary communication function. Then, a configuration descriptor directory is created under the communication function directory, and the corresponding auxiliary communication function is linked to the configuration descriptor, which is used to enable the auxiliary communication function in the USB device through the configuration descriptor. The auxiliary communication function created in the USB device may be a virtual communication function, such as a virtual network communication function, a virtual serial port communication function, and the like.

[0069] In this embodiment, a virtual auxiliary communication function is created in the USB device through the application framework without the need to use hardware facilities, thereby saving hardware resources of the USB device and realizing the integration of multiple auxiliary communication functions of the USB device, thereby improving the communication flexibility of the USB device.

[0070] In an exemplary embodiment, the plurality of auxiliary communication functions include a virtual network communication function, a virtual serial port communication function, and a hardware transmission communication function; Figure 4 As shown, step 208, data transmission with the host device based on the enabled auxiliary communication function, includes:

[0071] Step 402, obtaining a data transmission instruction sent by a host device;

[0072] Step 404, when the data transmission instruction is a device configuration instruction, based on the network connection state, determining the target communication function from the physical network communication function corresponding to the network connection state and the enabled auxiliary communication function;

[0073] Step 406, sending the device configuration information of the USB device to the host device based on the target communication function, so that the host device displays the device configuration information;

[0074] Step 408, when the data transmission instruction is a device working instruction, collecting working data based on the device working instruction; the device working instruction is received through the enabled virtual serial port communication function;

[0075] Step 410: When the data transmission instruction is a work feedback instruction, the collected work data is fed back to the host device based on the enabled hardware transmission communication function.

[0076] Among them, the physical network communication function refers to the network communication function realized by the physical network cable. The device configuration instruction refers to the instruction for configuring the working parameters of the USB device. The working feedback instruction is the instruction for instructing the USB device to return the working result. The device configuration information refers to the working configuration parameters of the USB device. The working data refers to the data generated by the USB device when it is working. The virtual network communication function and the physical network communication function can be collectively referred to as the network communication function.

[0077] Specifically, the USB device switches the working state of the auxiliary communication function to be enabled to the on state, obtains the enabled auxiliary communication function, and enters the standby state, waiting to receive the data transmission instruction sent by the host device. The data transmission instruction includes the device configuration instruction, the device working instruction and the working feedback instruction, etc. The USB device uses different communication functions for different instructions according to the communication configuration information, as follows:

[0078] When the USB device receives a data transmission instruction sent by the host device and identifies that the data transmission instruction is a device configuration instruction, it determines the target communication function from the physical network communication function corresponding to the network connection state and the enabled auxiliary communication function according to the network connection state. Generally, the target communication function is the network communication function. The USB device obtains local device configuration information and sends the device configuration information to the host device for display through the communication channel corresponding to the target communication function. The user can update the device configuration information of the USB device through the host device, which can be understood as the network communication function is used to configure the working parameters of the USB device.

[0079] When the USB device recognizes that the data transmission instruction is a device working instruction, it responds to the device working instruction to perform the working state and collect working data. The device working instruction is a control instruction sent by the host device to the USB device through the virtual serial port corresponding to the enabled virtual serial port communication function. It can be understood as the virtual serial port communication function being used to transmit the control instructions of the host device.

[0080] When the USB device recognizes that the data transmission instruction is a device working instruction, it calls the enabled hardware transmission communication function, which is generally the original communication function of the USB cable, such as the HID communication function of the USB cable. The USB device sends the collected working data to the host device through the communication channel corresponding to the enabled hardware transmission communication function.

[0081] In one embodiment, the USB device can update the device configuration information through the network communication function when it is in working state, that is, the user can configure the working parameters of the USB device when it is working. Specifically, when the USB device feeds back the collected working data to the host device through the hardware transmission communication function, when receiving the standby configuration instruction through the virtual serial port corresponding to the virtual serial port communication function, the USB device sends the device configuration information to the host device through the network communication channel corresponding to the network communication function, receives the updated device configuration information returned by the host device, and performs the next working data collection according to the updated device configuration information.

[0082] In this embodiment, by integrating multiple auxiliary communication functions into the USB device, the flexibility of the USB device for data transmission can be improved, and there is no need to switch different communication functions, thereby improving the data transmission efficiency of the USB device.

[0083] In an exemplary embodiment, step 404, based on the network connection state, determining the target communication function from the physical network communication function corresponding to the network connection state and the enabled auxiliary communication function, includes:

[0084] When the network connection state is not connected, determining, among the enabled auxiliary communication functions, an auxiliary communication function whose communication type belongs to network communication as a target communication function;

[0085] When the network connection state is connected, the physical network communication function corresponding to the network connection state is determined as the target communication function.

[0086] Specifically, when the USB device receives the device configuration instruction and the network connection state is not connected, the auxiliary communication function of the enabled auxiliary communication function, whose communication type belongs to network communication, is determined as the target communication function, which means that when the physical network between the USB device and the host device is not connected, the working parameters of the USB device can be configured through the virtual network communication function. When the USB device receives the device configuration instruction and the network connection state is connected, the physical network communication function corresponding to the network connection state is determined as the target communication function, which means that when the physical network between the USB device and the host device is connected, the working parameters of the USB device can be configured through the physical network communication function.

[0087] In this embodiment, by determining the target communication function according to the network connection status to achieve network communication between the USB device and the host device, repeated activation of the physical network communication function and the virtual network communication function can be avoided, thereby saving the network communication resources of the USB device.

[0088] In an exemplary embodiment, the USB device is a barcode scanner; the multiple auxiliary communication functions include a virtual network communication function, a virtual serial port communication function and a hardware transmission communication function; the virtual network communication function is used to transmit the device configuration information of the barcode scanner, the virtual serial port communication function is used to transmit the control instructions corresponding to the barcode scanner, and the hardware transmission communication function is used to transmit the scanning results generated by the barcode scanner when it is working.

[0089] Specifically, the USB device is a barcode scanner, which is connected to the host device via a USB cable. The USB device can reuse three auxiliary communication functions, including virtual network communication function, virtual serial port communication function and hardware transmission communication function. Figure 5 In the device connection schematic diagram shown, each double-arrow line in the figure represents a communication channel corresponding to an auxiliary communication function.

[0090] The host device can be a terminal such as a computer or a computer running a Windows system. The virtual network communication function is a channel for connecting the USB device to the Windows-side software of the host device, and is used to discover scanner devices, connect scanners, view scanner configurations, debug scanners, and other functions. The virtual serial port communication function is used to receive scanner results and trigger the scanner to scan a code; similar functions to the virtual network communication function can also be implemented through this channel, such as discovering scanner devices, connecting scanners, viewing scanner configurations, debugging scanners, and so on. The hardware transmission communication function, generally the HID communication function, is used to transmit the results of the scanner scanning.

[0091] In a specific embodiment, Figure 6 The schematic diagram of the scanner startup process shown is shown. The USB device is a scanner. After the scanner is connected to the host device through a USB cable, the scanner is started. The scanner detects the network connection status with the host device. If the network connection status is connected, the network card device discovery function is turned on, that is, the scanner is connected to the host device through the network card (physical network cable hardware). At this time, the host device will display a device list of the scanner, indicating that the host device has discovered the scanner through the network card; if the network connection status is not connected, it is determined whether the virtual network communication function is enabled according to the communication configuration information. If so, the virtual network device discovery function is turned on, that is, the scanner is connected to the host device through the virtual network. At this time, the host device will display a device list of the scanner, indicating that the host device has discovered the scanner through the virtual network, and then the next step is executed; if not, the virtual network device discovery function is not enabled, and the next step is executed.

[0092] The barcode scanner determines whether to enable the virtual serial port communication function according to the communication configuration information. If so, the virtual serial port communication function is enabled and the next step is executed; if not, the virtual serial port communication function is not enabled and the next step is executed.

[0093] The barcode scanner determines whether to enable the HID communication function based on the communication configuration information. If so, the HID communication function is enabled; if not, the HID communication function is not enabled. At this time, the barcode scanner is started up and data can be transmitted with the host device through the enabled communication function.

[0094] In the present embodiment, when the USB device is connected to the host device through the USB interface, the network connection status with the host device is detected, and a candidate auxiliary communication function is determined from a plurality of auxiliary communication functions provided by the USB device according to the network status, and the auxiliary communication function to be enabled is determined from the candidate auxiliary communication functions according to the communication configuration information. The functional integration of the plurality of auxiliary communication functions can be realized through the USB device, and the auxiliary communication function to be enabled is adaptively determined according to the network connection status and the communication configuration information. Data is transmitted with the host device through the enabled auxiliary communication function, thereby realizing flexible application of the auxiliary communication function of the USB device, thereby improving the data transmission efficiency of the USB device. Furthermore, through the flexible application of the auxiliary communication function of the USB device, the communication needs of the USB device are met, and the resources occupied by unnecessary auxiliary communication functions are saved.

[0095] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0096] Based on the same inventive concept, the embodiment of the present application also provides a data transmission device for implementing the data transmission method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more data transmission device embodiments provided below can refer to the limitations on the data transmission method above, and will not be repeated here.

[0097] In an exemplary embodiment, Figure 7 As shown, a data transmission device 700 is provided, including: a network detection module 702, a selection auxiliary communication module 704 and an auxiliary communication enabling module 706, wherein:

[0098] The network detection module 702 is used to connect to the host device through the USB interface and detect the network connection status with the host device;

[0099] The auxiliary communication selection module 704 is used to determine a candidate auxiliary communication function from a plurality of auxiliary communication functions provided by the USB device based on the network connection state; and to determine an auxiliary communication function to be enabled from the candidate auxiliary communication functions based on the pre-entered communication configuration information;

[0100] The auxiliary communication enabling module 706 is used to switch the working state of the auxiliary communication function to be enabled to an on state, and perform data transmission with the host device based on the enabled auxiliary communication function.

[0101] In one embodiment, the auxiliary communication module 704 is selected and is also used to, when the network connection state is not connected, use multiple auxiliary communication functions provided by the USB device as candidate auxiliary communication functions; when the network connection state is connected, determine the auxiliary communication function whose communication type belongs to non-network communication among the multiple auxiliary communication functions provided by the USB device as a candidate auxiliary communication function.

[0102] In one embodiment, the auxiliary communication enabling module 706 is also used to configure the communication protocol and communication port corresponding to the auxiliary communication function to be enabled based on the communication configuration information; based on the communication protocol and communication port, establish a communication connection corresponding to the auxiliary communication function to be enabled between the host device and the host device; when the connection test of the communication connection passes, switch the working state of the auxiliary communication function to be enabled to the on state.

[0103] In one embodiment, the data transmission device 700 is also used to obtain communication function configuration information corresponding to the USB device; determine multiple auxiliary communication functions corresponding to the USB device based on the communication function configuration information, and generate execution scripts corresponding to the multiple auxiliary communication functions; call the application framework deployed in the USB device, run the execution script based on the application framework, and obtain multiple auxiliary communication functions provided by the USB device.

[0104] In one embodiment, multiple auxiliary communication functions include a virtual network communication function, a virtual serial port communication function and a hardware transmission communication function; the auxiliary communication enabling module 706 is also used to obtain a data transmission instruction sent by a host device; when the data transmission instruction is a device configuration instruction, based on the network connection status, the target communication function is determined from the physical network communication function corresponding to the network connection status and the enabled auxiliary communication function; based on the target communication function, the device configuration information of the USB device is sent to the host device so that the host device displays the device configuration information; when the data transmission instruction is a device working instruction, working data is collected based on the device working instruction; the device working instruction is received through the enabled virtual serial port communication function; when the data transmission instruction is a working feedback instruction, based on the enabled hardware transmission communication function, the collected working data is fed back to the host device.

[0105] In one embodiment, the auxiliary communication enabling module 706 is also used to determine, when the network connection state is not connected, an auxiliary communication function whose communication type belongs to network communication among the enabled auxiliary communication functions as a target communication function; and when the network connection state is connected, determine the physical network communication function corresponding to the network connection state as the target communication function.

[0106] In one embodiment, the USB device is a barcode scanner; the multiple auxiliary communication functions include a virtual network communication function, a virtual serial port communication function and a hardware transmission communication function; the virtual network communication function is used to transmit the device configuration information of the barcode scanner, the virtual serial port communication function is used to transmit the control instructions corresponding to the barcode scanner, and the hardware transmission communication function is used to transmit the scanning results generated by the barcode scanner when it is working.

[0107] Each module in the above data transmission device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0108] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Figure 8As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, a data transmission method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

[0109] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0110] In an exemplary embodiment, in one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0111] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0112] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0113] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0114] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0115] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0116] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A data transmission method, characterized in that: Applied to a USB device, the method comprises: Connecting to a host device via a USB interface to detect a network connection status with the host device; Based on the network connection state, determining a candidate auxiliary communication function from a plurality of auxiliary communication functions provided by the USB device; Based on the pre-recorded communication configuration information, determining the auxiliary communication function to be enabled from the candidate auxiliary communication functions; The working state of the auxiliary communication function to be enabled is switched to an enabled state, and data is transmitted with the host device based on the enabled auxiliary communication function.

2. The method according to claim 1, characterized in that: The determining, based on the network connection state, a candidate auxiliary communication function from a plurality of auxiliary communication functions provided by the USB device comprises: When the network connection state is not connected, using a plurality of auxiliary communication functions provided by the USB device as candidate auxiliary communication functions; When the network connection state is connected, an auxiliary communication function whose communication type belongs to non-network communication among the multiple auxiliary communication functions provided by the USB device is determined as a candidate auxiliary communication function.

3. The method according to claim 1, characterized in that The step of switching the working state of the auxiliary communication function to be enabled to an on state includes: Based on the communication configuration information, configure the communication protocol and communication port corresponding to the auxiliary communication function to be enabled; Based on the communication protocol and the communication port, establishing a communication connection corresponding to the auxiliary communication function to be enabled with the host device; When the connection test of the communication connection passes, the working state of the auxiliary communication function to be enabled is switched to an on state.

4. The method according to claim 1, characterized in that Before connecting with the host device through the USB interface and detecting the network connection status with the host device, the method further includes: Obtaining communication function configuration information corresponding to the USB device; Determine a plurality of auxiliary communication functions corresponding to the USB device based on the communication function configuration information, and generate execution scripts corresponding to the plurality of auxiliary communication functions; The application framework deployed in the USB device is called, and the execution script is run based on the application framework to obtain multiple auxiliary communication functions provided by the USB device.

5. The method according to claim 1, characterized in that The plurality of auxiliary communication functions include a virtual network communication function, a virtual serial port communication function, and a hardware transmission communication function; and the data transmission with the host device based on the enabled auxiliary communication function includes: Obtaining a data transmission instruction sent by the host device; When the data transmission instruction is a device configuration instruction, based on the network connection state, determining a target communication function from a physical network communication function corresponding to the network connection state and an enabled auxiliary communication function; Sending the device configuration information of the USB device to the host device based on the target communication function, so that the host device displays the device configuration information; When the data transmission instruction is a device working instruction, collecting working data based on the device working instruction; the device working instruction is received through an enabled virtual serial port communication function; When the data transmission instruction is a work feedback instruction, the collected work data is fed back to the host device based on the enabled hardware transmission communication function.

6. The method according to claim 5, characterized in that The determining, based on the network connection state, a target communication function from a physical network communication function corresponding to the network connection state and an enabled auxiliary communication function, comprises: When the network connection state is not connected, determining, among the enabled auxiliary communication functions, an auxiliary communication function whose communication type belongs to network communication as a target communication function; When the network connection state is connected, a physical network communication function corresponding to the network connection state is determined as a target communication function.

7. The method according to any one of claims 1 to 6, characterized in that The USB device is a barcode scanner; the multiple auxiliary communication functions include a virtual network communication function, a virtual serial port communication function and a hardware transmission communication function; the virtual network communication function is used to transmit the device configuration information of the barcode scanner, the virtual serial port communication function is used to transmit the control instructions corresponding to the barcode scanner, and the hardware transmission communication function is used to transmit the scanning results generated by the barcode scanner when it is working.

8. A data transmission device, characterized in that: The device comprises: A network detection module, used to connect to a host device via a USB interface and detect a network connection status with the host device; An auxiliary communication module is selected, which is used to determine a candidate auxiliary communication function from a plurality of auxiliary communication functions provided by the USB device based on the network connection state; and to determine an auxiliary communication function to be enabled from the candidate auxiliary communication functions based on pre-entered communication configuration information; The auxiliary communication enabling module is used to switch the working state of the auxiliary communication function to be enabled to an on state, and to perform data transmission with the host device based on the enabled auxiliary communication function.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.