[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN108470008A - Serial data reading/writing method, device, computer equipment and storage medium - Google Patents

Serial data reading/writing method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN108470008A
CN108470008A CN201810063577.5A CN201810063577A CN108470008A CN 108470008 A CN108470008 A CN 108470008A CN 201810063577 A CN201810063577 A CN 201810063577A CN 108470008 A CN108470008 A CN 108470008A
Authority
CN
China
Prior art keywords
direct memory
memory access
data
serial
buffer circle
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
CN201810063577.5A
Other languages
Chinese (zh)
Other versions
CN108470008B (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.)
GUANGZHOU CITY ZHONGHAIDA SURVEYING INSTRUMENT CO Ltd
Original Assignee
GUANGZHOU CITY ZHONGHAIDA SURVEYING INSTRUMENT CO Ltd
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 GUANGZHOU CITY ZHONGHAIDA SURVEYING INSTRUMENT CO Ltd filed Critical GUANGZHOU CITY ZHONGHAIDA SURVEYING INSTRUMENT CO Ltd
Priority to CN201810063577.5A priority Critical patent/CN108470008B/en
Publication of CN108470008A publication Critical patent/CN108470008A/en
Application granted granted Critical
Publication of CN108470008B publication Critical patent/CN108470008B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/14Handling requests for interconnection or transfer
    • G06F13/16Handling requests for interconnection or transfer for access to memory bus
    • G06F13/1668Details of memory controller
    • G06F13/1673Details of memory controller using buffers
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present invention relates to a kind of serial data reading/writing method, device, computer equipment and storage mediums, including:Configure direct memory access resource;Traversal direct memory access node name is simultaneously compared with preset node name;When direct memory access node name is consistent with preset node name, parses direct memory access resource and configure the transmission mode of direct memory access;Construct Crossed Circle buffering area memory;It creates device file descriptor and device file descriptor is monitored;When listening to dynamic, operation is written and read in Crossed Circle buffering area.Pass through direct memory access transmission module, realize the quick transmission of data, it stores by constructing Crossed Circle buffering area, manage data, efficiently solve data buffering storage problem, serial equipment data are monitored by epoll mechanism, system resource overhead is saved, data real-time tranception efficiency is improved, there are problems that overflowing on a small quantity to further solve serial data transmission, lose, usurp the throne.

Description

Serial data reading/writing method, device, computer equipment and storage medium
Technical field
The present invention relates to embedded system technology fields, more particularly to a kind of serial data reading/writing method, device, calculating Machine equipment and storage medium.
Background technology
GNSS (Global Navigation Satellite System) locating module can be configured to the rate update output of 1Hz, 5Hz, 10Hz For GNSS initial data to serial ports, user, which applies, also needs to write while constantly reading serial equipment data data to serial ports, That is serial ports needs both data interactive communication with user's application.
Conventional solution is, in LINUX system inner nuclear layer, serial communication uses PIO patterns (Programming Input/Output Model), by CPU respond interrupt, execute I/O port instruction carry out reading and writing data come realize data communicate, In the serial communication application of client layer, serial data is monitored using Select mechanism.
It is both data life that hardware device (such as serial ports, network interface) has mass data interaction, the two between the two with user's application Production person is also data consumer.For this producer and consumer's pattern, traditional technology lacks a kind of good data management Pattern effectively realizes data interaction, especially when distribution/release of memory space is very frequent, using queue buffer meeting Increase overhead;Traditional PIO mode data transmissions execute I/O port commands come according to word using interrupt mode notice CPU The processing of the data unit of section or bigger, cpu resource occupies greatly, and transmission data speed is slow;Though Select monitoring mechanisms can be with Multiple equipment filec descriptor is monitored, but calls select every time, is required for a device file descriptor set from User space Copy kernel state to, overhead is big;Select is called every time, and the All Files that traversal transmission is come in kernel is required for retouch Symbol is stated, overhead is increased;The filec descriptor quantity that Select monitoring mechanisms are supported is small, and data are answered from hardware to user Whole process lacks an effective data link management flow.Therefore it is exported to serial ports with GNSS locating modules The rate of data improves, and serial ports can exist in long-time, the communication of high bit rate, big data quantity and overflow, lose on a small quantity, usurp the throne.
Invention content
Based on this, it is necessary to there are problems that overflowing on a small quantity for serial data, lose, usurp the throne, provide a kind of serial data Reading/writing method.
A kind of serial data reading/writing method, including:
Configure the direct memory access resource of serial equipment in device tree;
Traverse the direct memory access node name in the direct memory access resource and with serial port drive it is preset directly Internal storage access node name is compared;
When direct memory access node name and the preset direct memory access node name of the serial port drive in device tree When consistent, parse the direct memory access resource, application direct memory access channel resource and configure direct memory access Transmission mode;
Construct first annular buffering area memory and the second buffer circle memory;
It creates device file descriptor and the device file descriptor is monitored;
When listening to the dynamic of the device file descriptor, reading behaviour is carried out in the first annular buffering area memory Make, write operation is carried out in the second buffer circle memory.
In one embodiment, when direct memory access node name and the serial port drive in device tree are preset directly When internal storage access node name is inconsistent, PIO transmission modes are configured.
In one embodiment, in the configuration device tree the step of direct memory access resource of serial equipment, including:
Direct memory access controller and direct memory access transmission/receiving channel number are obtained according to chip data table;
In system equipment tree file, the corresponding direct memory access controller of addition serial equipment, it is described directly Internal storage access transmission/receiving channel number and direct memory access node name.
In one embodiment, described the step of constructing first annular buffering area memory and the second buffer circle memory, Including:
The structure of construction description buffer circle;
Create the initialization interface function of buffer circle, buffer circle reads interface function and buffer circle writes interface Function;
The initialization interface function of the buffer circle, the buffer circle is called to read interface function and the annular Buffering area writes interface function and builds first annular buffering area memory and the second buffer circle memory.
In one embodiment, described to create device file descriptor and the device file descriptor monitored Step, including:
Serial equipment node is opened, serial equipment filec descriptor is generated;
It is associated with the serial equipment filec descriptor and creates epoll objects, generate epoll filec descriptors;
Establish the monitoring to serial equipment filec descriptor.
In one embodiment, described when listening to the dynamic of the device file descriptor, carry out first ring The step of read-write operation of shape buffering area memory and the second buffer circle memory, including:
When the first annular buffering area there are data to be passed to, the data of the first annular buffering area are read;
When second buffer circle has data write-in, data are spread out of from the second buffer circle.
A kind of serial data read-write equipment, including:
Configuration device:Direct memory access resource for configuring serial equipment in device tree;
Comparison device:Traverse the direct memory access node name in the direct memory access resource and pre- with serial port drive If direct memory access node name compared;
Apply for device:When the direct memory access node name in device tree is visited with the preset direct memory of the serial port drive When asking that node name is consistent, parses the direct memory access resource, application direct memory access channel resource and configure in directly Deposit the transmission mode of access;
Constructing apparatus:Construct first annular buffering area memory and the second buffer circle memory;
Monitoring device:It creates device file descriptor and the device file descriptor is monitored;
Read-write equipment:When listening to the dynamic of the device file descriptor, in the first annular buffering area memory Read operation is carried out, write operation is carried out in the second buffer circle memory.
In one embodiment, the read-write equipment includes:
Reading device:For when the first annular buffering area has data to be passed to, reading the first annular buffering area Data;
Writing station:For when second buffer circle has data write-in, by data from the second buffer circle Outflow.
A kind of computer equipment, the computer equipment include memory, processor and storage on a memory and can locate The computer program run on reason device, wherein processor realizes that above-mentioned serial data such as is read when executing the computer program The step of write method.
A kind of storage medium, is stored thereon with computer program, wherein is realized as above-mentioned when the program is executed by processor Serial data reading/writing method the step of.
Above-mentioned serial data reading/writing method avoids CPU and frequently responds interruption by direct memory access transmission module, Cpu resource is saved, realizes the quick transmission of data, data, an annular are stored, manage by constructing Crossed Circle buffering area Buffering area is used to store the incoming data of direct memory access, another buffer circle is therefrom spread out of for direct memory access Data, the data of storage user's application write-in, efficiently solve data buffering storage problem, serial ports are monitored by epoll mechanism Device data saves system resource overhead, improves data real-time tranception efficiency, is passed to further solve serial data It is defeated to there are problems that overflowing on a small quantity, lose, usurp the throne.
Description of the drawings
Fig. 1 is the serial data reading/writing method flow diagram of an embodiment;
Fig. 2 is flow diagram the step of configuring the direct memory access resource of serial ports in device tree of an embodiment;
The flow for the step of Fig. 3 is the first annular buffering area memory of construction and the second buffer circle memory of an embodiment Schematic diagram;
The step of Fig. 4 is the establishment device file descriptor of an embodiment and monitors the device file descriptor Flow diagram;
Fig. 5 is the reading of the progress first annular buffering area memory and the second buffer circle memory of an embodiment The flow diagram of the step of write operation;
Fig. 6 is the module diagram of the serial data read-write equipment of an embodiment;
Fig. 7 is the module diagram of the first configuration device of an embodiment;
Fig. 8 is the module diagram of the constructing apparatus of an embodiment;
Fig. 9 is the module diagram of the monitoring device of an embodiment;
Figure 10 is the module diagram of the read-write equipment of an embodiment.
Specific implementation mode
In order to make the purpose , technical scheme and advantage of the present invention be clearer, right below in conjunction with drawings and examples The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and It is not used in the restriction present invention.
Fig. 1 is the serial data reading/writing method flow diagram of an embodiment.As shown in Figure 1, the present invention provides a kind of string Mouth data read-write method, including:
Step S101:Configure the direct memory access resource of serial equipment in device tree.
Specifically, in system equipment number file, the corresponding direct memory access (Direct of addition serial equipment Memory Access) resource, as the term suggests direct memory access function is exactly to allow equipment that can bypass processor, directly by interior It deposits to read data.Above-mentioned direct memory access resource include the corresponding direct memory access controller of serial equipment, directly in Access transmission/receiving channel number, direct memory access node name etc. are deposited, wherein direct memory access controller is visited with direct memory Ask that channel number is obtained according to the tables of data of chip, and what is set in direct memory access node name needs and serial port drive searches Rope name is consistent, and above-mentioned search name can freely be given by user.
More specifically, direct memory access transmission process can be divided into three parts:
1, direct memory access request CPU controls direct memory access
Direct memory access controller asks direct memory access to differentiate priority and shielding, is carried to bus ruling logic Go out bus request, when CPU has executed Current bus period i.e. releasable bus control right.At this point, the output of bus ruling logic is total Line response indicates that direct memory access has responded to, is initialized by direct memory access control device, and send out behaviour to I/O interfaces It orders, I/O interfaces propose that direct memory access request, direct memory access reactive mode device notice I/O interfaces start in directly Deposit access transport.
2, direct memory access transmits
After direct memory access controller obtains bus control right, CPU hangs up or only carries out at once internal operation, by direct Internal storage access controller exports read write command, directly controls RAM and carries out direct memory access transmission with I/O interfaces, in directly Under the control for depositing access controller, data transmission is directly carried out between memory and external equipment, is not required in transmit process Want the participation of central processing unit.Initial position and the data length of the data to be transmitted need to be provided when beginning.
3, direct memory access terminates
As defined in the completion after bulk data transfer, direct memory access controller discharges bus control right, and to I/O Interface sends out end signal.After I/O interfaces receive end signal, on the one hand stop I/O equipment work, on the other hand to CPU proposes interrupt requests, and CPU is made to be freed from the state being not involved in, and executes one section and check this direct memory access transmission behaviour Make the code of correctness.Finally, original program is continued to execute with this operating result and state.
Therefore, direct memory access transmission mode directly controls transmission without CPU, is also protected like that without Interrupt Processing Model The process for staying scene and restoring scene is opened up the access of a direct transmission data with I/O equipment for RAM by hardware, makes CPU Efficiency greatly improve.
Step S102:Traverse the direct memory access node name and preset with serial port drive in direct memory access resource Direct memory access node name is compared.
Specifically, traversal refers to doing once and only doing primary access to each node successively along certain search pattern, In the present embodiment, meaning be each direct memory access node name with the direct memory access node of serial port drive equipment Name is once compared.
In serial port drive, the direct memory access station code of retrieval facility tree is added, calls retrieval facility tree node Function interface traverses direct memory access node name, and is compared with the preset direct memory access node name of serial port drive It is right, if the direct memory access node name in device tree is consistent with the preset node name of serial port drive, retrieves successfully, continue Direct memory access transmission mode, if direct memory access node name and the preset node name of serial port drive in device tree are not When consistent, the read-write operation of data is carried out using PIO patterns.
More specifically, PIO is most previous hard disc data transmission mode, the ports I/O are executed using interrupt mode notice CPU Instruction to handle according to the data unit of byte or bigger, and message transmission rate is low, and CPU occupation rates are also very high, a large amount of to transmit It can lead to system-down because excessive cpu resource is occupied when data, other operations can not be carried out.
Step S103:Judge the direct memory access node name in device tree and the preset direct memory access of serial port drive Whether node name is consistent.
Step S104:When direct memory access node name and the preset direct memory access section of serial port drive in device tree When calling the roll consistent, parsing direct memory access resource, application direct memory access channel resource simultaneously configure direct memory access Transmission mode.
Specifically, default with serial port drive when getting the direct memory access node name in device tree by traversing operation Direct memory access node name it is consistent when, the direct memory access resource information configured in serial port drive analyzing device book and Shen Please direct memory access channel resource, the pattern of configuration direct memory access transmission, wherein direct memory access resource information packet Include direct memory access controller, the transmission data mode of direct memory access first in first out, direct memory access transmission/reception The name title of channel number and these channel numbers.
Step S105:When direct memory access node name and the preset direct memory access section of serial port drive in device tree When calling the roll inconsistent, PIO transmission modes are configured.
Specifically, PIO patterns are a kind of to execute I/O port commands by CPU and carry out the data exchange of the read-write of data Pattern, PIO data-transmission modes are divided into as PIO mode 0, PIO mode 1, PIO mode 2, PIO mode 3, PIO 4 several modes of mode, message transmission rate are differed from 3.3MB/s to 16.6MB/s.
Step S106:Construct first annular buffering area memory and the second buffer circle memory.
Specifically, buffer circle is a kind of data structure, for indicating a fixed dimension, buffering from beginning to end Area is suitble to data cached stream.Direct memory access to first annular buffering area incoming data, when subsequently needing to read data just from First annular buffering area reads data;When subsequently needing to write data, data, the second loop buffer is written to the second buffer circle Area is to direct memory access channel outgoi8ng data.Therefore first annular buffering area and the second buffer circle are respectively intended to serve as reading Write the memory carrier of data.
Step S107:It creates device file descriptor and device file descriptor is monitored.
Specifically, it calls open functions to open serial equipment node, generates serial equipment filec descriptor, call epoll_ Create function interfaces are associated with serial equipment filec descriptor to create epoll objects, generate epoll filec descriptors epid. This is at the kernel spacing that epoll filec descriptors epid is application, the event occurred for storage equipment filec descriptor. Open functions, epoll_create functions, epoll_ctl functions, epoll_wait functions are linux system library functions, are The power function that linux system provides for developer.Developer can directly use namely this partial code is exploit person It is that member shares, increase income.
Step S108:Judge whether to listen to the dynamic of device file descriptor.
Step S109:When listening to the dynamic of device file descriptor, reading behaviour is carried out in first annular buffering area memory Make, write operation is carried out in the second buffer circle memory.
Specifically, it calls epoll_ctl function interfaces to establish the monitoring to serial equipment filec descriptor, calls epoll_ Wait function interfaces monitor serial equipment filec descriptor, and ready device file descriptor is checked whether within given time Read-write event has occurred, when first annular buffer data reaches, device file descriptor reads event, user's application call Read function interfaces read first annular buffer data;When the second buffer circle data are read, device file descriptor is write Event occurs, and user's application call write function interfaces write data to the second buffer circle.
Above-mentioned serial data reading/writing method avoids CPU and frequently responds interruption by direct memory access transmission module, Cpu resource is saved, realizes the quick transmission of data, data, an annular are stored, manage by constructing Crossed Circle buffering area Buffering area is used to store the incoming data of direct memory access, another buffer circle is therefrom spread out of for direct memory access Data, the data of storage user's application write-in, efficiently solve data buffering storage problem, serial ports are monitored by epoll mechanism Device data saves system resource overhead, improves data real-time tranception efficiency, is passed to further solve serial data It is defeated to there are problems that overflowing on a small quantity, lose, usurp the throne.
Fig. 2 is flow signal the step of configuring the direct memory access resource of serial equipment in device tree of an embodiment Figure.As shown in Fig. 2, in one embodiment, in configuration device tree the step of the direct memory access resource of serial equipment, packet It includes:
Step S201:Direct memory access controller and direct memory access transmission/reception are obtained according to chip data table Channel number.
Specifically, tables of data (datasheet) is the databook of electronic component, electronic chip, content be electronic component, Parameters, electrical parameter, physical parameter of electronic chip etc., content-form are generally comment, various characteristics curve, figure Table, tables of data etc..The channel of direct memory access controller and direct memory access can be got according to the tables of data of chip Number information.
Step S202:In system equipment tree file, the corresponding direct memory access controller of addition serial equipment, directly Internal storage access transmission/receiving channel number and direct memory access node name.
The direct memory access controller and direct memory access that previous step is acquired access transmission/receiving channel number It is added in serial equipment.
Direct memory access controller and channel number information, and given and string are got by access chip data table information The consistent node name of the retrieval name that is set in jaws equipment, and configure and got well direct memory access resource.
The flow for the step of Fig. 3 is the first annular buffering area memory of construction and the second buffer circle memory of an embodiment Schematic diagram.As shown in figure 3, in one embodiment, first annular buffering area memory and the second buffer circle memory are constructed Step includes:
Step S301:The structure of construction description buffer circle.
Specifically, by code constructs structure, member is respectively in structure:
1, the buffer pointers of one section of memory are directed toward, for storing data.
2, the length of memory buffer.
3, write pointer is directed toward buffer zone address writeable in buffer circle.
4, read pointer is directed toward data address readable in buffer circle.
5, mutual exclusion lock, for ensureing that only there are one thread accesses shared datas.
Step S302:Create the initialization interface function of buffer circle, buffer circle reads interface function and annular is slow It rushes area and writes interface function.Specifically, by the initialization interface function of code establishing buffer circle, application construction in code Buffer circle memory, and initialize the data in two pieces of memories.
Interface function is read by code establishing buffer circle, it is to read one from buffering buffer to read interface function function The first address of remaining data in the real-time record buffer buffer of read pointer is used in combination in the data of measured length.When the data of reading are long Degree is more than remaining data length in buffering buffer, then remaining data all are read, read pointer is directed toward buffering Buffer first address indicates that buffering buffer has read sky.
Interface function is write by code establishing buffer circle, it is to be written one into buffering buffer to write interface function function The data of measured length, write pointer are directed toward the first address of remaining memory space in buffering buffer in real time.As buffering buffer In the length of remaining memory space be less than the length of data is written, then the only length scale of write-in residual memory space Data, the first address of write pointer direction buffering buffer, it is full to indicate that buffering buffer has write at this time.
Step S303:Call the initialization interface function, buffer circle reading interface function and annular of buffer circle slow It rushes area and writes the first annular buffering area memory of interface function structure and the second buffer circle memory.
The step of by foregoing description structure and call function, is created that two buffer circle memories, is respectively intended to Read operation and write operation are carried out, the data being written in first annular buffering area are read, the number in the second buffer circle will be written Data are managed, the demand of the producer and consumer's pattern are met by Crossed Circle buffering area valid cache data according to outflow.
The stream for the step of Fig. 4 is the establishment device file descriptor of an embodiment and monitors device file descriptor Journey schematic diagram.As shown in figure 4, in one embodiment, creating device file descriptor and being supervised to device file descriptor The step of listening include:
Step S401:Serial equipment node is opened, serial equipment filec descriptor is generated.
Specifically, it calls open function interfaces to open serial equipment node, generates serial equipment filec descriptor.
Step S402:Association serial equipment filec descriptor simultaneously creates epoll objects, generates epoll filec descriptors.
Specifically, call epoll_create function interfaces association serial equipment filec descriptor to create epoll objects, Generate epoll filec descriptors epid.The epid is a kernel spacing of application, is occurred for storage equipment filec descriptor Event.
Step S403:Establish the monitoring to serial equipment filec descriptor.
Specifically, epoll_ctl function interfaces are called to establish the monitoring to serial equipment filec descriptor.
Fig. 5 is the first annular buffering area memory of progress of an embodiment and the read-write operation of the second buffer circle memory The flow diagram of step, as shown in fig. 6, in one embodiment, carrying out first annular buffering area memory and the second annular being slow The step of read-write operation for rushing area's memory includes:
Step S501:When first annular buffering area there are data to be passed to, the data of first annular buffering area are read.
Specifically, when first annular buffer data reaches, device file descriptor reads event, user's application call Read function interfaces read first annular buffer data.
Step S502:When data are written to the second buffer circle in user, data are spread out of from the second buffer circle.
Specifically, user's application call write function interfaces write data to the second buffer circle, device file description Symbol writes event, and DMA is by the data transmission in the second buffer circle to serial equipment.
By Crossed Circle buffering area mechanism, valid cache data manage data, and a buffer circle is used for read operation, One buffer circle is used for write operation, meets the demand of the producer and consumer's pattern.
Fig. 6 is the module diagram of the serial data read-write equipment of an embodiment.As shown in fig. 7, the present invention provides one kind Serial data read-write equipment, including:
Configuration device 10:Direct memory access resource for configuring serial equipment in device tree.
Comparison device 20:It traverses the direct memory access node name in direct memory access resource and is preset with serial port drive Direct memory access node name compared.
First configuration device 30:When direct memory access node name and the preset direct memory of serial port drive in device tree When accessed node name is consistent, parsing direct memory access resource, application direct memory access channel resource simultaneously configure direct memory The transmission mode of access.
Second configuration device 40:When direct memory access node name and the preset direct memory of serial port drive in device tree When accessed node name is inconsistent, PIO transmission modes are configured.
Constructing apparatus 50:Construct first annular buffering area memory and the second buffer circle memory.
Monitoring device 60:It creates device file descriptor and device file descriptor is monitored.
Read-write equipment 70:When listening to the dynamic of the device file descriptor, in the first annular buffering area Row read operation is deposited into, write operation is carried out in the second buffer circle memory.
Above-mentioned serial data read-write equipment avoids CPU and frequently responds interruption by direct memory access transmission module, Cpu resource is saved, realizes the quick transmission of data, data, an annular are stored, manage by constructing Crossed Circle buffering area Buffering area is used to store the incoming data of direct memory access, another buffer circle is therefrom spread out of for direct memory access Data, the data of storage user's application write-in, efficiently solve data buffering storage problem, serial ports are monitored by epoll mechanism Device data saves system resource overhead, improves data real-time tranception efficiency, is passed to further solve serial data It is defeated to there are problems that overflowing on a small quantity, lose, usurp the throne.
Fig. 7 is the module diagram of the first configuration device of an embodiment.As shown in fig. 7, in one embodiment, first Configuration device 30 includes:
Acquisition device 32:For obtaining direct memory access controller and direct memory access hair according to chip data table Send/receiving channel number.
Adding set 34:For in system equipment tree file, adding the corresponding direct memory access of serial equipment Controller, direct memory access transmission/receiving channel number and direct memory access node name.
Above-mentioned apparatus gets direct memory access controller and channel number information by access chip data table information, and The given node name consistent with the retrieval name set in serial equipment, and configure and got well direct memory access resource.
Fig. 8 is the module diagram of the constructing apparatus of an embodiment.As shown in figure 8, in one embodiment, constructing apparatus 50 include:
Structure constructing apparatus 52:Structure for constructing description buffer circle.
Function creation device 54:For creating the initialization interface function of buffer circle, buffer circle reads interface letter Number and buffer circle write interface function.
Function call device 56:For calling the initialization interface function of buffer circle, buffer circle to read interface letter Number and buffer circle write interface function and build first annular buffering area memory and the second buffer circle memory.
The step of above-mentioned apparatus is by foregoing description structure and call function is created that two buffer circle memories, It is respectively intended to carry out read operation and write operation, reads the data being written in first annular buffering area, the second loop buffer will be written Data outflow in area manages data, meets the producer and consumer's pattern by Crossed Circle buffering area valid cache data Demand.
Fig. 9 is the module diagram of the monitoring device of an embodiment.As shown in figure 9, in one embodiment, monitoring device 60 include:
Generating means 62:It is used to open serial equipment node, generates serial equipment filec descriptor.
Associated apparatus 64:For the serial equipment filec descriptor and epoll objects are created, epoll files is generated and retouches State symbol.
Establish device 66:For establishing the monitoring to serial equipment filec descriptor.
Figure 10 is the module diagram of the read-write equipment of an embodiment.As shown in Figure 10, in one embodiment, read-write dress Setting 70 includes:
Reading device 72:For when first annular buffering area has data to be passed to, reading the data of first annular buffering area.
Writing station 74:For when user writes data to the second buffer circle, by data from the second loop buffer Area is spread out of.
Above-mentioned apparatus manages data by Crossed Circle buffering area mechanism, valid cache data, and a buffer circle is used for Read operation, a buffer circle are used for write operation, meet the demand of the producer and consumer's pattern.
A kind of computer equipment, the computer equipment include memory, processor and storage on a memory and can locate The computer program run on reason device, wherein processor realizes such as above-mentioned serial data read-write side when executing computer program The step of method.
A kind of storage medium, is stored thereon with computer program, wherein is realized as above-mentioned when the program is executed by processor Serial data reading/writing method the step of.
Each technical characteristic of embodiment described above can be combined arbitrarily, to keep description succinct, not to above-mentioned reality It applies all possible combination of each technical characteristic in example to be all described, as long as however, the combination of these technical characteristics is not deposited In contradiction, it is all considered to be the range of this specification record.
Several embodiments of the invention above described embodiment only expresses, the description thereof is more specific and detailed, but simultaneously It cannot therefore be construed as limiting the scope of the patent.It should be pointed out that coming for those of ordinary skill in the art It says, without departing from the inventive concept of the premise, various modifications and improvements can be made, these belong to the protection of the present invention Range.Therefore, the protection domain of patent of the present invention should be determined by the appended claims.

Claims (10)

1. a kind of serial data reading/writing method, which is characterized in that including:
Configure the direct memory access resource of serial equipment in device tree;
Traverse the direct memory access node name in the direct memory access resource and with the preset direct memory of serial port drive Accessed node name is compared;
When the direct memory access node name in device tree is consistent with the preset direct memory access node name of the serial port drive When, parse the direct memory access resource, application direct memory access channel resource and the transmission for configuring direct memory access Pattern;
Construct first annular buffering area memory and the second buffer circle memory;
It creates device file descriptor and the device file descriptor is monitored;
When listening to the dynamic of the device file descriptor, read operation is carried out in the first annular buffering area memory, The second buffer circle memory carries out write operation.
2. serial data reading/writing method according to claim 1, which is characterized in that further include:
When the direct memory access node name in device tree differs with the preset direct memory access node name of the serial port drive When cause, PIO transmission modes are configured.
3. serial data reading/writing method according to claim 1, which is characterized in that serial equipment in the configuration device tree Direct memory access resource the step of, including:
Direct memory access controller and direct memory access transmission/receiving channel number are obtained according to chip data table;
In system equipment tree file, the corresponding direct memory access controller of addition serial equipment, the direct memory Access transmission/receiving channel number and direct memory access node name.
4. serial data reading/writing method according to claim 1, which is characterized in that in the first annular buffering area of construction The step of depositing with the second buffer circle memory, including:
The structure of construction description buffer circle;
Create the initialization interface function of buffer circle, buffer circle reads interface function and buffer circle writes interface letter Number;
The initialization interface function of the buffer circle, the buffer circle is called to read interface function and the loop buffer It writes interface function and builds first annular buffering area memory and the second buffer circle memory in area.
5. serial data reading/writing method according to claim 1, which is characterized in that the establishment device file descriptor is simultaneously The step of device file descriptor is monitored, including:
Serial equipment node is opened, serial equipment filec descriptor is generated;
It is associated with the serial equipment filec descriptor and creates epoll objects, generate epoll filec descriptors;
Establish the monitoring to serial equipment filec descriptor.
6. serial data reading/writing method according to claim 1, which is characterized in that described to carry out the first annular buffering The step of read-write operation of area's memory and the second buffer circle memory, including:
When the first annular buffering area there are data to be passed to, the data of the first annular buffering area are read;
When second buffer circle has data write-in, data are spread out of from the second buffer circle.
7. a kind of serial data read-write equipment, which is characterized in that including:
Configuration device:Direct memory access resource for configuring serial equipment in device tree;
Comparison device:Traverse the direct memory access node name in the direct memory access resource and preset with serial port drive Direct memory access node name is compared;
Apply for device:When direct memory access node name and the preset direct memory access section of the serial port drive in device tree When calling the roll consistent, parses the direct memory access resource, application direct memory access channel resource and configure direct memory visit The transmission mode asked;
Constructing apparatus:Construct first annular buffering area memory and the second buffer circle memory;
Monitoring device:It creates device file descriptor and the device file descriptor is monitored;
Read-write equipment:When listening to the dynamic of the device file descriptor, carried out in the first annular buffering area memory Read operation carries out write operation in the second buffer circle memory.
8. serial data read-write equipment according to claim 7, which is characterized in that the read-write equipment includes:
Reading device:For when the first annular buffering area has data to be passed to, reading the number of the first annular buffering area According to;
Writing station:For when second buffer circle has data write-in, data to be spread out of from the second buffer circle.
9. a kind of computer equipment, which includes memory, processor and storage on a memory and can handle The computer program run on device, wherein processor is realized when executing the computer program such as any one of claim 1 to 6 The step of described serial data reading/writing method.
10. a kind of storage medium, is stored thereon with computer program, wherein realize such as right when the program is executed by processor It is required that the step of 1 to 6 any one of them serial data reading/writing method.
CN201810063577.5A 2018-01-23 2018-01-23 Serial port data read-write method and device, computer equipment and storage medium Expired - Fee Related CN108470008B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810063577.5A CN108470008B (en) 2018-01-23 2018-01-23 Serial port data read-write method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810063577.5A CN108470008B (en) 2018-01-23 2018-01-23 Serial port data read-write method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN108470008A true CN108470008A (en) 2018-08-31
CN108470008B CN108470008B (en) 2020-08-14

Family

ID=63266051

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810063577.5A Expired - Fee Related CN108470008B (en) 2018-01-23 2018-01-23 Serial port data read-write method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN108470008B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110046114A (en) * 2019-03-06 2019-07-23 上海熠知电子科技有限公司 Dma controller and DMA data transfer method based on PCIE agreement
CN110083394A (en) * 2019-04-04 2019-08-02 龙芯中科技术有限公司 Serial port drive method, apparatus and storage medium
CN111831596A (en) * 2020-07-28 2020-10-27 山东有人信息技术有限公司 RTOS serial port network transmission method and device
CN113468081A (en) * 2021-07-01 2021-10-01 福建信息职业技术学院 Serial port converter device and method based on ebi bus
CN114756699A (en) * 2022-04-26 2022-07-15 湖南翰博薇微电子科技有限公司 Graphic data access processing method and device, computer equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20010039108A (en) * 1999-10-29 2001-05-15 윤종용 Method for canceling of printing job
CN1679008A (en) * 2002-06-27 2005-10-05 英特尔公司 Method and apparatus to transfer information
CN101165666A (en) * 2006-10-17 2008-04-23 国际商业机器公司 Method and device establishing address conversion in data processing system
CN101278263A (en) * 2005-10-08 2008-10-01 国际商业机器公司 Direct-memory access between input/output device and physical memory within virtual machine environment
CN102841871A (en) * 2012-08-10 2012-12-26 无锡众志和达存储技术股份有限公司 Pipeline read-write method of direct memory access (DMA) structure based on high-speed serial bus
CN106575206A (en) * 2014-09-26 2017-04-19 英特尔公司 Memory write management in a computer system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20010039108A (en) * 1999-10-29 2001-05-15 윤종용 Method for canceling of printing job
CN1679008A (en) * 2002-06-27 2005-10-05 英特尔公司 Method and apparatus to transfer information
CN101278263A (en) * 2005-10-08 2008-10-01 国际商业机器公司 Direct-memory access between input/output device and physical memory within virtual machine environment
CN101165666A (en) * 2006-10-17 2008-04-23 国际商业机器公司 Method and device establishing address conversion in data processing system
CN102841871A (en) * 2012-08-10 2012-12-26 无锡众志和达存储技术股份有限公司 Pipeline read-write method of direct memory access (DMA) structure based on high-speed serial bus
CN106575206A (en) * 2014-09-26 2017-04-19 英特尔公司 Memory write management in a computer system

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110046114A (en) * 2019-03-06 2019-07-23 上海熠知电子科技有限公司 Dma controller and DMA data transfer method based on PCIE agreement
CN110046114B (en) * 2019-03-06 2020-08-14 上海熠知电子科技有限公司 DMA controller based on PCIE protocol and DMA data transmission method
CN110083394A (en) * 2019-04-04 2019-08-02 龙芯中科技术有限公司 Serial port drive method, apparatus and storage medium
CN110083394B (en) * 2019-04-04 2022-04-22 龙芯中科技术股份有限公司 Serial port driving method, device and storage medium
CN111831596A (en) * 2020-07-28 2020-10-27 山东有人信息技术有限公司 RTOS serial port network transmission method and device
CN111831596B (en) * 2020-07-28 2022-01-21 山东有人物联网股份有限公司 RTOS serial port network transmission method and device
CN113468081A (en) * 2021-07-01 2021-10-01 福建信息职业技术学院 Serial port converter device and method based on ebi bus
CN113468081B (en) * 2021-07-01 2024-05-28 福建信息职业技术学院 Device and method for converting serial port into udp based on ebi bus
CN114756699A (en) * 2022-04-26 2022-07-15 湖南翰博薇微电子科技有限公司 Graphic data access processing method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN108470008B (en) 2020-08-14

Similar Documents

Publication Publication Date Title
CN108470008A (en) Serial data reading/writing method, device, computer equipment and storage medium
US9098462B1 (en) Communications via shared memory
US4128882A (en) Packet memory system with hierarchical structure
CN107395665A (en) A kind of block chain service handling and business common recognition method and device
CN104111870B (en) Interrupt processing device and method
CN109902255B (en) Page mixed browsing record generation method, device, equipment and storage medium
CN103455371B (en) The method and system of message communicating between for minor node in the tube core of optimization
CN107046508A (en) Message method of reseptance and the network equipment
CN115913937B (en) Container multi-network card network configuration method, device, equipment and storage medium
CN106919442A (en) Many GPU dispatching devices and distributed computing system and many GPU dispatching methods
CN112685148A (en) Asynchronous communication method and device of mass terminals, computer equipment and storage medium
CN104657328A (en) Method and system for sharing memory among mobile devices
CN111666559A (en) Data bus management method and device supporting authority management, electronic equipment and storage medium
CN115801569B (en) Access rule deployment method, device, equipment, medium and cloud platform
CN107209738A (en) Store direct memory access (DMA)
CN114969851B (en) FPGA-based data processing method, device, equipment and medium
CN111654547B (en) Data transmission method, device, equipment and storage medium
US8938588B2 (en) Ensuring forward progress of token-required cache operations in a shared cache
CN100492299C (en) Embedded software developing method and system
CN107085557A (en) Direct memory access system and associated method
CN109324982B (en) Data processing method and data processing device
US10482007B2 (en) Memory allocation on non-volatile storage
CN110427269A (en) Processor and its data transferring method, computer readable storage medium
US9251100B2 (en) Bitmap locking using a nodal lock
JP3191667B2 (en) Network management device

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
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20200814