Data receiving and sending method and device based on embedded serial port module

CN116257206BActive Publication Date: 2026-08-28SICHUAN JIUZHOU ELECTRIC GROUP CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310260862.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-17
Publication Date
2026-08-28
Estimated Expiration
2043-03-17

AI Technical Summary

Technical Problem

[0006]鉴于上述的分析,本发明实施例旨在提供一种基于嵌入式串口模块的数据收发方法及装置,用以解决现有技术中串口模块软硬件耦合性强以及难以监控数据收发过程的问题

Benefits of technology

[0034]1、本发明通过传输层的数据读取单元、环形缓冲区、数据解析单元、接收队列、ACK帧队列、发送队列和数据发送单元,并且数据发送和接收时采用接口回调和队列技术解耦了硬件层和应用层,提高了串口模块的移植性和可扩展性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116257206B_ABST
    Figure CN116257206B_ABST
Patent Text Reader

Abstract

The application relates to a data transceiving method and device based on an embedded serial port module and belongs to the technical field of serial port data transceiving. The method solves the problems that the software and hardware of a serial port module are strongly coupled and the data transceiving process is difficult to monitor in the prior art. The data transceiving method comprises the following steps: triggering a serial port ISR when external data is stored into a hardware FIFO buffer; reading all the external data and storing the data into a ring buffer in the serial port ISR; analyzing the external data stored in the ring buffer, storing the obtained received data frame into a receiving queue for use by a user end, and storing the obtained ACK information into an ACK frame queue for judging whether data is successfully sent; when ACK feedback is needed, storing the ACK frame and a data frame needed to be sent by the user end into a sending queue; and when the sending queue stores frame data, reading the frame data according to the sequence of the frame and writing the frame data into the hardware FIFO buffer for sending. The method realizes the decoupling of the software and hardware and the monitoring of the data transceiving process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of serial port data transceiver technology, and in particular to a data transceiver method and apparatus based on an embedded serial port module. Background Technology

[0002] A serial port, or Universal Asynchronous Receiver / Transmitter (UART), is a universal serial data bus and one of the most common data transmission methods for embedded devices to interact with the outside world. A serial port connects two devices through a pair of signal lines. The two devices communicate using an agreed-upon baud rate, achieving full-duplex data transmission and reception. Serial communication is typically conducted in units of binary frames.

[0003] With the deepening development of the Internet of Things and the widespread application of embedded multi-core technology, the frequency and amount of data interaction between embedded devices and the outside world are constantly increasing. The processing method of serial port data transmission and reception is directly related to the quality of device communication performance and is an extremely important part of embedded device data processing.

[0004] However, the data transmission and reception processing flow of the serial port module in the existing technology is unclear, the hardware and software are strongly coupled, the portability and scalability are poor, it is difficult to support multi-core concurrent processing, and it cannot support the self-test design of the module, making it difficult to monitor anomalies that occur during data transmission and reception.

[0005] Therefore, there is an urgent need for a technical solution for serial port modules in the process of sending and receiving data. Summary of the Invention

[0006] Based on the above analysis, the present invention aims to provide a data transmission and reception method and apparatus based on an embedded serial port module, in order to solve the problems of strong hardware and software coupling and difficulty in monitoring the data transmission and reception process in the prior art.

[0007] On one hand, embodiments of the present invention provide a data transmission and reception method based on an embedded serial port module, the data transmission and reception method comprising:

[0008] When external data is stored in the hardware FIFO buffer, the serial port interrupt service routine (ISR) is triggered. In the serial port ISR, all external data is read and stored in the circular buffer. The external data stored in the circular buffer is parsed to obtain the received data frame and ACK information. The received data frame is stored in the receive queue for use by the user terminal, and the ACK information is stored in the ACK frame queue to determine whether the data was sent successfully.

[0009] Based on the received data frames, determine whether an ACK transmission is needed. If an ACK transmission is needed, store the ACK frame and the data frames that the user needs to send into the transmission queue. When the transmission queue contains frame data, read the frame data in the order of the frames and write it into the hardware FIFO buffer for transmission.

[0010] A further improvement to the above method, the step of reading all external data and storing it in a circular buffer, includes:

[0011] Use the single-byte read interface callback loop to read every byte of all external data and store it in a circular buffer.

[0012] Based on a further improvement to the above method, the parsing of external data stored in the circular buffer includes:

