CN112231265A - 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 PDF

Info

Publication number
CN112231265A
CN112231265A CN202011095529.8A CN202011095529A CN112231265A CN 112231265 A CN112231265 A CN 112231265A CN 202011095529 A CN202011095529 A CN 202011095529A CN 112231265 A CN112231265 A CN 112231265A
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.)
Granted
Application number
CN202011095529.8A
Other languages
Chinese (zh)
Other versions
CN112231265B (en
Inventor
唐亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tianjin Jinhang Computing Technology Research Institute
Original Assignee
Tianjin Jinhang Computing Technology Research Institute
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Tianjin Jinhang Computing Technology Research Institute filed Critical Tianjin Jinhang Computing Technology Research Institute
Priority to CN202011095529.8A priority Critical patent/CN112231265B/en
Publication of CN112231265A publication Critical patent/CN112231265A/en
Application granted granted Critical
Publication of CN112231265B publication Critical patent/CN112231265B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/90Buffering arrangements
    • YGENERAL 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
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE 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/00Energy 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)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Software Systems (AREA)
  • Information Transfer Systems (AREA)
  • Communication Control (AREA)

Abstract

The invention relates to a high-speed data transmission method of serial equipment under an embedded operating system, belonging 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

High-speed data transmission method for serial device under embedded operating system
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 high-rate data transmission method for a serial device under an embedded operating system, so as to solve the problem of packet loss of high-rate transmission data driven by a general SIO serial port.
(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, 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;
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 a 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, 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 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, compiling 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 driving source code of the serial device 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 read register function REG _ SET, for writing a value to 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 (10)

1. 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, 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.
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 any one of claims 1 to 4, wherein the step S3 specifically includes the steps of:
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.
6. The method for transmitting high-rate data of a serial device under an embedded operating system according to claim 5, wherein 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.
7. The method for transmitting high-rate data of a serial device under an embedded operating system according to claim 6, wherein the step S5 specifically includes the steps of:
s51, opening a VxWorks development shell, and positioning to a path where the sio driver is located;
and S52, executing the make command.
8. 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.
9. 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;
and S5, recompiling the driver, and enabling the new serial port system to take effect.
10. The method for transmitting high-rate data of a serial device under an embedded operating system according to claim 9, wherein the step S3 specifically includes the steps of:
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.
CN202011095529.8A 2020-10-14 2020-10-14 High-speed data transmission method for serial device under embedded operating system Active CN112231265B (en)

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 true CN112231265A (en) 2021-01-15
CN112231265B 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 (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020133662A1 (en) * 2001-03-16 2002-09-19 Hugo Cheung Serial peripheral interface with high performance buffering scheme
CN103294509A (en) * 2013-05-17 2013-09-11 深圳市亿威尔信息技术股份有限公司 Multi-serial equipment driving process for VxWorks operating system
CN103728627A (en) * 2013-12-19 2014-04-16 天津光电通信技术有限公司 Embedded positioning system based on Ublox GPS module
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

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020133662A1 (en) * 2001-03-16 2002-09-19 Hugo Cheung Serial peripheral interface with high performance buffering scheme
CN103294509A (en) * 2013-05-17 2013-09-11 深圳市亿威尔信息技术股份有限公司 Multi-serial equipment driving process for VxWorks operating system
CN103728627A (en) * 2013-12-19 2014-04-16 天津光电通信技术有限公司 Embedded positioning system based on Ublox GPS module
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)

* Cited by examiner, † Cited by third party
Title
WEIXIN_34025151: "基于Vxworks实时操作系统的串口通信程序设计与实现", 《CSDN》 *
尹鹏: "基于Vxworks嵌入式操作系统的网络数据通信研究", 《中国优秀硕士学位论文全文数据库》 *
陈娟: "嵌入式操作系统Vxworks下设备驱动程序的研究与设计", 《中国优秀硕士学位论文全文数据库》 *

Also Published As

Publication number Publication date
CN112231265B (en) 2022-09-13

Similar Documents

Publication Publication Date Title
CN106155960B (en) It is shaken hands the UART serial port communication method with EDMA based on GPIO
RU2546561C2 (en) Converting message-initiated interruption into input/output adapter-generated event notification
JP5128122B2 (en) Address space emulation
US8078850B2 (en) Branch prediction technique using instruction for resetting result table pointer
US10860511B1 (en) Integrated network-attachable controller that interconnects a solid-state drive with a remote server computer
EP2831727B1 (en) Accessing a device on a remote machine
WO2021036370A1 (en) Method and device for pre-reading file page, and terminal device
US9164804B2 (en) Virtual memory module
CN104317791A (en) Gathering and scattering multiple data elements
JP2011519092A (en) Virtual interrupt mode interface and method for virtualizing interrupt mode
US20120137181A1 (en) Preventing log wrap with debug scripts
EP3598310B1 (en) Network interface device and host processing device
WO2020135010A1 (en) Method and device for processing hosted application, and computer readable storage medium
US20040221274A1 (en) Source-transparent endian translation
CN112231265B (en) High-speed data transmission method for serial device under embedded operating system
CN101777005A (en) Providing multiple virtual device controllers by redirecting an interrupt from a physical device controller
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
CN115905046B (en) Network card driving data packet processing method and device, electronic equipment and storage medium
US9288163B2 (en) Low-latency packet receive method for networking devices
JP2010532509A (en) System, processor, apparatus and method for interprocessor communication
JP3415931B2 (en) Method and apparatus for executing interrupt response of communication protocol
CN111427823B (en) Driving design method supporting PC and FPGA to communicate through PCIE
CN101162440B (en) Design method for built-in processor high speed on-line download straight-through channel
CN110138452A (en) A kind of data transmission method and system based on internet of things equipment indicator light

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