Method and device for realizing MTP protocol data transmission in single guide device, and medium
By implementing the MTP protocol stack and buffer optimization data block transmission method in a single-guided device, the compatibility problem of single-guided devices to MTP devices and the poor file transfer performance are solved, and the compatibility and file transfer performance of MTP devices are optimized.
Patent Information
- Application Number
- CN202411906818.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2044-12-24
AI Technical Summary
Existing single-guided transmission devices cannot support the MTP protocol, resulting in compatibility issues with mobile devices that support the MTP protocol such as smartphones and voice recorders, and poor file transfer performance.
The HOST end and the SLAVE end are divided in a single-guided device. The HOST end implements the MTP protocol stack, including the physical layer, the transport layer and the command layer, optimizes data block transmission through buffers, and supports filtering and sending specific types of files according to file types.
It solves the compatibility problem of single-guided devices for MTP devices, optimizes file transfer performance, and supports filtering and sending specific types of files according to file types to meet the needs of different application scenarios.
Smart Images

Figure CN119854275A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of communications, and in particular to a method, a device and a medium for implementing MTP protocol data transmission in a single-channel device. Background Art
[0002] MTP is a new multimedia transmission protocol developed by Microsoft for file transfer between mobile devices and hosts. Due to its wide application in mobile devices, MTP has become an essential component in various device interconnection products. Android 3.0 and later versions have added support for the MTP transmission protocol. Android mobile products can interact with computers through the MTP protocol, that is, users can use the MTP protocol to transfer files between mobile devices and computers quickly and easily.
[0003] At present, the solutions of single-channel transmission equipment manufacturers only support data transmission and import of large-capacity mobile storage devices such as USB flash drives, that is, they only support USB large-capacity storage protocols, and do not support mobile devices that support MTP protocols such as smart phones, voice recorders, and digital cameras. Therefore, single-channel devices have limitations in practical applications. Summary of the invention
[0004] In view of the defects of the prior art, the present invention provides a method, device and medium for realizing MTP protocol data transmission in a single-channel device, which solves the problem of compatibility of single-channel devices with MTP devices, optimizes and improves the file transfer performance, and supports the function of filtering and sending specific types of files according to file types to meet the needs of different application scenarios.
[0005] In order to solve the technical problem, the technical solution adopted by the present invention is: a method for realizing MTP protocol data transmission in a single-guide device, comprising the following steps: S01. A single-channel device is divided into a HOST end and a SLAVE end. The HOST end is a USB 3.0 chip. The HOST end, as an initiator, actively initiates a session with the MTP device. The MTP device, as a responder, processes the initiator's request and feeds back the processing result. The file obtained from the MTP device is sent from the HOST end to the SLAVE end through a single-channel path. The SLAVE end transfers the received file to the target PC host. S02. Implement the MTP protocol stack in layers at the HOST end. The MTP protocol stack includes a physical layer, a transport layer, and a command layer. The physical layer is used to implement the underlying communication of the USB, the transport layer is used to implement data and instruction format encapsulation, and the command layer is used to implement MTP instructions and protocols. S03. N buffer blocks with a data volume of 64KB are opened on the HOST side. The N buffer blocks form a circular linked list of data blocks. The data packets obtained by the command layer from the physical layer are stored in the buffer blocks in sequence until they are full or the file data is received. The HOST side then sends the buffer block data to the SLAVE side until all file transfers are completed. S04. After the HOST detects that a device with a USB interface is connected, it first initializes the USB configuration information and interface information, and then determines whether the connected device supports the MTP protocol and the supported protocol type. If the connected device supports the MTP protocol, it initiates a session creation request to establish a communication channel with the connected device. After the communication channel is established, the HOST queries how many storages the currently connected device has, and records the ID of each storage, and then selects the specified storage for file transfer, or traverses each storage and performs file transfer. S05. The HOST reads the file configuration information, which is used to start the file transfer, determine and filter the file type to be transferred; then, according to the ID list of the storage obtained, each storage is traversed, and the file type specified in the file configuration information is filtered for transmission.
[0006] Furthermore, the file configuration information is written when the single-lead device is mass-produced with firmware, and supports real-time updates after mass production.
[0007] Furthermore, the file configuration information is updated by reading the configuration file from a USB flash drive.
[0008] Furthermore, when traversing each STORAGE, each STORAGE has a root directory. Starting from the root directory, folders and files are traversed and file types specified in the file configuration information are filtered for transmission. For any file read, the file type is first parsed, and it is determined whether the file type is in the file configuration information list. If it meets the requirements, the file is sent, and the file information and file content are sent from the HOST end to the SLAVE end, and then from the SLAVE end to the target PC.
[0009] Furthermore, for file data packets transmitted by MTP, the first data packet is a fixed file header of 500 bytes in length, followed by multiple 16KB data blocks, and the end is a data tail packet of less than 16KB. After the HOST receives the data packets obtained by the physical layer, it reorganizes the data packets, with each 64KB as a transmission BLOCK. Files less than 64KB are placed in a circular linked list of data blocks according to the actual file size. The data packets transmitted from the HOST to the SLAVE are 64KB or the actual file size at a time.
[0010] Furthermore, the physical layer implements the underlying communication of USB through the xHCI protocol, including control transmission and BULK transmission.
[0011] Furthermore, the MTP device is a smart phone, a voice recorder or a digital camera that supports the MTP protocol.
[0012] The present invention also discloses a device for implementing MTP protocol data transmission in a single-guide device, comprising a processor and a memory storing program instructions, wherein the processor is configured to execute the method for implementing MTP protocol data transmission in a single-guide device as described above when running the program instructions.
[0013] The present invention also discloses a storage medium storing program instructions, wherein the program instructions, when running, execute the method for realizing MTP protocol data transmission in a single-guide device as described above.
[0014] Beneficial effects of the present invention: The present invention proposes a single-channel device supporting the MTP protocol and an implementation method, which solves the problem of compatibility of single-channel devices with MTP devices, optimizes and improves the file transmission method and performance, and supports the function of filtering files to be sent according to file types, meets the needs of different application scenarios, and improves the file transmission efficiency of single-channel transmission devices. The present invention can support single-channel transmission of data of multiple MTP devices, and can be applied to security application scenarios such as government office and confidentiality. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 This is the principle architecture diagram of this method; Figure 2 This is a layered diagram of the MTP protocol; Figure 3 This is a schematic diagram of the file transfer BLOCK; Figure 4 To identify and traverse the MTP device STORAGE flow chart; Figure 5 Traverse the flowchart for the file. DETAILED DESCRIPTION
[0016] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments. First, the English words appearing in the embodiments are explained: MTP: Media Transfer Protocol.
[0017] Initiator: Initiator, in this solution, refers to the USB HOST end.
[0018] Responder: Responder, which refers to the MTP device in this solution.
[0019] Example 1 This embodiment discloses a method for implementing MTP protocol data transmission in a single-channel device, such as Figure 1 As shown, this method has three participants: MTP device, single-guide device, and target PC. The MTP device communicates with the single-guide device via USB, and the single-guide device communicates with the target PC via USB. The single-guide device is divided into the HOST end and the SLAVE end. The HOST end is a USB 3.0 HOST chip, which also makes it possible for the single-guide transmission device to support the MTP transmission protocol. This method implements the initiator function of MTP in the HOST end chip. The HOST end, as the initiator, actively initiates a session with the MTP device. The MTP device, as the responder, processes the initiator's request and feeds back the processing result. This conforms to the specifications and characteristics of the MTP protocol. Therefore, as long as the single-guide device implements the standard MTP protocol stack on the HOST end, it can support the one-way import and transmission of MTP device data.
[0020] like Figure 1 As shown in the figure, the HOST end of the single-channel device implements the MTP protocol and filters and parses the files uploaded by the MTP device, and optimizes the performance of small file transmission; the files obtained from the MTP device are sent from the HOST end to the SLAVE end through a single-channel path; the SLAVE end transfers the received files to the target PC host through the host USB port.
[0021] This method mainly includes the following aspects: the layered implementation method of the MTP protocol on the HOST side; the method for optimizing and improving the data BLOCK in the file transfer process; the method and steps for identifying and traversing MTP devices and supporting multiple storages for a single MTP device; the file type screening transmission method and how to support the screening of different file types by modifying the configuration. The following is a detailed introduction.
[0022] Support of MTP transmission protocol: The HOST side of the single-channel device uses the host (USB HOST) mode, and implements the MTP protocol stack in layers on the HOST side, such as Figure 2 As shown in the figure, the MTP protocol stack implemented by the HOST end is divided into the physical layer, the transport layer and the command layer. The physical layer mainly implements the underlying communication of USB (including control transmission, BULK transmission, etc.) through the xHCI protocol, the transport layer implements the data and instruction format encapsulation, and the command layer implements various instructions of the standard MTP protocol.
[0023] Optimization and improvement of data BLOCK blocks during file transfer: Due to the characteristics of the MTP protocol, for small files, the size of the data packet obtained by the USB bottom layer at a time is not fixed (it can be any length less than or equal to 16KB), which will result in low reading performance for small files. In order to optimize data transmission performance, this solution optimizes and improves the single data BLOCK blocks during file transfer.
[0024] The specific method is to open N buffer blocks with a data capacity of 64KB on the HOST side. The N buffer blocks are connected end to end to form a circular linked list of data blocks. The data packets obtained by the MTP command layer from the USB physical layer are stored in the BLOCKs in sequence. The size of each BLOCK is 64KB. The HOST side will not send the BLOCK to the SLAVE side until it is full or the file data is received until all file transfers are completed.
[0025] like Figure 3 As shown in the figure, the first data packet of the file data transmitted by MTP is a fixed 500-byte file header (Header data), followed by multiple 16KB data blocks (Body data), and the end is a data tail packet (Tail data) of less than 16KB. After the HOST receives the data packet obtained by the USB physical layer, it reassembles the data packet and stores it in the buffer block. Each 64KB is a transmission BLOCK, and files less than 64KB are transmitted according to the actual file size. In this way, the data packet transmitted from the HOST end to the SLAVE end is 64KB at a time, which can achieve the optimal performance of USB data transmission, thereby improving data transmission efficiency.
[0026] Identify and traverse MTP devices: Figure 4 As shown, after the HOST detects that a device with a USB interface (a mobile storage device that supports MTP, such as a voice recorder, etc.) is connected, it first initializes the USB configuration information, interface information, etc., and then sends a "get device information" command to determine whether the current device supports the MTP protocol, as well as the supported protocol type and other information based on the acquired device information. If the current device supports the MTP protocol, a session creation request is initiated, and the communication channel with the device has been established. In the case where a device has multiple storage modules (STORAGE), first query how many STORAGEs the current device has in total, and record the ID of each STORAGE, and then filter the specified STORAGE for file transfer according to the policy, or traverse each STORAGE and perform file transfer. The policy is stored in the file configuration information of the single-guide device, and the file configuration information specifies which STORAGEs are to be transferred.
[0027] File type screening and data processing: When the USB HOST end of the single-lead device is initialized, the file configuration information is read from the offset position where the "file configuration information" is stored to complete the initialization process. The file configuration information is used to determine and screen the file type to be transferred after the file transfer is started. The above "file configuration information" can be written when the firmware of the single-lead chip is mass-produced, and can also be updated by reading the configuration file from a USB flash drive to ensure that the file type screening rules can be changed according to needs.
[0028] The specific process and rules for file transfer are as follows: According to the ID list of the storage obtained, each storage is traversed, such as Figure 5 As shown, each STORAGE has a root directory. Starting from the root directory, folders and files are traversed and the file types specified in the "file configuration information" are filtered for transmission. For any file read, the file type is first parsed, and it is determined whether the file type is in the file configuration information list. If it meets the requirements, the file is sent, and the file information and file content are sent from the HOST end to the SLAVE end via the optical module. If it does not meet the rules, the current file is skipped. For example, if there is only wav / JPEG information in the currently read file configuration information, only files with file types of .wav and .JPEG are filtered for transmission. In this way, for a specific voice recorder or digital camera device, it can be ensured that only valid audio files or picture files required by the user are transmitted, avoiding the transmission of other invalid system files, greatly improving the efficiency of data transmission.
[0029] This method uses the data transmission characteristics of the MTP protocol to optimize the data BLOCK blocks for each transmission, thereby improving the overall data transmission efficiency; supports traversing the file system of the MTP device, and adds support for a single MTP device with multiple STORAGEs (storage media); supports filtering and sending specific types of files based on file types, and by adding a configuration module, supports filtering of different file types by modifying the configuration.
[0030] This method supports the one-way import and transmission of specific data of smart phones, voice recorders, etc. with MTP transmission protocol. At the same time, according to user needs, the file transfer performance is optimized and improved, and the function of filtering and sending files of specified types and formats according to file types is supported, which not only meets customer needs, but also enriches the application scenarios of single-channel devices, which is conducive to the promotion and application of products.
[0031] Example 2 The embodiment of the present disclosure provides a device for implementing MTP protocol data transmission in a single-conductor device, including a processor and a memory. Optionally, the device may also include a communication interface and a bus. The processor, the communication interface, and the memory may communicate with each other through the bus. The communication interface may be used for information transmission. The processor may call the logic instructions in the memory to execute the method for implementing MTP protocol data transmission in a single-conductor device according to the above embodiment.
[0032] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.
[0033] The memory, as a computer-readable storage medium, can be used to store software programs and computer executable programs, such as program instructions / modules corresponding to the method in the embodiment of the present disclosure. The processor executes the function application and data processing by running the program instructions / modules stored in the memory, that is, the method for implementing MTP protocol data transmission in a single-guide device in the above embodiment is implemented.
[0034] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory may include a high-speed random access memory and may also include a non-volatile memory.
[0035] Example 3 The present disclosure provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured to execute the method for implementing MTP protocol data transmission in a single-guide device. The computer-readable storage medium may be a transient computer-readable storage medium or a non-transient computer-readable storage medium.
[0036] The technical solution of the embodiment of the present disclosure can be embodied in the form of a software product, which is stored in a storage medium and includes one or more instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in the embodiment of the present disclosure. The aforementioned storage medium may be a non-transient storage medium, including: a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk, and other media that can store program codes, or a transient storage medium.
[0037] The above description and the accompanying drawings fully illustrate the embodiments of the present disclosure so that those skilled in the art can practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent only possible changes. Unless explicitly required, separate components and functions are optional, and the order of operations may vary. Parts and features of some embodiments may be included in or replace parts and features of other embodiments. Moreover, the words used in this application are only used to describe the embodiments and are not used to limit the claims. As used in the description of the embodiments and the claims, unless the context clearly indicates, the singular forms of "a", "an" and "the" are intended to include plural forms as well. Similarly, the term "and / or" as used in this application refers to any and all possible combinations of one or more associated listings. In addition, when used in this application, the term "comprise" and its variants "comprises" and / or comprising refer to the presence of stated features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the presence of other identical elements in the process, method or device including the elements. In this article, each embodiment may focus on the differences from other embodiments, and the same and similar parts between the embodiments may refer to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can refer to the description of the method part.
[0038] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software may depend on the specific application and design constraints of the technical solution. The technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. The technicians may clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
Claims
1. A method for implementing MTP protocol data transmission in a single-conductor device, characterized in that: The following steps are involved: S01. A single-channel device is divided into a HOST end and a SLAVE end. The HOST end is a USB 3.0 chip. The HOST end, as an initiator, actively initiates a session with the MTP device. The MTP device, as a responder, processes the initiator's request and feeds back the processing result. The file obtained from the MTP device is sent from the HOST end to the SLAVE end through a single-channel path. The SLAVE end transfers the received file to the target PC host. S02. Implement the MTP protocol stack in layers at the HOST end. The MTP protocol stack includes a physical layer, a transport layer, and a command layer. The physical layer is used to implement the underlying communication of the USB, the transport layer is used to implement data and instruction format encapsulation, and the command layer is used to implement MTP instructions and protocols. S03. N buffer blocks with a data volume of 64KB are opened on the HOST side. The N buffer blocks form a circular linked list of data blocks. The data packets obtained by the command layer from the physical layer are stored in the buffer blocks in sequence until they are full or the file data is received. The HOST side then sends the buffer block data to the SLAVE side until all file transfers are completed. S04. After the HOST detects that a device with a USB interface is connected, it first initializes the USB configuration information and interface information, and then determines whether the connected device supports the MTP protocol and the supported protocol type. If the connected device supports the MTP protocol, it initiates a session creation request to establish a communication channel with the connected device. After the communication channel is established, the HOST queries how many storages the currently connected device has, and records the ID of each storage, and then selects the specified storage for file transfer, or traverses each storage and performs file transfer. S05. The HOST reads the file configuration information, which is used to start the file transfer, determine and filter the file type to be transferred; then, according to the ID list of the storage obtained, each storage is traversed, and the file type specified in the file configuration information is filtered for transmission.
2. The method for realizing MTP protocol data transmission in a single-guide device according to claim 1, wherein: The file configuration information is written when the single-lead device is mass-produced with firmware, and supports real-time updates after mass production.
3. The method for realizing MTP protocol data transmission in a single-guide device according to claim 2, characterized in that: Update the file configuration information by reading the configuration file from a USB flash drive.
4. The method for realizing MTP protocol data transmission in a single-guide device according to claim 1, characterized in that: When traversing each STORAGE, each STORAGE has a root directory. Starting from the root directory, folders and files are traversed and the file types specified in the file configuration information are filtered for transmission. For any file read, the file type is first parsed and it is determined whether the file type is in the file configuration information list. If it meets the requirements, the file is sent, and the file information and file content are sent from the HOST end to the SLAVE end, and then from the SLAVE end to the target PC.
5. The method for realizing MTP protocol data transmission in a single-guide device according to claim 1, characterized in that: The first data packet of the file data transmitted by MTP is a fixed file header of 500 bytes, followed by multiple 16KB data blocks, and the end is a data tail packet of less than 16KB. After the HOST receives the data packet obtained by the physical layer, it reorganizes the data packet, and each 64KB is a transmission BLOCK. Files less than 64KB are placed in a circular linked list of data blocks according to the actual file size. The data packet transmitted by the HOST to the SLAVE end is 64KB or the actual file size at a time.
6. The method for realizing MTP protocol data transmission in a single-guide device according to claim 1, characterized in that: The physical layer implements the underlying communication of USB through the xHCI protocol, including control transmission and BULK transmission.
7. The method for realizing MTP protocol data transmission in a single-guide device according to claim 1, characterized in that: The MTP device is a smart phone, a voice recorder or a digital camera that supports the MTP protocol.
8. A device for implementing MTP protocol data transmission in a single-channel device, comprising a processor and a memory storing program instructions, characterized in that: The processor is configured to execute the method for implementing MTP protocol data transmission in a single-lead device as claimed in any one of claims 1 to 7 when running the program instructions.
9. A storage medium storing program instructions, characterized in that: When the program instructions are executed, the method for implementing MTP protocol data transmission in a single-channel device as described in any one of claims 1 to 7 is executed.
Citation Information
Patent Citations
File transfer method and device and terminal device
CN109271266A
File transfer method, device and terminal device
CN109298956A
Versatile electronic storage device
EP2211264A1