[0013] By utilizing the task or soft interrupt mechanism supported by the embedded operating system EOS, byte data in the circular buffer is continuously read and parsed to identify the frame header, frame length, and frame tail until a complete frame is parsed.

[0014] Based on the above method, when it is determined that a back transmission is required according to the received data frame, an ACK frame is encapsulated and directly inserted into the sending queue with high priority.

[0015] Based on a further improvement of the above method, the data transmission and reception method further includes:

[0016] Within the preset verification time range, the ACK information in the ACK frame queue is queried to determine whether the data frame to be sent by the user has been successfully sent.

[0017] If transmission fails, a retransmission mechanism of a preset number of times is initiated or the data frame to be sent is retransmitted until it is verified that the data frame to be sent by the user has been successfully transmitted.

[0018] Based on a further improvement of the above method, the data transmission and reception method further includes:

[0019] In the serial port ISR, count the number of bytes read during each interrupt and the number of times the circular buffer is full;

[0020] The number of bytes read determines whether the hardware FIFO buffer has malfunctioned, and the fullness of the circular buffer determines whether the circular buffer has malfunctioned.

[0021] A further improvement to the above method, the step of reading frame data and writing it into a hardware FIFO buffer for transmission, includes:

[0022] The single-byte write interface callback loop reads the byte data of the frame data and writes it to the hardware FIFO buffer, while simultaneously initiating the transmission process.

[0023] Based on a further improvement of the above method, the data transmission and reception method further includes:

[0024] During data transmission and reception, statistics are collected on the fullness of the receive queue, the fullness of the ACK frame queue, the fullness of the send queue, and the fullness of the circular buffer.

[0025] Based on the conditions of the receive queue being full, the ACK frame queue being full, the transmit queue being full, and the circular buffer being full, the parameters of the receive queue, the ACK frame queue, the transmit queue, and the circular buffer are adjusted.

[0026] On the other hand, embodiments of the present invention provide a data transceiver device based on an embedded serial port module. The data transceiver device includes a data reading unit, a circular buffer, a data parsing unit, a receiving queue, an ACK frame queue, a sending queue, and a data sending unit located in the transmission layer, as well as a hardware FIFO buffer located in the hardware layer.

[0027] The data reading unit is used to read all external data from the hardware FIFO buffer in the serial port ISR and store it into the circular buffer;

[0028] The data parsing unit is used to parse the external data stored in the circular buffer to obtain the received data frames and ACK information. The received data frames are stored in the receive queue for use by the user terminal of the application layer, and the ACK information is stored in the ACK frame queue to determine whether the data has been successfully sent.

[0029] The send queue is used to store ACK frames and data frames that the application layer client needs to send;

[0030] The data transmission unit is used to read frame data in the order of frames and write it into the hardware FIFO buffer for transmission when the transmission queue contains frame data.

[0031] Based on further improvements to the above-mentioned device, the data transceiver device also includes an information statistics unit;

[0032] The information statistics unit is used to count the number of bytes read during each interrupt and the status of the full ring buffer, as well as to count the status of the full receive queue, the full ACK frame queue, the full send queue, and the full ring buffer.

[0033] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:

[0034] 1. This invention improves the portability and scalability of the serial port module by using a data reading unit, a circular buffer, a data parsing unit, a receiving queue, an ACK frame queue, a sending queue, and a data sending unit in the transmission layer, and by using interface callbacks and queue technology during data sending and receiving.

[0035] 2. This invention achieves data transmission and reception of the serial port module by reading all external data in the serial port ISR and storing it in a circular buffer; parsing the external data stored in the circular buffer to obtain the received data frames and ACK information; storing the received data frames in the receive queue for user terminal use, and storing the ACK information in the ACK frame queue to determine whether the data was successfully transmitted; when ACK return is required, storing the ACK frame and the data frame to be sent by the user terminal in the send queue; when the send queue contains frame data, reading the frame data in the order of the frames and writing it into the hardware FIFO buffer for transmission.

[0036] 3. This invention adjusts the parameters of relevant queues by statistically analyzing the fullness of the receive queue, ACK frame queue, send queue, and circular buffer during data transmission and reception, thereby achieving monitoring of the data transmission and reception process and reducing the cost of abnormal handling of the serial port module.

[0037] In this invention, the above-described technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of this invention will be set forth in the following description, and some advantages may become apparent from the description or be learned by practicing the invention. The objects and other advantages of this invention can be realized and obtained from the description and drawings, which are particularly pointed out. Attached Figure Description

