A kind of data transmission method and system
Technical field
The present invention relates to field of data transmission more particularly to a kind of data transmission method and systems.
Background technique
It is wirelessly attached currently, being used between many terminal devices, and carries out the transmission of data, such as is blue
Tooth, Wifi, infrared ray etc..Data element is loaded in transmission data by terminal device in the prior art, then will be carried
The transmission data for stating data element are sent to other terminal devices, to realize the transmission of data.Due to each biography in the prior art
Transmission of data only loads a data element, for biggish data volume, it is necessary to many transmission data, thus be transmitted across
Journey inefficiency.
Summary of the invention
In order to solve the technical problems existing in the prior art, the present invention provides a kind of data transmission method and system, real
The purpose of improve data transfer efficiency is showed.
The embodiment of the invention provides a kind of data transmission methods, which comprises
The position of the transmission data is at least divided two sections by the data type for predefining transmission data;
First terminal equipment obtains at least two data elements, and at least two data element is filled respectively to right
In the section answered, a data element is at least filled in each section, and the length in each section and the data element of filling are adapted;
The transmission data for carrying the data element are sent to second terminal equipment by the first terminal equipment.
Preferably, which comprises
The second terminal equipment extracts the data element from the transmission data for carrying the data element, by section
Element.
Preferably, described to include: by the section extraction data element
The data element is extracted from each section using multithreading.
Preferably, described to include: by the section extraction data element
Mask corresponding with section to be extracted is set;
Mask transmission data corresponding with the section to be extracted are carried out and operation, operating result is obtained;
By shifting function, the data element in the section to be extracted is extracted from the operating result.
Preferably, the data type includes byte, integer data and/or character type data.
Preferably, the first terminal equipment includes handle end.
The embodiment of the invention also provides a kind of data transmission system, the system comprises first terminal equipment and second eventually
End equipment, wherein the first terminal equipment includes: interval division unit, data element acquiring unit and transmission unit;
The interval division unit, for predefining the data type for being used for transmission data, by the transmission data
Position at least divides two sections;
The data element acquiring unit, for obtaining at least two data elements, and by least two data element
Element is filled respectively to corresponding section, and a data element, length and the filling in each section are at least filled in each section
Data element is adapted;
The transmission unit, for the transmission data for carrying the data element to be sent to second terminal equipment.
Preferably, the second terminal equipment, for being mentioned by section from the transmission data for carrying the data element
Take the data element.
Preferably, the second terminal equipment, is specifically used for:
From the transmission data for carrying the data element, the data element is extracted from each section using multithreading
Element.
Preferably, the second terminal equipment includes:
Mask setting unit and operating unit and extraction unit;
The mask setting unit, for mask corresponding with section to be extracted to be arranged;
Described and operating unit, for mask transmission data corresponding with the section to be extracted to be carried out and grasped
Make, obtains operating result;
The extraction unit, for extracting the number in the section to be extracted from the operating result by shifting function
According to element.
The present invention is by being divided at least two sections, at least filling one respectively of each section for the position of the transmission data
A data element, in this way, the transmission data are just at least to carry the data of two data elements, compared with the existing technology
In, each transmission data only carry the technical solution of a data element, and the present invention effectively increases data transmission efficiency.
Detailed description of the invention
In order to illustrate the technical solutions in the embodiments of the present application or in the prior art more clearly, to embodiment or will show below
There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this
The some embodiments recorded in application, for those of ordinary skill in the art, without creative efforts,
It can also be obtained according to these attached drawings other attached drawings.
Fig. 1 is a kind of data transmission method flow chart that the embodiment of the present invention one provides;
The signless long data that Fig. 2 is one 32 in the embodiment of the present invention one is divided into the schematic diagram in three sections;
Fig. 3 is a kind of data transmission method flow chart provided by Embodiment 2 of the present invention;
Fig. 4 is a kind of structural block diagram for data transmission system that the embodiment of the present invention three provides;
Fig. 5 is a kind of structural block diagram for data transmission system that the embodiment of the present invention four provides.
Specific embodiment
In order to enable those skilled in the art to better understand the solution of the present invention, below in conjunction in the embodiment of the present invention
Attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is only this
Invention a part of the embodiment, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art exist
Every other embodiment obtained under the premise of creative work is not made, shall fall within the protection scope of the present invention.
Embodiment one:
Referring to Fig. 1, which is a kind of data transmission method flow chart that the embodiment of the present invention one provides.
Data transmission method provided in this embodiment includes the following steps:
Step S101: predefining the data type of transmission data, and the position of the transmission data is at least divided the area Liang Ge
Between.
Step S102: first terminal equipment obtains at least two data elements, and at least two data element is divided
Tian Chong not be in corresponding section, a data element, the length in each section and the data of filling are at least filled in each section
Element is adapted.
Step S103: the transmission data for carrying the data element are sent to second terminal by the first terminal equipment
Equipment.
In a computer, data are indicated so that position (0 or 1) is unit, it is single that the data type in the present invention, which includes with position,
All types of data of position, in the present embodiment, the transmission data are the data for including at least two.Table 1 is common
Data type and corresponding storage size and value range.
Table 1
In the prior art, the data transmission between terminal device is by data element " loading " in preset transmission data
It is transmitted in each position.So-called data element refers to the basic unit of data transmission.Using a terminal device as handle end (example
Such as game paddle), another terminal device is for mobile terminal, the game paddle is used to acquire the movement of user's finger
Trace information, when the motion track information includes finger initial touch handle end touch screen x-axis coordinate and y-axis coordinate (with
Lower referred to as the first x-axis coordinate and the first y-axis coordinate respectively) and x-axis coordinate and y-axis of the finger when leaving the touch screen
Coordinate (referred to as the second x-axis coordinate and the second y-axis coordinate individually below), then further includes finger if more fingers operate simultaneously
Number, each finger is distinguished.Therefore, the data element includes x-axis coordinate, y-axis coordinate and finger number.It is existing
The each transmission data of technology only load a data element, for example, the long that the data type of the transmission data is 32
Data, then for one group of finger motion locus information (including finger number, the first x-axis coordinate, the first y-axis coordinate, the 2nd x
Axial coordinate and the second y-axis coordinate), it is necessary to the signless long data that at least five is 32 is transmitted, and not all data
Element can fill full this 32, and many positions is caused to be wasted, and influence the efficiency of data transmission, especially for handling capacity compared with
Small wireless transmission method, such as bluetooth, WIFI etc., the degree that data transmission efficiency is affected are more obvious.
In order to solve this technical problem, the position for transmitting data is divided at least two sections, each section by the present invention
It is respectively used to fill at least one data element.By taking above-mentioned example as an example, one 32 signless long datas can be divided into
Three sections, referring to fig. 2, first section are first 10, and for loading the finger number for occupying 8, second section is the
11 to the 21st, for loading the first x-axis coordinate for occupying 10, third section is the 22nd to the 32nd, for filling
Carry the first y-axis coordinate of occupancy 10, that is to say, that one 32 signless long datas can load three data elements now
Element reduces the quantity of the position of waste, improves data transmission efficiency.
It should be noted that when the position to transmission data carries out interval division, the length and filling in each section
Data need to be adapted, i.e., the quantity of the corresponding position in each section is not less than the number of the occupied position of the data element to be filled
Amount.
Embodiment two:
Referring to Fig. 3, which is a kind of data transmission method flow chart provided by Embodiment 2 of the present invention.
Data transmission method provided in this embodiment includes the following steps:
Step S201: predefining the data type of transmission data, and the position of the transmission data is at least divided the area Liang Ge
Between.
Step S202: first terminal equipment obtains at least two data elements, and at least two data element is divided
Tian Chong not be in corresponding section, a data element, the length in each section and the data of filling are at least filled in each section
Element is adapted.
Step S203: the transmission data for carrying the data element are sent to second terminal by the first terminal equipment
Equipment.
The step S201 to step S203 is identical to step S103 as step S101, and details are not described herein again.
Step S204: the second terminal equipment is extracted from the transmission data for carrying the data element by section
The data element.
The embodiment one describes first terminal equipment as data sending terminal, the side handled transmission data
Method highlights the second terminal equipment as data receiver, is set receiving by the first terminal in the present embodiment
After the standby transmission data sent by way of wirelessly or non-wirelessly, how to be handled.Specifically, in advance eventually described second
Setting rule in section to be extracted is arranged in end equipment, from from the first terminal equipment, carries the data element
It transmits in data, extracts the data element by section.By taking above-mentioned example as an example, the second terminal equipment is receiving Fig. 2
In transmission data after, finger number is extracted out of described first interval, first x-axis is extracted out of described second interval and is sat
Mark, extracts first y-axis coordinate out of described 3rd interval.
In order to improve the efficiency that the data element is extracted in each section from the transmission data, the second terminal is set
It is extracted for can use multithreading.In practical applications, can be arranged one in the second terminal equipment includes at least
The thread pool of two threads, and the transmission data received are hung on a chained list, using multithreading simultaneously to described
Data element in multiple transmission data extracts, and whenever having vacant thread in thread pool, will be assigned from the chain
Task of the transmission data are extracted in table, until all transmission data on chained list are all disposed.
In addition, there are many implementation, the present invention in practical applications on how to extract the data element by section
It is not specifically limited, the present embodiment provides one of which to be used as example:
Firstly, setting mask corresponding with section to be extracted.The mask is a string of binary codes, in the present embodiment
In, different sections to be extracted corresponds to different masks, by utilizing mask transmission data corresponding with the section to be extracted
It carries out and operates, obtain operating result, then by shifting function, the section to be extracted is extracted from the operating result
Data element.For example, if section to be extracted be Fig. 2 in first interval, i.e., 1-10, then mask MASK_A can be set
It is 11111111110000000000000000000000, described MASK_A and 32 transmission data is being executed and operated
Afterwards, the value got moves to right 22 and just obtains the finger number;If section to be extracted is the second interval in Fig. 2, i.e. 11-
21, then it is 00000000001111111111100000000000 that mask MASK_B, which can be set, by the mask
After MASK_B and 32 transmission data is executed and operated, the value got, which moves to right 11, can be obtained by the first x-axis seat
Mark;If the section to be extracted be Fig. 2 in 3rd interval, i.e., 22-32, then can be set mask MASK_C be 000
00000000000000000011111111111, it executes by MASK_C and described 32 transmission data with after operation, obtains
To value move to right 0 and obtain first y-axis coordinate.
Based on a kind of data transmission method that above embodiments provide, the embodiment of the invention also provides a kind of transmission of data
Its working principle is described in detail with reference to the accompanying drawing in system.
Embodiment three:
Referring to fig. 4, which is a kind of structural block diagram for data transmission system that the embodiment of the present invention three provides.
Data transmission system provided in this embodiment includes: first terminal equipment 11 and second terminal equipment 12, wherein institute
Stating first terminal equipment 11 includes: interval division unit 101, data element acquiring unit 102 and transmission unit 103;
The interval division unit 101, for predefining the data type for being used for transmission data, by the transmission data
Position at least divide two sections;
The data element acquiring unit 102, for obtaining at least two data elements, and by least two data
Element is filled respectively to corresponding section, and a data element, the length and filling in each section are at least filled in each section
Data element be adapted;
The transmission unit 103, for the transmission data for carrying the data element to be sent to second terminal equipment.
The first terminal equipment 11 includes processor and memory, and above-mentioned interval division unit 101, data element obtain
Unit 102 and transmission unit 103 store in memory as program unit, are executed by processor stored in memory
Above procedure unit realizes corresponding function.
Include kernel in processor, is gone in memory to transfer corresponding program unit by kernel.Kernel can be set one
Or more, the purpose of improve data transfer efficiency is realized by adjusting kernel parameter.
Memory may include the non-volatile memory in computer-readable medium, random access memory (RAM) and/
Or the forms such as Nonvolatile memory, if read-only memory (ROM) or flash memory (flash RAM), memory include that at least one is deposited
Store up chip.
The present embodiment, which passes through, is divided at least two sections for the position for transmitting data, and each section is respectively used to filling at least
One data element reduces the position left unused in data transmission procedure, thus the efficiency of improve data transfer.
Example IV:
Referring to Fig. 5, which is a kind of structural block diagram for data transmission system that the embodiment of the present invention four provides.
In order to improve the extraction efficiency of data element, on the basis of embodiment three, data provided in this embodiment
In Transmission system, the second terminal equipment 21, for being extracted by section from the transmission data for carrying the data element
The data element.
Optionally, the second terminal equipment 21, is specifically used for:
From the transmission data for carrying the data element, the data element is extracted from each section using multithreading
Element.
Optionally, the second terminal equipment 21 includes:
Mask setting unit 201 and operating unit 202 and extraction unit 203;
The mask setting unit 201, for mask corresponding with section to be extracted to be arranged;
It is described with operating unit 202, for by mask transmission data progress corresponding with the section to be extracted and
Operation, obtains operating result;
The extraction unit 203, for extracting the section to be extracted from the operating result by shifting function
Data element.
Present invention also provides a kind of computer program products, when executing on data processing equipment, are adapted for carrying out just
The program code of beginningization there are as below methods step:
The position of the transmission data is at least divided two sections by the data type for predefining transmission data;
First terminal equipment obtains at least two data elements, and at least two data element is filled respectively to right
In the section answered, a data element is at least filled in each section, and the length in each section and the data element of filling are adapted;
The transmission data for carrying the data element are sent to second terminal equipment by the first terminal equipment.
It should be understood by those skilled in the art that, embodiments herein can provide as method, system or computer program
Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the application
Apply the form of example.Moreover, it wherein includes the computer of computer usable program code that the application, which can be used in one or more,
The computer program implemented in usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) produces
The form of product.
The application is referring to method, the process of equipment (system) and computer program product according to the embodiment of the present application
Figure and/or block diagram describe.It should be understood that every one stream in flowchart and/or the block diagram can be realized by computer program instructions
The combination of process and/or box in journey and/or box and flowchart and/or the block diagram.It can provide these computer programs
Instruct the processor of general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produce
A raw machine, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute for real
The device for the function of being specified in present one or more flows of the flowchart and/or one or more blocks of the block diagram.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates,
Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or
The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one
The step of function of being specified in a box or multiple boxes.
In a typical configuration, calculating equipment includes one or more processors (CPU), input/output interface, net
Network interface and memory.
Memory may include the non-volatile memory in computer-readable medium, random access memory (RAM) and/
Or the forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flash RAM).Memory is computer-readable Jie
The example of matter.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology come realize information store.Information can be computer readable instructions, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devices
Or any other non-transmission medium, can be used for storage can be accessed by a computing device information.As defined in this article, it calculates
Machine readable medium does not include temporary computer readable media (transitory media), such as the data-signal and carrier wave of modulation.
When introducing elements of various embodiments of the present invention, the article " one ", "one", " this " and " described " be intended to
Indicate one or more elements.Word "include", "comprise" and " having " are all inclusive and mean in addition to listing
Except element, there can also be other elements.
All the embodiments in this specification are described in a progressive manner, same and similar portion between each embodiment
Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.Especially for system reality
For applying example, since it is substantially similar to the method embodiment, so describing fairly simple, related place is referring to embodiment of the method
Part explanation.System embodiment described above is only schematical, wherein described be used as separate part description
Unit and module may or may not be physically separated.Furthermore it is also possible to select it according to the actual needs
In some or all of unit and module achieve the purpose of the solution of this embodiment.Those of ordinary skill in the art are not paying
In the case where creative work, it can understand and implement.
The above is only a specific embodiment of the invention, it is noted that for the ordinary skill people of the art
For member, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications are also answered
It is considered as protection scope of the present invention.