CN104021100A - Method for processing data received by serial port of single-chip microcomputer - Google Patents
Method for processing data received by serial port of single-chip microcomputer Download PDFInfo
- Publication number
- CN104021100A CN104021100A CN201410223379.2A CN201410223379A CN104021100A CN 104021100 A CN104021100 A CN 104021100A CN 201410223379 A CN201410223379 A CN 201410223379A CN 104021100 A CN104021100 A CN 104021100A
- Authority
- CN
- China
- Prior art keywords
- data
- chip microcomputer
- serial port
- pointed
- pointer
- 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.)
- Withdrawn
Links
Landscapes
- Information Transfer Systems (AREA)
Abstract
The invention discloses a method for processing data received by a serial port of a single-chip microcomputer, and belongs to the field of serial port data processing. The method comprises the steps that a data cache array is firstly built, and then the received data are placed in the data cache array in sequence; after all the data are received, the single-chip microcomputer processes the data in the data cache array according to the placement sequence in sequence, and the aim that the data placed in the data cache array early can be processed earlier, and the data placed in the data cache array later are processed later is achieved. According to the method, all the received data can be processed in order by the single-chip microcomputer, and the occurrence rate of lost packets is effectively reduced.
Description
Technical field
The present invention relates to the disposal route that a kind of microcontroller serial port receives data, belong to serial data process field.
Background technology
In Internet of Things field, be unable to do without reception and the processing of data, serial ports is as a kind of conventional communication modes, and it is commonly employed in Internet of Things.
At present, the processing mode that microcontroller serial port receives data normally receives after one group of data, at once these group data are processed, and only have after last group of data processing is complete and could receive next group data, when having multi-group data to import single-chip microcomputer into continuously, can cause single-chip microcomputer to occur packet loss phenomenon like this.
Summary of the invention
The present invention is directed to the problem in background technology, and propose the disposal route that a kind of microcontroller serial port receives data, to reduce drop probabilities.
The present invention, for solving above technical matters, adopts following technical scheme:
Microcontroller serial port receives a disposal route for data, and the method comprises the following steps:
Step 1: set up data buffer storage array, and definition is used in reference to the data of element in data buffer storage array and writes pointer and data reading pointer;
Step 2: open serial ports and interrupt, single-chip microcomputer often receives after data, automatically enters serial ports interrupt service routine;
Step 3: in serial ports interrupt service routine, single-chip microcomputer writes the element of pointed by the data cover data that receive, and data are write to pointer add one;
Step 4: after all data receivers are complete, single-chip microcomputer is processed the element of data reading pointed, and data reading pointer is added to one, until all data processings are complete.
Further, in described step 4, all data processings are complete means that the position of data reading pointed is identical with the position that data write pointed.
Further, the element definition in described data buffer storage array is unsigned character type.
Technique effect:
1, change traditional serial data processing mode, the data that receive have first been temporarily stored in data buffer storage array, and then processed successively in order, effectively reduced the incidence of packet loss phenomenon.
2, method is simple, and reliability is high, has good using value.
Embodiment
Below technical scheme of the present invention is described further:
The disposal route that microcontroller serial port of the present invention receives data mainly comprises the following steps:
Step 1: set up data buffer storage array, and definition is used in reference to the data of element in data buffer storage array and writes pointer and data reading pointer, the element definition in data buffer storage array is unsigned character type;
Step 2: open serial ports and interrupt, single-chip microcomputer often receives after data, automatically enters serial ports interrupt service routine;
Step 3: in serial ports interrupt service routine, single-chip microcomputer writes the element of pointed by the data cover data that receive, and data are write to pointer add one, make to write the next element of pointed;
Step 4: after all data receivers are complete (this stage no longer enters serial ports interrupt service routine), single-chip microcomputer is processed the element of data reading pointed, and data reading pointer is added to one, make to read the next element of pointed, deal with data so successively, until all data processings are complete.
Before serial ports receives data, data write pointer and data reading pointer all points to the first element in buffer memory array, while receiving data, along with data enter buffer memory array, write pointer and move afterwards successively, after data receiver is complete, write a pointed end data next bit element.Along with data start to process, read pointer and move afterwards successively, after all data processings are complete, read pointer and also point to an end data next bit element.So, after data are processed, when position and the data of data reading pointed write the position of pointed when identical, representing that all data processings are complete, single-chip microcomputer is waited for next stage data receiver, pointer resets.
Single-chip microcomputer is put into data buffer storage array sequentially successively by the data of receiving, after receiving, processes successively again, has avoided importing data into continuously and makes single-chip microcomputer generation packet loss phenomenon.
Claims (3)
1. microcontroller serial port receives a disposal route for data, it is characterized in that comprising the following steps:
Step 1: set up data buffer storage array, and definition is used in reference to the data of element in data buffer storage array and writes pointer and data reading pointer;
Step 2: open serial ports and interrupt, single-chip microcomputer often receives after data, automatically enters serial ports interrupt service routine;
Step 3: in serial ports interrupt service routine, single-chip microcomputer writes the element of pointed by the data cover data that receive, and data are write to pointer add one;
Step 4: after all data receivers are complete, single-chip microcomputer is processed the element of data reading pointed, and data reading pointer is added to one, until all data processings are complete.
2. a kind of microcontroller serial port according to claim 1 receives the disposal route of data, it is characterized in that: in described step 4, all data processings are complete means that the position of data reading pointed is identical with the position that data write pointed.
3. a kind of microcontroller serial port according to claim 1 receives the disposal route of data, it is characterized in that: the element definition in described data buffer storage array is unsigned character type.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410223379.2A CN104021100A (en) | 2014-05-23 | 2014-05-23 | Method for processing data received by serial port of single-chip microcomputer |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410223379.2A CN104021100A (en) | 2014-05-23 | 2014-05-23 | Method for processing data received by serial port of single-chip microcomputer |
Publications (1)
Publication Number | Publication Date |
---|---|
CN104021100A true CN104021100A (en) | 2014-09-03 |
Family
ID=51437861
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410223379.2A Withdrawn CN104021100A (en) | 2014-05-23 | 2014-05-23 | Method for processing data received by serial port of single-chip microcomputer |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104021100A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109802759A (en) * | 2018-12-27 | 2019-05-24 | 北京航天福道高技术股份有限公司 | The method of data receiver processing |
CN112148444A (en) * | 2020-09-04 | 2020-12-29 | 珠海格力电器股份有限公司 | Data processing method, device and system and storage medium |
CN112231265A (en) * | 2020-10-14 | 2021-01-15 | 天津津航计算技术研究所 | High-speed data transmission method for serial device under embedded operating system |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030030556A1 (en) * | 2001-07-23 | 2003-02-13 | Edwards Systems Technology, Inc. | Modem communicator |
CN102629240A (en) * | 2012-02-13 | 2012-08-08 | 上海创远仪器技术股份有限公司 | Method and device for serial communication |
CN102724122A (en) * | 2012-06-21 | 2012-10-10 | 广东威创视讯科技股份有限公司 | Reliable serial port transmission method and device based on hardware system |
-
2014
- 2014-05-23 CN CN201410223379.2A patent/CN104021100A/en not_active Withdrawn
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030030556A1 (en) * | 2001-07-23 | 2003-02-13 | Edwards Systems Technology, Inc. | Modem communicator |
CN102629240A (en) * | 2012-02-13 | 2012-08-08 | 上海创远仪器技术股份有限公司 | Method and device for serial communication |
CN102724122A (en) * | 2012-06-21 | 2012-10-10 | 广东威创视讯科技股份有限公司 | Reliable serial port transmission method and device based on hardware system |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109802759A (en) * | 2018-12-27 | 2019-05-24 | 北京航天福道高技术股份有限公司 | The method of data receiver processing |
CN112148444A (en) * | 2020-09-04 | 2020-12-29 | 珠海格力电器股份有限公司 | Data processing method, device and system and storage medium |
CN112148444B (en) * | 2020-09-04 | 2024-06-07 | 珠海格力电器股份有限公司 | Data processing method, device, system and storage medium |
CN112231265A (en) * | 2020-10-14 | 2021-01-15 | 天津津航计算技术研究所 | High-speed data transmission method for serial device under embedded operating system |
CN112231265B (en) * | 2020-10-14 | 2022-09-13 | 天津津航计算技术研究所 | High-speed data transmission method for serial device under embedded operating system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2008045321A3 (en) | Method, system, and computer program product for resequencing of data segments received over a bonding channel set | |
US10140853B2 (en) | Household appliances infrared remote waveform replication learning method and system | |
CN105676023A (en) | Recording method and system of fault recording data | |
CN102724122B (en) | Reliable serial port transmission method and device based on hardware system | |
CN104021100A (en) | Method for processing data received by serial port of single-chip microcomputer | |
CN102263604A (en) | LTE (long term evolution) PDCCH (physical downlink control channel) demapping method and device | |
WO2010136775A3 (en) | Acquisition method and apparatus for mass spectrometer data | |
CN105872849B (en) | A kind of network transmission real-time audio and video error correction method and system based on FPGA | |
CN105573711A (en) | Data caching methods and apparatuses | |
CN101839984B (en) | Navigational satellite signal receiver | |
CN103559017A (en) | Character string matching method and system based on graphic processing unit (GPU) heterogeneous computing platform | |
CN102629235A (en) | Method for increasing read-write speed of double data rate (DDR) memory | |
CN110400569B (en) | Bluetooth audio repairing method and terminal equipment | |
US9137158B2 (en) | Communication apparatus and communication method | |
JP2012147435A5 (en) | ||
CN101227618B (en) | DVB-H system and method for performing forward error correction | |
CN103152134B (en) | Receiving terminal based on Real-time Transport Protocol resets the method and system of voice packet | |
US9465689B2 (en) | Forward error correction synchronization | |
US9559857B2 (en) | Preprocessing unit for network data | |
CN102739366A (en) | Soft bit information bit interception processing device and method | |
CN106899386B (en) | Method for demodulating fragmented frame signals based on multi-channel communication receiving system | |
CN104407367B (en) | Improve the apparatus and method of satellite navigation terminal receiver baseband signal disposal ability | |
CN207835492U (en) | A kind of Double buffer carrier wave demodulation system | |
CN103076995B (en) | The data processing method of NandFlash and device | |
CN103678235B (en) | Based on parallel pipeline network data processing device and method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C04 | Withdrawal of patent application after publication (patent law 2001) | ||
WW01 | Invention patent application withdrawn after publication |
Application publication date: 20140903 |