[0038] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts.

[0039] Figure 1 This is a flowchart illustrating the data transmission and reception method based on an embedded serial port module provided in an embodiment of the present invention.

[0040] Figure 2 This is a schematic diagram of the structure of a data transceiver device based on an embedded serial port module provided in an embodiment of the present invention. Detailed Implementation

[0041] Preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which form part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not intended to limit the scope of the present invention.

[0042] A specific embodiment of the present invention discloses a data transmission and reception method based on an embedded serial port module, such as... Figure 1 As shown, the data transmission and reception method includes:

[0043] Step S1: When external data is stored in the hardware FIFO buffer, the serial port interrupt service routine (ISR) is triggered; in the serial port ISR, all external data is read and stored in the circular buffer; the external data stored in the circular buffer is parsed to obtain the received data frame and ACK information; the received data frame is stored in the receive queue for use by the user terminal, and the ACK information is stored in the ACK frame queue to determine whether the data has been successfully sent.

[0044] Step S2: Determine whether an ACK return is needed based on the received data frame. If an ACK return is needed, store the ACK frame and the data frame that the user needs to send into the transmission queue. When there is frame data stored in the transmission queue, read the frame data in the order of the frames and write it into the hardware FIFO buffer for transmission.

[0045] Specifically, the serial port module connects two embedded devices through a pair of signal lines. The two embedded devices communicate using an agreed baud rate to achieve full-duplex data communication.

[0046] Specifically, in step S1, this embodiment of the invention provides a process for a serial port module to receive data. For example... Figure 2 As shown, when external data arrives at the hardware FIFO (First Input First Output) buffer 210 in the hardware layer, the serial port ISR (Interrupt Service Routines) is triggered.

[0047] In the transport layer, after receiving the signal sent by the serial port ISR, the data reading unit 201 reads the external data stored in the hardware FIFO buffer 210.

[0048] Preferably, the step of reading all external data and storing it in a circular buffer includes:

[0049] Use the single-byte read interface callback loop to read every byte of all external data and store it in a circular buffer.

[0050] Specifically, the data reading unit 201 uses the single-byte read interface callback function to read each byte of external data in a loop until all the external data stored in the hardware FIFO buffer 210 has been read. During the reading process, each single byte read is stored in the circular buffer 202.

[0051] The single-byte read interface callback refers to reading a single byte of data and determining whether the reading was successful. It is understood that this invention uses a single-byte read interface callback to read data from the serial port hardware buffer, reading only one byte at a time. It returns failure when no byte is available to read and success when a byte is available to read.

[0052] The circular buffer 202 consists of a fixed-size byte array, a write index, a read index, a write loop count, and a read loop count.

[0053] Preferably, the data transmission and reception method further includes:

[0054] In the serial port ISR, count the number of bytes read during each interrupt and the number of times the circular buffer is full;

[0055] The number of bytes read determines whether the hardware FIFO buffer has malfunctioned, and the fullness of the circular buffer determines whether the circular buffer has malfunctioned.

[0056] Specifically, in the serial port ISR, by counting the number of bytes read in each interrupt and the fullness of the circular buffer 202, it is further determined whether the hardware FIFO buffer 202 has failed, and whether the circular buffer 202 has failed.

[0057] It is worth noting that the storage space size of the hardware FIFO buffer 202 is fixed. In each serial port ISR, if the number of bytes read exceeds the storage space size of the hardware FIFO buffer 202, it indicates that the hardware FIFO buffer 202 has malfunctioned.

[0058] It's worth noting that the circular buffer 202 has a start and an end point. When their indices are equal, it indicates that the circular buffer 202 is full. Under normal circumstances, since the storage space of the circular buffer 202 is larger than that of the hardware FIFO buffer 202, the circular buffer 202 should not become full. Therefore, when the circular buffer 202 is full, it indicates that the circular buffer 202 has malfunctioned.

[0059] Furthermore, it is worth noting that in order to calculate the time Trecv consumed by the data reading unit 201 to read all the external data in each serial port ISR, the time point T1 when the serial port ISR enters the interrupt and the time point T2 when the serial port ISR finishes execution can be recorded, and the time Trecv consumed by reading all the external data in this instance can be calculated.

