CN107172181A - A kind of document transmission method based on dual-thread - Google Patents
A kind of document transmission method based on dual-thread Download PDFInfo
- Publication number
- CN107172181A CN107172181A CN201710421095.8A CN201710421095A CN107172181A CN 107172181 A CN107172181 A CN 107172181A CN 201710421095 A CN201710421095 A CN 201710421095A CN 107172181 A CN107172181 A CN 107172181A
- Authority
- CN
- China
- Prior art keywords
- packet
- thread
- subdata
- receiving
- sent
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/06—Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/104—Peer-to-peer [P2P] networks
- H04L67/1074—Peer-to-peer [P2P] networks for supporting data block transmission mechanisms
- H04L67/1078—Resource delivery mechanisms
- H04L67/108—Resource delivery mechanisms characterised by resources being split in blocks or fragments
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Communication Control (AREA)
Abstract
The present invention provides a kind of document transmission method based on dual-thread, comprises the following steps:Packet sends thread, and file is divided into n sub- packets by the order from 1 to n and subdata bag number n is sent into packet receiving thread by serial ports;Packet receiving thread, one 1 queue arranged to n is set up according to subdata bag number n;Packet sends thread with fixed frequency, and subdata bag is sent to serial ports according to 1 to n order, while detecting whether that receiving the subdata packet number retransmitted the need for packet receiving thread is sent or file end of transmission notifies;If receiving file end of transmission notice, packet, which sends thread, to be stopped;If receiving the subdata packet number for needing to retransmit, the subdata bag accordingly numbered preferentially is sent;If not receiving, continue to send next subdata bag in order.
Description
Technical field
The present invention relates to a kind of document transmission method, specifically, a kind of file transmission side based on dual-thread relate to
Method.
Background technology
The terminal device of AFC System of Urban Mass Transit for example automatic machine, semi-automatic ticket vending machine, gate, from
Dynamic ticket taking machine, enquiry machine etc. obtain various parameters file, program file from station centre's server, then again by these texts
Part sends ticket card processing equipment to.The terminal device of usual AFC System of Urban Mass Transit is passed to ticket card processing equipment
Frequently with serial communication mode when sending file, as shown in figure 1, transmitting terminal only just may proceed to when receiving the feedback of receiving terminal
Next packet is sent, when Documents Comparison is big, because the wait link of this serial communication is more, single thread performs the cycle
It is longer, therefore transmission time is also long, is also easy to mistake occur.
In order to solve the problem of above is present, people are seeking a kind of preferable technical solution always.
The content of the invention
The purpose of the present invention is in view of the shortcomings of the prior art, so that there is provided a kind of file transmission side based on dual-thread
Method, has the advantages that method is simple, the used time is few.
To achieve these goals, the technical solution adopted in the present invention is:A kind of file transmission side based on dual-thread
Method, comprises the following steps:
Preparatory stage
Packet sends thread, file is divided into n data block according to regular length, each data block is packaged into a subnumber
According to bag, it is numbered according to order subdata bag hereof from 1 to n, and subdata bag number n is sent by serial ports
Give packet receiving thread;
Packet receiving thread, from serial ports received data packet send thread send subdata bag number n, and set up one by
Subdata packet number 1 arrives the queue that n is arranged;
The transmission stage
Packet sends thread with fixed frequency, according to 1 to n transmission order, subdata bag is sent to serial ports, while detection is
It is no to receive the subdata packet number retransmitted the need for packet receiving thread is sent or file end of transmission notice;If receiving
Notified to file end of transmission, packet, which sends thread, to be stopped;If receiving the subdata packet number for needing to retransmit, preferential hair
Send the subdata bag accordingly numbered;If not receiving, continue to send next subdata bag in order;
Packet receiving thread is received after the current sub-data packet number x that serial ports is sent, and corresponding subdata bag in queue is compiled
Number delete, whether be empty, if it is empty, then send thread to packet and send file end of transmission notice, packet if judging queue
Receiving thread stops;If not empty, then the subdata packet number for whether also having less than x in queue is judged, if so, returning to the subnumber
Thread is sent according to packet number to packet, if nothing, next subdata packet number to be received is waited.
Based on above-mentioned, if exceeding preset time, packet receiving thread is not received by the subdata bag volume of serial ports transmission
Number, and queue is not sky, then stops packet and send thread and packet receiving thread.
Based on above-mentioned, after packet transmission thread or the stopping of packet receiving thread, the internal storage data of correspondence thread is cleared up.
The present invention is compared with the prior art with prominent substantive distinguishing features and significantly progressive, and specifically, the present invention is adopted
The transmission of file is carried out with dual-thread, while packet sends thread sends subdata bag with fixed intervals to serial ports, without
With considering whether packet receiving thread have received packet, packet receiving thread is also in real time according to the packet received
The package number fed back to packet receiving thread and need to retransmit is numbered, transmission process and reception process are carried out simultaneously, effectively
Solve serial communication speed slow, the problem of error-prone, have the advantages that method is simple, the used time is short.
Brief description of the drawings
Fig. 1 is traditional serial communication process;
Fig. 2 is the document transmission method schematic flow sheet of the present invention.
Embodiment
Below by embodiment, technical scheme is described in further detail.
As shown in Fig. 2 a kind of document transmission method based on dual-thread, comprises the following steps:
Preparatory stage
Packet sends thread, file is divided into n data block according to regular length, each data block is packaged into a subnumber
According to bag, it is numbered according to order subdata bag hereof from 1 to n, and subdata bag number n is sent by serial ports
Give packet receiving thread;
Packet receiving thread, from serial ports received data packet send thread send subdata bag number n, and set up one by
Subdata packet number 1 arrives the tactic queues of n;
The transmission stage
Packet sends thread with fixed frequency, according to 1 to n transmission order, subdata bag is sent to serial ports, while detection is
It is no to receive the subdata packet number retransmitted the need for packet receiving thread is sent or file end of transmission notice;If receiving
Notified to file end of transmission, packet, which sends thread, to be stopped, while clearing up internal storage data;If receiving the subnumber for needing to retransmit
According to packet number, then the subdata bag accordingly numbered preferentially is sent;If not receiving, continue to send next subnumber in order
According to bag;
Packet receiving thread is received after the current sub-data packet number x that serial ports is sent, and corresponding subdata bag in queue is compiled
Number delete, while judging whether queue is empty, if it is empty, then send thread to packet and send file end of transmission and notify, count
Stop according to bag receiving thread, while clearing up internal storage data;If not empty, then the son for judging whether to also have less than x in queue is continued
Package number, if so, returning to the subdata packet number to packet sends thread, if nothing, waits next subdata to be received
Packet number.
It is preferred that, the serial ports of duplex communication, such as RS485 serial ports, RS422 serial ports or RS232 strings should be selected during selection serial ports
Mouthful.
This file needs not wait for after a sub- packet is sent successfully and carries out next subdata bag again
Transmission, but packet send thread with fixed intervals to serial ports send subdata bag while also received data packet receive
The package number that thread is retransmitted the need for sending, transmission process and reception process are carried out simultaneously, efficiently solve serial communication
Speed is slow, the problem of error-prone.
If it should be noted that more than preset time, packet receiving thread never has the son for receiving serial ports transmission
Package number, and queue is not sky, then it represents that communication failure, now need to stop packet transmission thread and packet receives line
Journey, and clear up the internal storage data that packet sends thread and packet receiving thread.
Finally it should be noted that:The above embodiments are merely illustrative of the technical scheme of the present invention and are not intended to be limiting thereof;To the greatest extent
The present invention is described in detail with reference to preferred embodiments for pipe, those of ordinary skills in the art should understand that:Still
The embodiment of the present invention can be modified or equivalent substitution is carried out to some technical characteristics;Without departing from this hair
The spirit of bright technical scheme, it all should cover among claimed technical scheme scope of the invention.
Claims (3)
1. a kind of document transmission method based on dual-thread, it is characterised in that comprise the following steps:
Preparatory stage
Packet sends thread, file is divided into n data block according to regular length, each data block is packaged into a subnumber
According to bag, it is numbered according to order subdata bag hereof from 1 to n, and subdata bag number n is sent by serial ports
Give packet receiving thread;
Packet receiving thread, from serial ports received data packet send thread send subdata bag number n, and set up one by
Subdata packet number 1 arrives the queue that n is arranged;
The transmission stage
Packet sends thread with fixed frequency, according to 1 to n transmission order, subdata bag is sent to serial ports, while detection is
It is no to receive the subdata packet number retransmitted the need for packet receiving thread is sent or file end of transmission notice;If receiving
Notified to file end of transmission, packet, which sends thread, to be stopped;If receiving the subdata packet number for needing to retransmit, preferential hair
Send the subdata bag accordingly numbered;If not receiving, continue to send next subdata bag in order;
Packet receiving thread is received after the current sub-data packet number x that serial ports is sent, and corresponding subdata bag in queue is compiled
Number delete, whether be empty, if it is empty, then send thread to packet and send file end of transmission notice, packet if judging queue
Receiving thread stops;If not empty, then the subdata packet number for whether also having less than x in queue is judged, if so, returning to the subnumber
Thread is sent according to packet number to packet, if nothing, next subdata packet number to be received is waited.
2. the document transmission method according to claim 1 based on dual-thread, it is characterised in that:If more than preset time,
Packet receiving thread is not received by the subdata packet number of serial ports transmission, and queue is not sky, then stops packet and send
Thread and packet receiving thread.
3. the document transmission method according to claim 1 or 2 based on dual-thread, it is characterised in that:Packet sends line
After journey or packet receiving thread stop, the internal storage data of cleaning correspondence thread.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710421095.8A CN107172181B (en) | 2017-06-07 | 2017-06-07 | File transmission method based on double threads |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710421095.8A CN107172181B (en) | 2017-06-07 | 2017-06-07 | File transmission method based on double threads |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107172181A true CN107172181A (en) | 2017-09-15 |
CN107172181B CN107172181B (en) | 2020-12-04 |
Family
ID=59825471
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710421095.8A Active CN107172181B (en) | 2017-06-07 | 2017-06-07 | File transmission method based on double threads |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107172181B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107945430A (en) * | 2017-11-24 | 2018-04-20 | 上海动联信息技术股份有限公司 | A kind of two-way concurrent means of communication based on serial ports for being used for intelligent POS machine |
CN110062295A (en) * | 2019-04-19 | 2019-07-26 | 视联动力信息技术股份有限公司 | A kind of file resource acquisition methods and system |
WO2023142301A1 (en) * | 2022-01-29 | 2023-08-03 | 南京沁恒微电子股份有限公司 | Method and system for real-time data uploading by usb virtual serial port, and usb host |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080313425A1 (en) * | 2007-06-15 | 2008-12-18 | Le Hung Q | Enhanced Load Lookahead Prefetch in Single Threaded Mode for a Simultaneous Multithreaded Microprocessor |
CN101656756A (en) * | 2009-09-17 | 2010-02-24 | 中国科学院声学研究所 | File transferring method with self-adaptive control of transmission speed and system thereof |
US8086801B2 (en) * | 2009-04-08 | 2011-12-27 | International Business Machines Corporation | Loading data to vector renamed register from across multiple cache lines |
CN103685243A (en) * | 2013-11-28 | 2014-03-26 | 许继电气股份有限公司 | Fault recording data transmission method based on UDP |
CN103957169A (en) * | 2014-05-14 | 2014-07-30 | 上海复兰信息科技有限公司 | Reliable UDP achievement method based on reserve request |
CN105242908A (en) * | 2015-11-24 | 2016-01-13 | 西安烽火电子科技有限责任公司 | Method for transmitting very high frequency radio large file based on serial hardware flow control |
CN105357305A (en) * | 2015-11-13 | 2016-02-24 | 北京金山安全软件有限公司 | File sending method and device, file receiving method and device and terminal equipment |
CN106341738A (en) * | 2015-07-08 | 2017-01-18 | 杭州海康威视数字技术股份有限公司 | Streaming media network transmission bandwidth calculation method, server and system |
-
2017
- 2017-06-07 CN CN201710421095.8A patent/CN107172181B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080313425A1 (en) * | 2007-06-15 | 2008-12-18 | Le Hung Q | Enhanced Load Lookahead Prefetch in Single Threaded Mode for a Simultaneous Multithreaded Microprocessor |
US8086801B2 (en) * | 2009-04-08 | 2011-12-27 | International Business Machines Corporation | Loading data to vector renamed register from across multiple cache lines |
CN101656756A (en) * | 2009-09-17 | 2010-02-24 | 中国科学院声学研究所 | File transferring method with self-adaptive control of transmission speed and system thereof |
CN103685243A (en) * | 2013-11-28 | 2014-03-26 | 许继电气股份有限公司 | Fault recording data transmission method based on UDP |
CN103957169A (en) * | 2014-05-14 | 2014-07-30 | 上海复兰信息科技有限公司 | Reliable UDP achievement method based on reserve request |
CN106341738A (en) * | 2015-07-08 | 2017-01-18 | 杭州海康威视数字技术股份有限公司 | Streaming media network transmission bandwidth calculation method, server and system |
CN105357305A (en) * | 2015-11-13 | 2016-02-24 | 北京金山安全软件有限公司 | File sending method and device, file receiving method and device and terminal equipment |
CN105242908A (en) * | 2015-11-24 | 2016-01-13 | 西安烽火电子科技有限责任公司 | Method for transmitting very high frequency radio large file based on serial hardware flow control |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107945430A (en) * | 2017-11-24 | 2018-04-20 | 上海动联信息技术股份有限公司 | A kind of two-way concurrent means of communication based on serial ports for being used for intelligent POS machine |
CN107945430B (en) * | 2017-11-24 | 2021-09-14 | 上海动联信息技术股份有限公司 | Serial-port-based bidirectional concurrent communication method for intelligent POS machine |
CN110062295A (en) * | 2019-04-19 | 2019-07-26 | 视联动力信息技术股份有限公司 | A kind of file resource acquisition methods and system |
WO2023142301A1 (en) * | 2022-01-29 | 2023-08-03 | 南京沁恒微电子股份有限公司 | Method and system for real-time data uploading by usb virtual serial port, and usb host |
GB2618707A (en) * | 2022-01-29 | 2023-11-15 | Nanjing Qinheng Microelectronics Co Ltd | Method and system for real-time data uploading by USB virtual serial port, and USB host |
GB2618707B (en) * | 2022-01-29 | 2024-04-03 | Nanjing Qinheng Microelectronics Co Ltd | Method and system for real-time data uploading by USB virtual serial port and USB host |
Also Published As
Publication number | Publication date |
---|---|
CN107172181B (en) | 2020-12-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107172181A (en) | A kind of document transmission method based on dual-thread | |
CN101223759B (en) | Transmission device and information communication method | |
US8526440B2 (en) | Partial radio link control status report | |
CN103905300B (en) | A kind of data message sending method, equipment and system | |
CN103354482B (en) | A kind of data transmission method, system and base station and user equipment | |
US20050152350A1 (en) | System and method for transmitting/receiving automatic repeat request | |
CN105517053B (en) | Reduce the method and system that protocol data unit of wireless links control layer is segmented again | |
KR880008565A (en) | Station for communication system and communication method | |
CN101411134A (en) | Memory management for high speed media access control | |
CN103338184B (en) | Data transmitting method and data transmitting apparatus | |
CN103944880B (en) | A kind of method of ZigBee data transfers | |
CN110460533A (en) | Data transmission method and device based on RDMA | |
CN101841403A (en) | Data transmission method and system | |
CN109673050A (en) | Data-reusing transmission method, network side equipment and communication system | |
CN102217283A (en) | Method and apparatus for pp file transmission | |
CN103338158B (en) | A kind of GOOSE message transmission delay jitter suppression method | |
CN104468061B (en) | A kind of method and system of real-time reliable data transmission under low-speed network environment | |
CN106301696B (en) | A kind of the bursty data sending, receiving method and device of ultralow time delay business | |
CN101267582B (en) | Method and system for high-speed download packet access to ignored RLC confirmation state report | |
CN109936859A (en) | Suitable for height delay low bandwidth satellite communication small data quantity transmission method | |
CN104486187B (en) | A kind of CAN communication device and method of dynamic synchronization | |
CN106209764A (en) | A kind of data transmission method based on udp protocol and system | |
CN104753813B (en) | The method that DMA transmits message | |
CN102238493A (en) | Machine-to-machine (M2M)-platform-based message sequential transmission and receiving method and device | |
CN101742451A (en) | Method, system and device for transmitting charging information |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |