CN112231265B - High-speed data transmission method for serial device under embedded operating system - Google Patents
High-speed data transmission method for serial device under embedded operating system Download PDFInfo
- Publication number
- CN112231265B CN112231265B CN202011095529.8A CN202011095529A CN112231265B CN 112231265 B CN112231265 B CN 112231265B CN 202011095529 A CN202011095529 A CN 202011095529A CN 112231265 B CN112231265 B CN 112231265B
- Authority
- CN
- China
- Prior art keywords
- function
- serial port
- receiving
- serial
- data
- 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.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/42—Bus transfer protocol, e.g. handshake; Synchronisation
- G06F13/4282—Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L49/00—Packet switching elements
- H04L49/90—Buffering arrangements
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Transfer Systems (AREA)
- Communication Control (AREA)
Abstract
The invention relates to a high-speed data transmission method for serial devices under an embedded operating system, and belongs to the field of embedded software development. The invention increases the function of reading and writing the serial port chip register; adding a custom receiving cache in the serial port opening function; rewriting a serial port interrupt service function and a receiving function by adopting a mode of adding a special cache and one-time reading empty; registering the rewritten interrupt service function and the rewritten receiving function in an equipment driving list, or adding the rewritten interrupt service function and the rewritten receiving function as a callback function into a serial port initialization list; recompiling the driver. The method is based on a standard SIO interface driving model, improves the processing mode, enhances the reliability of high-speed serial port data transmission under an embedded operating system, can ensure that the problem of data loss does not occur during the high-speed data transmission by adopting the serial port chip driving program modified by the method, and is easy to realize, obvious in effect, stable and reliable.
Description
Technical Field
The invention belongs to the field of embedded software development, and particularly relates to a high-rate data transmission method for serial devices under an embedded operating system.
Background
The serial port communication mode has the characteristics of simplicity, convenience, low cost and the like, and is still widely applied to the field of embedded electronics, such as the industrial fields of environment monitoring, data acquisition, industrial control, financial interruption, touch screens and the like. With the rapid development of processors and the arrival of the era of equipment intellectualization and networking, the speed of serial port communication is required to be higher and higher, and the 2Mbps serial port baud rate slowly becomes a trend. At present, most serial port chips in the market are supported by a general SIO device driver provided in an embedded operating system, but in practice, the phenomenon of packet loss occasionally occurs when the speed of a serial port exceeds 1.5 Mbps.
In order to solve the problem, a data processing mechanism with higher efficiency is found out by starting from a general serial port driver and researching a realization mechanism of the driver, the consumption of interrupt resources is reduced, and a method for realizing the high-speed data transmission of the serial port is provided.
Disclosure of Invention
Technical problem to be solved
The technical problem to be solved by the invention is how to provide a method for transmitting high-speed data of a serial device under an embedded operating system, so as to solve the problem that the packet loss occurs when a general SIO serial port drives the high-speed transmission data.
(II) technical scheme
In order to solve the technical problem, the invention provides a high-speed data transmission method of serial equipment under an embedded operating system, which comprises the following steps:
s1, adding functions for reading and writing the serial port chip register;
s2, adding a custom receiving cache in the serial port opening function;
s3, rewriting the serial port interrupt service function and the receiving function by adding a special cache and a one-time blank reading mode;
s4, registering the rewritten interrupt service function and the receiving function in the device driving list;
and S5, recompiling the driver, and enabling the new serial port system to take effect.
Further, the step S1 specifically includes the following steps:
s11, writing a register reading function REG _ GET for obtaining a chip register value;
s12, program the read register function REG _ SET for writing values to the chip registers.
Further, the step S2 specifically includes: finding a serial port opening function, and customizing an N-byte receiving cache when creating the device descriptor, wherein the N-byte receiving cache is used for reading serial port data from the chip FIFO and registering the serial port data into a device resource list.
Further, N is 32M or more.
Further, the step S3 specifically includes the following steps:
s31, defining an interrupt service function;
s32, defining a receiving function;
s33, judging the interrupt type in the interrupt service function, if the interrupt is received, calling the receiving function, and clearing the interrupt;
s34, in the receiving function, acquiring the number of data in the receiving cache by reading the register function;
s35, controlling the for loop times according to the data number, and reading one byte of data to the receiving buffer created in the step S2.
Further, the step S4 specifically includes the following steps:
s41, finding a device driving function list data structure;
s42, adding the interrupt service function and the receive function to the data structure.
Further, the step S5 specifically includes the following steps:
s51, opening a VxWorks development shell, and positioning to a path where the sio driver is located;
and S52, executing the make command.
Further, the serial port chip is an Ns17D158 serial port expansion chip.
The invention also provides a high-speed data transmission method of the serial device under the embedded operating system, which comprises the following steps:
s1, increasing functions of reading and writing serial port chip registers;
s2, adding a custom receiving cache in the serial port opening function;
s3, rewriting the serial port interrupt service function and the receiving function by adding a special cache and a one-time blank reading mode;
s4, adding the rewritten interrupt service function and the rewritten receiving function into a serial port initialization list as callback functions;
and S5, recompiling the driver, and enabling the new serial port system to take effect.
Further, the step S3 specifically includes the following steps:
s31, defining an interrupt service function;
s32, defining a receiving function;
s33, judging the interrupt type in the interrupt service function, if the interrupt is received, calling the receiving function, and clearing the interrupt;
s34, in the receiving function, acquiring the number of data in the receiving cache by reading the register function;
s35, controlling the for loop times according to the data number, and reading one byte of data to the receiving buffer created in the step S2.
(III) advantageous effects
The invention provides a high-speed data transmission method of serial equipment under an embedded operating system, which is based on a standard SIO interface driving model, perfects the processing mode and enhances the reliability of high-speed serial data transmission under the embedded operating system. The Ns17D158 serial port chip driving program changed by adopting the operation steps can ensure that the problem of data loss does not occur during high-speed data transmission.
Drawings
FIG. 1 is a flow chart of a high-speed data transmission method of a serial device under an embedded operating system according to the present invention;
fig. 2 is a specific flowchart for solving the problem of serial port high-speed data transmission according to the present invention.
Detailed Description
In order to make the objects, contents and advantages of the present invention clearer, the following detailed description of the embodiments of the present invention will be made in conjunction with the accompanying drawings and examples.
The invention belongs to a technical method for realizing high-speed serial communication under an embedded operating system, and solves the problem that received bytes are easy to lose when the serial baud rate is more than 1.5Mbps in an embedded environment. The invention is based on the standard SIO interface driving model, perfects the processing mode and enhances the reliability of high-speed serial port data transmission under the embedded operating system.
In order to achieve the purpose, the invention adopts the following technical measures:
s1, adding functions for reading and writing the serial port chip register;
s2, adding a custom receiving cache in the serial port opening function;
s3, rewriting the serial port interrupt service function and the receiving function by adding a special cache and a one-time blank reading mode;
s4, registering the rewritten interrupt service function and the rewritten receiving function into the device driving list, or adding the rewritten interrupt service function and the rewritten receiving function into the serial port initialization list as callback functions;
and S5, recompiling the driver, and enabling the new serial port system to take effect.
Through the steps, the problem of data packet loss in communication when the serial port baud rate is more than 1.5Mbps is solved.
The key points of the invention are as follows: firstly, writing a function for accessing a serial port chip register; secondly, receiving and caching a custom serial port; thirdly, rewriting the serial port interrupt service function and the receiving function and registering the serial port interrupt service function and the receiving function in a serial port initialization function list; fourthly, recompiling the driver to enable the changed serial port driver to take effect.
The invention improves the serial device driving source code in the operating system.
The invention adds the self-defined data receiving cache and adds the data receiving cache to the equipment.
The invention rewrites the serial port interrupt receiving service program.
The invention writes the function for accessing the register of the serial device and obtains the serial data in the interrupt receiving service program.
The invention reads the data in the FIFO of the serial port chip once and writes the data into the custom receiving buffer.
With reference to fig. 1-2, in order to solve the problem that the received bytes are easily lost when the serial port baud rate is greater than 1.5Mbps in the embedded environment, we improve the interrupt execution efficiency by rewriting the serial port interrupt service function and the receive function, reduce the interrupt occurrence frequency, and change the receive mechanism to solve the problem. The content of the present invention is further described below with reference to the Ns17D158 serial port expansion chip in the embedded operating system.
1. Writing read-write register function in vxbNs17D158sio.c file
S11, writing a register reading function REG _ GET for obtaining a register value of the Ns17D158 chip;
s12, program the read register function REG _ SET to write a value to the Ns17D158 chip register.
2. Adding custom receiving cache in serial port opening function Ns17D158vxbOpen
Finding the Ns17D158vxbOpen function, defining an N-byte receiving buffer (N is greater than or equal to 32M, and the receiving buffer is large enough to ensure that the serial data cannot overflow) when the device descriptor is created, and reading the serial data from the chip FIFO and registering the serial data in a device resource list.
3. Rewriting the interrupt service function and the receiving function in the vxbNs17D158sio.c file
S31, defining a void xr17D158ChanInt (NS17D158_ CHAN × pChan) interrupt service function;
s32, defining a void xr17D158IntRd (NS17D158_ CHAN × pChan) receiving function;
s33, judging the interrupt type in the interrupt service function, if the interrupt is received, calling a receiving function xr17d158IntRd, and clearing the interrupt;
s34, in the receiving function, acquiring the number of data in the receiving cache by reading the register function;
s35, controlling the for loop times according to the data number, and reading one byte of data to the receiving buffer created in the step S2.
4. Registering the rewritten interrupt service function and the reception function in the device driver list
S41, finding a data structure of a device driver function list Ns17D158 vxbSioDrvFuncs;
s42, adding an interrupt service function xr17d158ChanInt function and a receiving function xr17d158IntRd function into the data structure.
5. Recompilation driver
S51, opening a VxWorks development shell, and positioning to the path C where the sio driver is located, wherein \ WindRiver \ VxWorks-6.x \ target \ src \ drv.
And S52, executing the make command.
By utilizing the technical scheme and adopting the operation steps, the changed Ns17D158 serial port chip driving program can ensure that the problem of data loss does not occur during high-speed data transmission.
The above description is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, several modifications and variations can be made without departing from the technical principle of the present invention, and these modifications and variations should also be regarded as the protection scope of the present invention.
Claims (8)
1. A high-speed data transmission method for a serial device under an embedded operating system is characterized by comprising the following steps:
s1, increasing functions of reading and writing serial port chip registers;
s2, adding a custom receiving cache in the serial port opening function;
s3, rewriting the serial port interrupt service function and the receiving function by adding a special cache and a one-time blank reading mode;
s4, registering the rewritten interrupt service function and the receiving function in the device driving list;
s5, recompiling the driver, and enabling the new serial port system to take effect;
the step S3 specifically includes the following steps:
s31, defining an interrupt service function;
s32, defining a receiving function;
s33, judging the interrupt type in the interrupt service function, if the interrupt is received, calling the receiving function, and clearing the interrupt;
s34, in the receiving function, acquiring the number of data in the receiving cache by reading the register function;
s35, controlling the for circulation times according to the data number, and reading one byte of data to the receiving buffer created in the step S2 each time.
2. The method for transmitting high-rate data of a serial device under an embedded operating system according to claim 1, wherein the step S1 specifically includes the steps of:
s11, writing a register reading function REG _ GET for obtaining a chip register value;
s12, program the read register function REG _ SET for writing values to the chip registers.
3. The method for transmitting high-rate data of a serial device under an embedded operating system according to claim 1, wherein the step S2 specifically includes: finding a serial port opening function, and customizing an N-byte receiving cache when creating the device descriptor, wherein the N-byte receiving cache is used for reading serial port data from the chip FIFO and registering the serial port data into a device resource list.
4. The method for transmitting high-rate data of a serial device under an embedded operating system according to claim 3, wherein N is greater than or equal to 32M.
5. The method for transmitting high-rate data of a serial device under an embedded operating system according to claim 1, wherein the step S4 specifically includes the steps of:
s41, finding a device driving function list data structure;
s42, adding the interrupt service function and the receive function to the data structure.
6. The method for transmitting high-rate data of a serial device under an embedded operating system according to claim 5, wherein the step S5 specifically includes the following steps:
s51, opening a VxWorks development shell, and positioning to a path where the sio driver is located;
and S52, executing the make command.
7. The method for transmitting the high-speed data of the serial device under the embedded operating system according to claim 1, wherein the serial chip is a Ns17D158 serial expansion chip.
8. A high-speed data transmission method of serial equipment under an embedded operating system is characterized by comprising the following steps:
s1, increasing functions of reading and writing serial port chip registers;
s2, adding a custom receiving cache in the serial port opening function;
s3, rewriting the serial port interrupt service function and the receiving function by adding a special cache and a one-time blank reading mode;
s4, adding the rewritten interrupt service function and the rewritten receiving function into a serial port initialization list as callback functions;
s5, recompiling the driver, and enabling the new serial port system to take effect;
the step S3 specifically includes the following steps:
s31, defining an interrupt service function;
s32, defining a receiving function;
s33, judging the interrupt type in the interrupt service function, if the interrupt is received, calling the receiving function, and clearing the interrupt;
s34, in the receiving function, acquiring the number of data in the receiving cache by reading the register function;
s35, controlling the for circulation times according to the data number, and reading one byte of data to the receiving buffer created in the step S2 each time.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011095529.8A CN112231265B (en) | 2020-10-14 | 2020-10-14 | High-speed data transmission method for serial device under embedded operating system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011095529.8A CN112231265B (en) | 2020-10-14 | 2020-10-14 | High-speed data transmission method for serial device under embedded operating system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112231265A CN112231265A (en) | 2021-01-15 |
CN112231265B true CN112231265B (en) | 2022-09-13 |
Family
ID=74112921
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011095529.8A Active CN112231265B (en) | 2020-10-14 | 2020-10-14 | High-speed data transmission method for serial device under embedded operating system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112231265B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103294509A (en) * | 2013-05-17 | 2013-09-11 | 深圳市亿威尔信息技术股份有限公司 | Multi-serial equipment driving process for VxWorks operating system |
CN104021100A (en) * | 2014-05-23 | 2014-09-03 | 无锡市崇安区科技创业服务中心 | Method for processing data received by serial port of single-chip microcomputer |
CN104965700A (en) * | 2015-06-09 | 2015-10-07 | 航天科工深圳(集团)有限公司 | Method and system for implementing driving on SPI equipment under VxWorks operating system |
CN107168710A (en) * | 2017-05-16 | 2017-09-15 | 太原鹏跃电子科技有限公司 | A kind of built-in Linux Development of Serial Driver method based on barrage reception mechanism |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6687769B2 (en) * | 2001-03-16 | 2004-02-03 | Texas Instruments Incorporated | Serial peripheral interface with high performance buffering scheme |
CN103728627A (en) * | 2013-12-19 | 2014-04-16 | 天津光电通信技术有限公司 | Embedded positioning system based on Ublox GPS module |
-
2020
- 2020-10-14 CN CN202011095529.8A patent/CN112231265B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103294509A (en) * | 2013-05-17 | 2013-09-11 | 深圳市亿威尔信息技术股份有限公司 | Multi-serial equipment driving process for VxWorks operating system |
CN104021100A (en) * | 2014-05-23 | 2014-09-03 | 无锡市崇安区科技创业服务中心 | Method for processing data received by serial port of single-chip microcomputer |
CN104965700A (en) * | 2015-06-09 | 2015-10-07 | 航天科工深圳(集团)有限公司 | Method and system for implementing driving on SPI equipment under VxWorks operating system |
CN107168710A (en) * | 2017-05-16 | 2017-09-15 | 太原鹏跃电子科技有限公司 | A kind of built-in Linux Development of Serial Driver method based on barrage reception mechanism |
Non-Patent Citations (3)
Title |
---|
基于Vxworks实时操作系统的串口通信程序设计与实现;weixin_34025151;《CSDN》;20081218;第1-4页 * |
基于Vxworks嵌入式操作系统的网络数据通信研究;尹鹏;《中国优秀硕士学位论文全文数据库》;20170331(第2017年03期);I138-3565 * |
嵌入式操作系统Vxworks下设备驱动程序的研究与设计;陈娟;《中国优秀硕士学位论文全文数据库》;20120228(第2012年02期);I138-1475 * |
Also Published As
Publication number | Publication date |
---|---|
CN112231265A (en) | 2021-01-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11176068B2 (en) | Methods and apparatus for synchronizing uplink and downlink transactions on an inter-device communication link | |
US10551906B2 (en) | Methods and apparatus for running and booting inter-processor communication link between independently operable processors | |
US20160077740A1 (en) | Systems and methods for enabling local caching for remote storage devices over a network via nvme controller | |
CN106155960B (en) | It is shaken hands the UART serial port communication method with EDMA based on GPIO | |
CN102103483B (en) | Gathering and scattering multiple data elements | |
US8078850B2 (en) | Branch prediction technique using instruction for resetting result table pointer | |
US9164804B2 (en) | Virtual memory module | |
WO2021036370A1 (en) | Method and device for pre-reading file page, and terminal device | |
JP2011519092A (en) | Virtual interrupt mode interface and method for virtualizing interrupt mode | |
WO2013143121A1 (en) | Accessing a device on a remote machine | |
US20120137181A1 (en) | Preventing log wrap with debug scripts | |
EP3598310B1 (en) | Network interface device and host processing device | |
WO2022213865A1 (en) | Computer device, virtual acceleration device, data transmission method, and storage medium | |
CN115905046B (en) | Network card driving data packet processing method and device, electronic equipment and storage medium | |
CN112231265B (en) | High-speed data transmission method for serial device under embedded operating system | |
US9477538B2 (en) | Method and system for the support of application specific policies for conventional operating systems | |
US11429438B2 (en) | Network interface device and host processing device | |
JP5498378B2 (en) | System, processor, apparatus and method for interprocessor communication | |
US9288163B2 (en) | Low-latency packet receive method for networking devices | |
CN112612728A (en) | Cache management method, device and equipment | |
JP3415931B2 (en) | Method and apparatus for executing interrupt response of communication protocol | |
CN115061958A (en) | Hard disk identification method, identification system, storage medium and computer equipment | |
US8180926B2 (en) | Adaptable resource spoofing for an extended computer system | |
CN110138452A (en) | A kind of data transmission method and system based on internet of things equipment indicator light | |
CN116795493B (en) | Method for processing instructions, processing system and computer readable storage medium |
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 |