[0060] Specifically, in step S1, after the serial port ISR is completed, it indicates that the data reading unit 201 has read all the external data stored in the hardware FIFO buffer 210 and stored it in the ring buffer 202. At this time, a semaphore is sent to the data parsing unit 203, and the data parsing unit 203 starts to work.

[0061] The data parsing unit 203 begins reading byte data from the circular buffer 202 and analyzing the byte data. The parsed data frame is stored in the receive queue 204 for use by the user terminal of the application layer. The user terminal can receive, process and further process the data frame. At the same time, the parsed acknowledgment character ACK information is stored in the ACK frame queue 205 to determine whether the data was sent successfully.

[0062] Preferably, parsing the external data stored in the circular buffer includes:

[0063] By utilizing the task or soft interrupt mechanism supported by the embedded operating system EOS, byte data in the circular buffer is continuously read and parsed to identify the frame header, frame length, and frame tail until a complete frame is parsed.

[0064] It is worth noting that, using the task or soft interrupt mechanism supported by EOS (Embedded Operating System), the data parsing unit 203 parses each byte of data read from the circular buffer 202 according to the preset frame format, and parses out the frame header, frame length and frame tail respectively. When a complete frame is parsed, it is stored in the receive queue 204 and the ACK frame queue 205 respectively.

[0065] Specifically, when the data parsing unit 203 parses the byte data stored in the circular buffer 202, parsing errors may occur. The number of parsing frame errors in the data parsing unit 203 during the parsing process is recorded to determine the anomaly.

[0066] Specifically, each complete frame parsed is stored in the receive queue 204 and the ACK frame queue 205. There may be a situation where the receive queue 204 is full or the ACK frame queue 205 is full. The situations where the receive queue 204 is full and the ACK frame queue 205 is full during the parsing process are counted.

[0067] It is worth noting that when the receive queue 204 is full or the ACK frame queue 205 is full, it means that the storage space of the receive queue 204 or the ACK frame queue 205 is relatively small. The corresponding parameters can be adjusted to make the receive queue 204 or the ACK frame queue 205 meet the storage requirements.

[0068] In addition, the time Tparse, which is consumed by the parsing unit 203 in parsing all the external data in the circular buffer 202, can be calculated.

[0069] Specifically, in step S2, this embodiment of the invention provides a process for a serial port module to send data, such as... Figure 2 As shown.

[0070] It is worth noting that the data that the serial port module can send includes, on the one hand, the data frames that the application layer user needs to send, and on the other hand, the ACK frames that need to be returned.

[0071] Specifically, after the received data frame is stored in the receive queue, it is determined whether an ACK transmission is needed based on the received data frame.

[0072] Preferably, when it is determined that a back transmission is required based on the received data frame, an ACK frame is encapsulated and directly inserted into the sending queue with high priority.

[0073] Specifically, when the user needs to send a data frame, the data frame is stored in the sending queue 206. At the same time, when an ACK is needed, when an ACK frame is created, the ACK frame is directly inserted into the sending queue 206 with high priority.

[0074] It is worth noting that during the process of storing data frames that the user needs to send or ACK frames that need to be returned into the sending queue 206, the fullness of the sending queue 206 is counted in order to make adaptive adjustments to the parameters of the sending queue 206.

[0075] Specifically, in step S2, when frame data is stored in the transmission queue 206, the frame data is read in the order of the frames and written into the hardware FIFO buffer for transmission.

[0076] Preferably, the step of reading frame data and writing it into a hardware FIFO buffer for transmission includes:

[0077] The single-byte write interface callback loop reads the byte data of the frame data and writes it to the hardware FIFO buffer, while simultaneously initiating the transmission process.

[0078] Specifically, the single-byte write interface callback refers to writing one byte of data at a time and determining whether it is writable. If there is remaining space to write, it returns success; if there is no remaining space to write, it returns failure.

[0079] Preferably, the data transmission and reception method further includes:

[0080] Within the preset verification time range, the ACK information in the ACK frame queue is queried to determine whether the data frame to be sent by the user has been successfully sent.

[0081] If transmission fails, a retransmission mechanism of a preset number of times is initiated or the data frame to be sent is retransmitted until it is verified that the data frame to be sent by the user has been successfully transmitted.

[0082] Specifically, when a data frame requires an ACK response, the ACK information in the ACK frame queue is queried within a preset verification time after the data frame is sent. If they do not match, the transmission fails; if they match, the transmission succeeds. Preferably, the preset verification time can be set to 100ms.

[0083] Specifically, when transmission fails, a retransmission mechanism can be initiated after a preset number of attempts, or the data frame can be retransmitted until it is verified that the transmitted data frame was successfully sent. Preferably, the preset number of attempts is 5.

[0084] It is worth noting that, through the process in step S1, the total time for receiving one frame of data in the serial port module data receiving process provided in this embodiment of the invention can be calculated; simultaneously, through the process in step S2, the CPU time Tcpu occupied by sending one frame of data can be calculated. It is understood that different frames have different lengths, ranging from a few bytes to thousands of bytes, with significant differences.

[0085] Therefore, to compare the performance of different serial port module data transmission and reception methods, a set of frames of different lengths can be designed for continuous reception and transmission processing, i.e., the number of bytes sent and received is the same (assumed to be N). Then, the total reception time Trecv(total), total parsing time Tparse(total), and total transmission CPU time = Tcpu(total) can be calculated. Under normal circumstances, since the serial communication rate is constant, the total reception time Trecv(total) and the total serial port transmission time for N bytes are the same. The efficiency of different methods mainly lies in the total parsing time Tparse(total) and the total transmission CPU time. Therefore, based on the average byte reception time = N / Tparse(total) and average byte CPU time = N / Tcpu(total) proposed in this invention, a quantitative comparison can be achieved between different serial port data transmission and reception methods.

[0086] Preferably, the ACK frame queue can be a queue, mailbox, or hash table mechanism. ACK information includes the frame message ID and the ACK / denial character NAK.

[0087] Another specific embodiment of the present invention discloses a data transceiver device based on an embedded serial port module, such as... Figure 2As shown, the data transceiver device includes a data reading unit 201, a circular buffer 202, a data parsing unit 203, a receiving queue 204, an ACK frame queue 205, a sending queue 206, and a data sending unit 207 located in the transport layer, as well as a hardware FIFO buffer 210 located in the hardware layer.

[0088] The data reading unit 201 is used to read all external data from the hardware FIFO buffer 210 in the serial port ISR and store it into the circular buffer 202.

[0089] The data parsing unit 203 is used to parse the external data stored in the circular buffer 202 to obtain the received data frame and ACK information, and to store the received data frame in the receive queue 204 for use by the user terminal 209 of the application layer, and to store the ACK information in the ACK frame queue 205 to determine whether the data was successfully sent.

[0090] Sending queue 206 is used to store ACK frames and data frames that the application layer user terminal needs to send;

[0091] The data transmission unit 207 is used to read frame data in the order of frames and write it into the hardware FIFO buffer 210 for transmission when the transmission queue 206 stores frame data.

[0092] Preferably, the data transceiver device further includes an information statistics unit 208;

[0093] The information statistics unit 208 is used to count the number of bytes read during each interrupt and the status of the full ring buffer, as well as to count the status of the full receive queue, the full ACK frame queue, the full send queue, and the full ring buffer.

[0094] Compared with existing technologies, the data transceiver method and apparatus based on an embedded serial port module provided in this embodiment decouples the hardware layer and application layer through a data reading unit, a circular buffer, a data parsing unit, a receiving queue, an ACK frame queue, a sending queue, and a data sending unit in the transport layer, as well as a hardware FIFO buffer in the hardware layer, thereby improving the portability and scalability of the serial port module. Simultaneously, by reading all external data from the serial port ISR and storing it in the circular buffer, parsing the external data stored in the circular buffer to obtain the received data frames and ACK information, and storing the received data frames in the receiving queue for user terminal use, the method and apparatus further decouple the hardware layer and application layer. ACK information is stored in the ACK frame queue to determine whether data transmission was successful. When ACK transmission is required, the ACK frame and the data frame to be sent by the user are stored in the transmission queue. When the transmission queue contains frame data, the frame data is read in the order of the frames and written into the hardware FIFO buffer for transmission, thus realizing the data transmission and reception of the serial port module. Furthermore, by statistically analyzing the full status of the receive queue, ACK frame queue, transmission queue, and circular buffer during the data transmission and reception process, the parameters of the relevant queues are adjusted, thereby realizing the monitoring of the data transmission and reception process and reducing the abnormal handling cost of the serial port module.

[0095] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware, and the program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.

[0096] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.

Claims

1. A data transmission and reception method based on an embedded serial port module, characterized in that, The data transmission and reception method includes: When external data is stored in the hardware FIFO buffer, the serial port interrupt service routine (ISR) is triggered. In the serial port ISR, each byte of all external data is read in a loop using the single-byte read interface callback and stored in the circular buffer. The time point when the serial port ISR enters the interrupt and the time point when it finishes execution are recorded, and the time consumed by reading all external data in this operation is calculated. The external data stored in the circular buffer is parsed to obtain the received data frames and ACK information, and the number of parsing errors during the parsing process is recorded. The received data frames are stored in the receive queue for use by the user terminal, and the ACK information is stored in the ACK frame queue to determine whether the data was sent successfully. Based on the received data frame, determine whether an ACK return is needed. When an ACK return is needed, store the ACK frame and the data frame that the user needs to send into the sending queue. When the sending queue contains frame data, read the byte data in the frame data in the order of the frames and write it into the hardware FIFO buffer using the single-byte write interface callback loop. At the same time, start the sending process and count the CPU time occupied by sending one frame of data. Within the preset verification time range, the ACK information in the ACK frame queue is queried to determine whether the data frame to be sent by the user has been successfully sent.

2. The data transmission and reception method according to claim 1, characterized in that, The parsing of external data stored in the circular buffer includes: By utilizing the task or soft interrupt mechanism supported by the embedded operating system EOS, byte data in the circular buffer is continuously read and parsed to identify the frame header, frame length, and frame tail until a complete frame is parsed.

3. The data transmission and reception method according to claim 1, characterized in that, When it is determined that a back transmission is needed based on the received data frame, an ACK frame is encapsulated and directly inserted into the sending queue with high priority.

4. The data transmission and reception method according to claim 1, characterized in that, The data transmission and reception method further includes: If transmission fails, a retransmission mechanism of a preset number of times is initiated or the data frame to be sent is retransmitted until it is verified that the data frame to be sent by the user has been successfully transmitted.

5. The data transmission and reception method according to claim 1, characterized in that, The data transmission and reception method further includes: In the serial port ISR, count the number of bytes read during each interrupt and the number of times the circular buffer is full; The number of bytes read determines whether the hardware FIFO buffer has malfunctioned, and the fullness of the circular buffer determines whether the circular buffer has malfunctioned.

6. The data transmission and reception method according to any one of claims 1-5, characterized in that, The data transmission and reception method further includes: During data transmission and reception, statistics are collected on the fullness of the receive queue, the fullness of the ACK frame queue, the fullness of the send queue, and the fullness of the circular buffer. Based on the conditions of the receive queue being full, the ACK frame queue being full, the transmit queue being full, and the circular buffer being full, the parameters of the receive queue, the ACK frame queue, the transmit queue, and the circular buffer are adjusted.

7. A data transceiver device based on an embedded serial port module, characterized in that, The data transceiver device includes a data reading unit, a circular buffer, a data parsing unit, a receiving queue, an ACK frame queue, a sending queue, and a data sending unit located at the transport layer, as well as a hardware FIFO buffer located at the hardware layer. The data reading unit is used in the serial port ISR to read every byte of all external data in a loop using the single-byte read interface callback and store it into a circular buffer. It is also used to record the time when the serial port ISR enters the interrupt and the time when it finishes execution, and to calculate the time consumed in reading all external data this time; The data parsing unit is used to parse the external data stored in the circular buffer to obtain the received data frames and ACK information, record the number of parsing frame errors during the parsing process, store the received data frames in the receive queue for use by the user terminal of the application layer, and store the ACK information in the ACK frame queue to determine whether the data was sent successfully. The send queue is used to store ACK frames and data frames that the application layer client needs to send; The data sending unit is used to read the byte data in the frame data in the order of the frames and write it into the hardware FIFO buffer in a loop according to the single-byte write interface callback when the frame data is stored in the sending queue. At the same time, it starts the sending process and counts the CPU time occupied by sending one frame of data. It is also used to query the ACK information in the ACK frame queue within the preset verification time range to determine whether the data frame to be sent by the user terminal has been successfully sent.

8. The data transceiver device according to claim 7, characterized in that, The data transceiver device also includes an information statistics unit; The information statistics unit is used to count the number of bytes read during each interrupt and the status of the full ring buffer, as well as to count the status of the full receive queue, the full ACK frame queue, the full send queue, and the full ring buffer.

Citation Information

Patent Citations

  • Serial port communication method based on head and tail circular queue

    CN106095716A