CN115314155B - Communication method, device, equipment and readable storage medium - Google Patents

Communication method, device, equipment and readable storage medium Download PDF

Info

Publication number
CN115314155B
CN115314155B CN202210834469.XA CN202210834469A CN115314155B CN 115314155 B CN115314155 B CN 115314155B CN 202210834469 A CN202210834469 A CN 202210834469A CN 115314155 B CN115314155 B CN 115314155B
Authority
CN
China
Prior art keywords
frame
data
processed
data frame
type
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210834469.XA
Other languages
Chinese (zh)
Other versions
CN115314155A (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.)
Dongfeng Electric Drive Systems Co Ltd
Original Assignee
Dongfeng Electric Drive Systems 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 Dongfeng Electric Drive Systems Co Ltd filed Critical Dongfeng Electric Drive Systems Co Ltd
Priority to CN202210834469.XA priority Critical patent/CN115314155B/en
Publication of CN115314155A publication Critical patent/CN115314155A/en
Application granted granted Critical
Publication of CN115314155B publication Critical patent/CN115314155B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/0001Systems modifying transmission characteristics according to link quality, e.g. power backoff
    • H04L1/0033Systems modifying transmission characteristics according to link quality, e.g. power backoff arrangements specific to the transmitter
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/0001Systems modifying transmission characteristics according to link quality, e.g. power backoff
    • H04L1/0036Systems modifying transmission characteristics according to link quality, e.g. power backoff arrangements specific to the receiver
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/004Arrangements for detecting or preventing errors in the information received by using forward error control
    • H04L1/0056Systems characterized by the type of code used
    • H04L1/0061Error detection codes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/0078Avoidance of errors by organising the transmitted data in a format specifically designed to deal with errors, e.g. location
    • H04L1/0083Formatting with frames or packets; Protocol or part of protocol for error control
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/90Buffering arrangements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Quality & Reliability (AREA)
  • Computer Security & Cryptography (AREA)
  • Communication Control (AREA)

Abstract

The invention provides a communication method, a device, equipment and a readable storage medium, wherein the communication method comprises the following steps: at a transmitting end, encapsulating a frame header, data to be transmitted and a check code to obtain a data frame to be transmitted; the sending end sends the data frame to be sent to the receiving end; the receiving end receives data from the sending end; the receiving end determines a data frame to be processed from the received data by searching for a frame header identifier, and checks whether the data frame to be processed is complete or not according to the data length and the check code of the data frame to be processed; analyzing the data frame to be processed; and if the frame type of the analyzed data frame to be processed is the request frame, encapsulating the frame header, the response information, the response data and the check code to obtain a response data frame, and sending the response data frame to a sending end by a receiving end. Through the invention, the high-efficiency and stable communication between the microcontroller and the microprocessor is realized through the good frame head structural design, the response information design and the perfect checksum communication mechanism.

Description

Communication method, device, equipment and readable storage medium
Technical Field
The present invention relates to the field of communications, and in particular, to a communication method, apparatus, device, and readable storage medium.
Background
The full liquid crystal automobile instrument generally comprises a Microprocessor (MPU) and a Microcontroller (MCU), wherein the MPU is mainly responsible for displaying a graphical interface, the MCU is mainly responsible for collecting and processing vehicle data, and the MPU and the MCU are in communication through a CAN bus interconnection, however, along with the improvement of intelligent requirements of an intelligent network-connected automobile, the requirements of increasing communication quantity and low time delay are higher and higher, and the existing communication technology cannot meet the high-efficiency and stable communication requirements between the MPU and the MCU.
Disclosure of Invention
The invention mainly aims to provide a communication method, a device, equipment and a readable storage medium, and aims to solve the technical problem that the existing communication technology cannot meet the high-efficiency and stable communication requirements between an MPU and an MCU.
In a first aspect, the present invention provides a communication method, the communication method comprising:
at a transmitting end, encapsulating a frame header, data to be transmitted and a check code to obtain a data frame to be transmitted, wherein the frame header comprises a frame header identifier, a data length, a frame count, a frame type and a frame ID, and the frame type comprises a request frame and a response frame;
the sending end sends the data frame to be sent to the receiving end, wherein when the sending end is a microcontroller, the receiving end is a microprocessor, and when the sending end is a microprocessor, the receiving end is a microcontroller;
the receiving end receives data from the sending end;
the receiving end determines a data frame to be processed from the received data by searching for a frame header identifier, and checks whether the data frame to be processed is complete or not according to the data length and the check code of the data frame to be processed;
if the frame of the data to be processed is complete, analyzing the frame of the data to be processed according to the frame type, the frame count and the frame ID;
and if the frame type of the analyzed data frame to be processed is the request frame, encapsulating the frame header, the response information, the response data and the check code to obtain a response data frame, and sending the response data frame to the sending end by the receiving end, wherein the response information comprises the frame count of the frame to be processed, the frame ID of the frame to be processed and the received correct request frame.
Optionally, the sending the data frame to be sent to the receiving end by the sending end includes:
at a transmitting end, acquiring configuration parameters, wherein the configuration parameters comprise a frame ID, a transmission type, a preset transmission period and a corresponding relation of an enabling state, and the transmission type comprises a period type and an event type;
determining the transmission type, the preset transmission period and the enabling state of the data frame to be transmitted according to the frame ID of the data frame to be transmitted;
if the transmission type of the data frame to be transmitted is periodic, writing the data frame to be transmitted into a buffer area according to a preset transmission period;
if the sending type of the data frame to be sent is event type, writing the data frame to be sent into a buffer area when the data frame to be sent is in an enabling state;
and reading the data frames to be transmitted from the buffer area according to the first-in first-out sequence, and transmitting the data frames to be transmitted to the receiving end.
Optionally, the determining, by the receiving end, the frame to be processed from the received data by searching the frame header identifier includes:
the receiving end determines a data frame to be processed from the received data by searching a frame header identifier according to a preset analysis period, wherein the preset analysis period is smaller than a preset sending period.
Optionally, the parsing the data frame to be processed according to the frame type, the frame count and the frame ID includes:
if the frame type of the data frame to be processed is a request frame, judging whether the frame ID in the data frame to be processed is in a preset range, if not, sending an error information code to an application layer, and if so, informing the application layer of receiving the correct data frame to be processed;
if the frame type of the data frame to be processed is a response frame, judging whether the frame ID in the data frame to be processed is correct, if not, transmitting an error information code to an application layer, if so, judging whether the frame count and the frame ID in response information in the data frame to be processed are the same as the frame count and the frame ID of the data frame when requested, if not, transmitting the error information code to the application layer, and if so, notifying the application layer of receiving the correct data frame to be processed.
Optionally, if the frame type of the parsed data frame to be processed is a request frame, encapsulating a frame header, response information, response data and a check code to obtain a response data frame, and sending the response data frame to a sending end by a receiving end, where the response information includes a frame count of the frame to be processed, a frame ID of the frame to be processed and a correct request frame received, and then includes:
if the sending type of the data frame to be sent is periodic, if the sending end does not receive the response data frame of the receiving end or the number of times that the received response data frame is in error exceeds the preset number of times, sending an error information code to the application layer;
if the sending type of the data frame to be sent is event type, if the sending end does not receive the response data frame of the receiving end after exceeding the preset time, the sending end resends, and when the resending times exceeds the preset times, the sending end sends error information codes to the application layer.
In a second aspect, the present invention also provides a communication device, including:
the packaging module is used for packaging a frame header, data to be transmitted and a check code at a transmitting end to obtain a data frame to be transmitted, wherein the frame header comprises a frame header identifier, a data length, a frame count, a frame type and a frame ID, and the frame type comprises a request frame and a response frame;
the sending module is used for sending the data frame to be sent to the receiving end by the sending end, wherein when the sending end is a microcontroller, the receiving end is a microprocessor, and when the sending end is a microprocessor, the receiving end is a microcontroller;
the receiving module is used for receiving the data from the transmitting end;
the verification module is used for determining a data frame to be processed from received data by the receiving end through searching a frame header identifier, and verifying whether the data frame to be processed is complete or not according to the data length of the data frame to be processed and a verification code;
the analysis module is used for analyzing the data frame to be processed according to the frame type, the frame count and the frame ID if the data frame to be processed is complete;
and the response module is used for encapsulating the frame header, response information, response data and check codes to obtain a response data frame if the frame type of the analyzed data frame to be processed is a request frame, and the receiving end sends the response data frame to the sending end, wherein the response information comprises the frame count of the frame to be processed, the frame ID of the frame to be processed and the received correct request frame.
Optionally, the sending module is configured to:
at a transmitting end, acquiring configuration parameters, wherein the configuration parameters comprise a frame ID, a transmission type, a preset transmission period and a corresponding relation of an enabling state, and the transmission type comprises a period type and an event type;
determining the transmission type, the preset transmission period and the enabling state of the data frame to be transmitted according to the frame ID of the data frame to be transmitted;
if the transmission type of the data frame to be transmitted is periodic, writing the data frame to be transmitted into a buffer area according to a preset transmission period;
if the sending type of the data frame to be sent is event type, writing the data frame to be sent into a buffer area when the data frame to be sent is in an enabling state;
and reading the data frames to be transmitted from the buffer area according to the first-in first-out sequence, and transmitting the data frames to be transmitted to the receiving end.
Optionally, the parsing module is configured to:
if the frame type of the data frame to be processed is a request frame, judging whether the frame ID in the data frame to be processed is in a preset range, if not, sending an error information code to an application layer, and if so, informing the application layer of receiving the correct data frame to be processed;
if the frame type of the data frame to be processed is a response frame, judging whether the frame ID in the data frame to be processed is correct, if not, transmitting an error information code to an application layer, if so, judging whether the frame count and the frame ID in response information in the data frame to be processed are the same as the frame count and the frame ID of the data frame when requested, if not, transmitting the error information code to the application layer, and if so, notifying the application layer of receiving the correct data frame to be processed.
In a third aspect, the present invention also provides a communication device, where the communication device includes a processor, a memory, and a communication program stored on the memory and executable by the processor, where the communication program, when executed by the processor, implements the steps of the communication method as described above.
In a fourth aspect, the present invention further provides a readable storage medium having a communication program stored thereon, wherein the communication program, when executed by a processor, implements the steps of the communication method as described above.
In the invention, at a transmitting end, a frame header, data to be transmitted and a check code are encapsulated to obtain a data frame to be transmitted, wherein the frame header comprises a frame header identifier, a data length, a frame count, a frame type and a frame ID, and the frame type comprises a request frame and a response frame; the sending end sends the data frame to be sent to the receiving end, wherein when the sending end is a microcontroller, the receiving end is a microprocessor, and when the sending end is a microprocessor, the receiving end is a microcontroller; the receiving end receives data from the sending end; the receiving end determines a data frame to be processed from the received data by searching for a frame header identifier, and checks whether the data frame to be processed is complete or not according to the data length and the check code of the data frame to be processed; if the frame of the data to be processed is complete, analyzing the frame of the data to be processed according to the frame type, the frame count and the frame ID; and if the frame type of the analyzed data frame to be processed is the request frame, encapsulating the frame header, the response information, the response data and the check code to obtain a response data frame, and sending the response data frame to the sending end by the receiving end, wherein the response information comprises the frame count of the frame to be processed, the frame ID of the frame to be processed and the received correct request frame. The invention obtains the data frame to be transmitted by encapsulating the frame header, the data to be transmitted and the check code at the transmitting end, the transmitting end transmits the data frame to be transmitted to the receiving end, the receiving end searches the frame header identification to determine the data frame to be processed according to the preset analysis period, then analyzes the data frame to be processed according to the frame type, the frame count and the frame ID, encapsulates the frame header, the response information, the response data and the check code if the analyzed frame type of the data frame to be processed is the request frame, and obtains the response data frame, and the receiving end transmits the response data frame to the transmitting end, thereby realizing the peer-to-peer communication between the microcontroller and the microprocessor.
Drawings
FIG. 1 is a schematic diagram of a hardware configuration of a communication device according to an embodiment of the present invention;
FIG. 2 is a flow chart of an embodiment of the communication method of the present invention;
FIG. 3 is a schematic diagram of the refinement procedure of step S20 in FIG. 2;
FIG. 4 is a schematic diagram of a refinement flow chart of step S50 in FIG. 2;
fig. 5 is a schematic functional block diagram of an embodiment of the communication device of the present invention.
The achievement of the objects, functional features and advantages of the present invention will be further described with reference to the accompanying drawings, in conjunction with the embodiments.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
In a first aspect, an embodiment of the present invention provides a communication device.
Referring to fig. 1, fig. 1 is a schematic hardware structure of an embodiment of a communication device according to the present invention. In an embodiment of the present invention, the communication device may include a processor 1001 (e.g., a central processing unit Central Processing Unit, a CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein the communication bus 1002 is used to enable connected communications between these components; the user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard); the network interface 1004 may optionally include a standard wired interface, a WIreless interface (e.g., WIreless-FIdelity, WI-FI interface); the memory 1005 may be a high-speed random access memory (random access memory, RAM) or a stable memory (non-volatile memory), such as a disk memory, and the memory 1005 may alternatively be a storage device independent of the processor 1001. Those skilled in the art will appreciate that the hardware configuration shown in fig. 1 is not limiting of the invention and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components.
With continued reference to fig. 1, an operating system, a network communication module, a user interface module, and a communication program may be included in the memory 1005, which is one type of computer storage medium in fig. 1. The processor 1001 may call a communication program stored in the memory 1005, and execute the communication method provided in the embodiment of the present invention.
In a second aspect, an embodiment of the present invention provides a communication method.
In order to more clearly show the communication method provided by the embodiment of the present application, first, an application scenario of the communication method provided by the embodiment of the present application is introduced.
The communication method provided by the embodiment of the application is applied to the increase of the communication quantity and the requirement of low time delay are higher and higher along with the improvement of the intelligent requirement of the intelligent network-connected automobile, and high-efficiency and stable communication between the microcontroller and the microprocessor is required to be ensured.
In an embodiment, referring to fig. 2, fig. 2 is a flow chart of an embodiment of a communication method according to the present invention, as shown in fig. 2, the communication method includes:
step S10, at a transmitting end, encapsulating a frame header, data to be transmitted and a check code to obtain a data frame to be transmitted, wherein the frame header comprises a frame header identification, a data length, a frame count, a frame type and a frame ID, and the frame type comprises a request frame and a response frame.
In this embodiment, at the transmitting end, the frame header, the data to be transmitted and the check code are encapsulated into the data frame to be transmitted, the frame header is structured by a frame header identifier, a data length, a frame count, a frame type and a frame ID, where the frame header identifier is a special fixed character, identifies the start of a frame of data, the data length is the length of a data portion carried by the data frame, the frame count is a self-up counter, and is used to ensure continuity of communication, the frame type is divided into two types, i.e., a request frame and a response frame, the frame ID is used to identify the function of the data frame, the frame ID of the request frame has a predetermined range, and the frame ID of the response frame is a fixed value.
And step S20, the sending end sends the data frame to be sent to the receiving end, wherein when the sending end is a micro controller, the receiving end is a micro controller, and when the sending end is a micro controller, the receiving end is a micro controller.
In this embodiment, the sending end and the receiving end, that is, the microcontroller and the microprocessor, are in peer-to-peer communication relationship, and can both send and receive data frames.
In step S30, the receiving end receives the data from the transmitting end.
In this embodiment, the microcontroller and microprocessor receive the transmitted data from each other.
Step S40, the receiving end determines the data frame to be processed from the received data by searching the frame header identification, and checks whether the data frame to be processed is complete or not according to the data length and the check code of the data frame to be processed.
In this embodiment, the received data may be analyzed by periodically calling an analysis function, and the frame header identifier is usually a fixed value, for example, may be set to "0xA5", which identifies the start position of the frame header, and therefore, the frame header content may be determined, and whether the frame is complete or not may be obtained by checking the frame to be processed by using the data length in the frame header and the CRC check code, where CRC (Cyclic Redundancy Checksum, i.e., cyclic redundancy check) is a channel coding technique for generating a short fixed bit check code according to data such as a network data packet or a computer file, and is mainly used to detect or check errors that may occur after data transmission or storage, and error detection is performed by using the principles of division and remainder.
Step S50, if the frame of the data to be processed is complete, analyzing the frame of the data to be processed according to the frame type, the frame count and the frame ID.
In this embodiment, on the basis of the integrity of the data frame to be processed, the data frame to be processed is parsed according to the frame type, the frame count and the frame ID, and if the data frame to be processed is not complete, the data frame to be processed is parsed without meaning.
Step S60, if the frame type of the analyzed data frame to be processed is the request frame, packaging a frame header, response information, response data and a check code to obtain a response data frame, and sending the response data frame to a sending end by a receiving end, wherein the response information comprises the frame count of the frame to be processed, the frame ID of the frame to be processed and the received correct request frame.
In this embodiment, for the case that the received data frame is a request frame, the receiving end must give a response, where the structure of the response data frame includes a frame header, response information, response data and a check code, where the response information is a frame count of the frame to be processed, a frame ID of the frame to be processed, and a received correct request frame, that is, the receiving end sends the response data frame to tell the sending end that "i received the correct request data frame you sent", and the frame count of the frame to be processed and the frame ID of the frame to be processed in the response information are used by the sending end to check the response data frame after receiving the response data frame.
In this embodiment, through a good frame header structure design, the integrity of the data frame is ensured through the data length and the check code in the frame header, and through analyzing the frame type, the frame count and the frame ID, the response is performed based on the requested data frame, and through the design of the frame count and the frame ID of the response information in the response data frame, the efficient and stable communication between the microcontroller and the microprocessor is realized.
Further, referring to fig. 3, fig. 3 is a schematic diagram of a refinement flow of step S20 in fig. 2, and as shown in fig. 3, step S20 includes:
step S201, at a transmitting end, acquiring configuration parameters, wherein the configuration parameters comprise a frame ID, a transmission type, a preset transmission period and a corresponding relation of an enabling state, and the transmission type comprises a period type and an event type;
step S202, determining the transmission type, the preset transmission period and the enabling state of the data frame to be transmitted according to the frame ID of the data frame to be transmitted;
step S203, if the transmission type of the data frame to be transmitted is periodic, writing the data frame to be transmitted into the buffer area according to a preset transmission period;
step S204, if the transmission type of the data frame to be transmitted is event type, writing the data frame to be transmitted into the buffer area when the data frame to be transmitted is in an enabling state;
in step S205, the data frames to be sent are read from the buffer according to the first-in first-out order, and the data frames to be sent are sent to the receiving end.
In this embodiment, the configuration parameters may be stored in a configuration file, so that flexible adjustment and modification are convenient, and the buffer area is set to function as if the data submitted to the transmission layer by the application layer is too much and the transmission layer cannot be completely sent out in a short time, at this time, the data submitted by the application layer needs to be buffered first and then gradually sent.
Further, in an embodiment, step S40 includes:
the receiving end determines a data frame to be processed from the received data by searching a frame header identifier according to a preset analysis period, wherein the preset analysis period is smaller than a preset sending period.
In this embodiment, the sending end and the receiving end may set the preset parsing period to be smaller than the preset sending period according to the function of the frame ID of the sent and received data frame by pre-agreed before communication, so that the receiving end can process the data frame in time.
Further, referring to fig. 4, fig. 4 is a detailed flowchart of step S50 in fig. 2, and as shown in fig. 4, step S50 includes:
step S501, if the frame type of the data frame to be processed is the request frame, judging whether the frame ID in the data frame to be processed is within the preset range, if not, transmitting an error information code to the application layer, and if so, notifying the application layer of receiving the correct data frame to be processed;
step S502, if the frame type of the data frame to be processed is the response frame, judging whether the frame ID in the data frame to be processed is correct, if not, transmitting an error information code to the application layer, if so, judging whether the frame count and the frame ID in the response information in the data frame to be processed are the same as the frame count and the frame ID of the data frame when requested, if not, transmitting the error information code to the application layer, and if so, notifying the application layer of receiving the correct data frame to be processed.
In this embodiment, the frame ID of the request frame has a predetermined range, if the frame ID is not within the predetermined range, it indicates that the request frame is in error, and a corresponding error information code is reported to the application layer, and if the frame ID is within the predetermined range, it indicates that the request frame is received correctly, and the application layer is notified. The frame ID of the response frame is a fixed value, whether the response frame is correct or not is judged, if so, further judgment is made whether the frame count and the frame ID of the response information part in the response frame are the same as the frame count and the frame ID of the data frame when the response frame is requested, namely, whether the response frame is a corresponding request frame is judged.
Further, in an embodiment, after step S60, the method includes:
if the sending type of the data frame to be sent is periodic, if the sending end does not receive the response data frame of the receiving end or the number of times that the received response data frame is in error exceeds the preset number of times, sending an error information code to the application layer;
if the sending type of the data frame to be sent is event type, if the sending end does not receive the response data frame of the receiving end after exceeding the preset time, the sending end resends, and when the resending times exceeds the preset times, the sending end sends error information codes to the application layer.
In this embodiment, a response must be given to the request frame when the request frame is received, so as to ensure the stability of communication, and a fixed transmission period is sent periodically, if no corresponding response frame is received or the number of errors in the received response frame exceeds a preset number of times, for example, 3 times, the application layer is notified of an error, the event type transmission is performed, when the corresponding response frame is not received for a period exceeding a preset period, the application layer is notified of an error when the corresponding response frame is not received for more than 3 times, and when the corresponding response frame is not received for more than 3 times, the application layer is notified of an error.
In a third aspect, an embodiment of the present invention further provides a communication device.
Referring to fig. 5, fig. 5 is a schematic diagram of functional modules of an embodiment of a communication device according to the present invention.
In this embodiment, the communication device includes:
the encapsulating module 10 is configured to encapsulate, at a transmitting end, a frame header, data to be transmitted, and a check code, to obtain a data frame to be transmitted, where the frame header includes a frame header identifier, a data length, a frame count, a frame type, and a frame ID, and the frame type includes a request frame and a response frame;
the sending module 20 is configured to send the data frame to be sent to a receiving end by using a sending end, where when the sending end is a microcontroller, the receiving end is a microprocessor, and when the sending end is a microprocessor, the receiving end is a microcontroller;
a receiving module 30, configured to receive data from a transmitting end;
the verification module 40 is configured to determine, by the receiving end, a frame to be processed from the received data by searching for a frame header identifier, and verify whether the frame to be processed is complete according to a data length and a check code of the frame to be processed;
the parsing module 50 is configured to parse the data frame to be processed according to the frame type, the frame count and the frame ID if the data frame to be processed is complete;
and the response module 60 is configured to encapsulate the frame header, the response information, the response data and the check code if the parsed frame type of the to-be-processed data frame is the request frame, so as to obtain a response data frame, and the receiving end sends the response data frame to the sending end, where the response information includes a frame count of the to-be-processed frame, a frame ID of the to-be-processed frame and a received correct request frame.
Further, in an embodiment, the sending module 20 is configured to:
at a transmitting end, acquiring configuration parameters, wherein the configuration parameters comprise a frame ID, a transmission type, a preset transmission period and a corresponding relation of an enabling state, and the transmission type comprises a period type and an event type;
determining the transmission type, the preset transmission period and the enabling state of the data frame to be transmitted according to the frame ID of the data frame to be transmitted;
if the transmission type of the data frame to be transmitted is periodic, writing the data frame to be transmitted into a buffer area according to a preset transmission period;
if the sending type of the data frame to be sent is event type, writing the data frame to be sent into a buffer area when the data frame to be sent is in an enabling state;
and reading the data frames to be transmitted from the buffer area according to the first-in first-out sequence, and transmitting the data frames to be transmitted to the receiving end.
Further, in an embodiment, the verification module 40 is configured to:
the receiving end determines a data frame to be processed from the received data by searching a frame header identifier according to a preset analysis period, wherein the preset analysis period is smaller than a preset sending period.
Further, in an embodiment, the parsing module 50 is configured to:
if the frame type of the data frame to be processed is a request frame, judging whether the frame ID in the data frame to be processed is in a preset range, if not, sending an error information code to an application layer, and if so, informing the application layer of receiving the correct data frame to be processed;
if the frame type of the data frame to be processed is a response frame, judging whether the frame ID in the data frame to be processed is correct, if not, transmitting an error information code to an application layer, if so, judging whether the frame count and the frame ID in response information in the data frame to be processed are the same as the frame count and the frame ID of the data frame when requested, if not, transmitting the error information code to the application layer, and if so, notifying the application layer of receiving the correct data frame to be processed.
Further, in an embodiment, the communication device further includes a timeout module configured to:
if the sending type of the data frame to be sent is periodic, if the sending end does not receive the response data frame of the receiving end or the number of times that the received response data frame is in error exceeds the preset number of times, sending an error information code to the application layer;
if the sending type of the data frame to be sent is event type, if the sending end does not receive the response data frame of the receiving end after exceeding the preset time, the sending end resends, and when the resending times exceeds the preset times, the sending end sends error information codes to the application layer.
The function implementation of each module in the communication device corresponds to each step in the communication method embodiment, and the function and implementation process of each module are not described herein.
In a fourth aspect, embodiments of the present invention also provide a readable storage medium.
The readable storage medium of the present invention stores a communication program, wherein the communication program, when executed by a processor, implements the steps of the communication method as described above.
The method implemented when the communication program is executed may refer to various embodiments of the communication method of the present invention, and will not be described herein.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) as described above, comprising several instructions for causing a terminal device to perform the method according to the embodiments of the present invention.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the invention, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.

Claims (8)

1. A method of communication, the method comprising:
at a transmitting end, encapsulating a frame header, data to be transmitted and a check code to obtain a data frame to be transmitted, wherein the frame header comprises a frame header identifier, a data length, a frame count, a frame type and a frame ID, and the frame type comprises a request frame and a response frame;
the sending end sends the data frame to be sent to the receiving end, wherein when the sending end is a microcontroller, the receiving end is a microprocessor, and when the sending end is a microprocessor, the receiving end is a microcontroller;
the receiving end receives data from the sending end;
the receiving end determines a data frame to be processed from the received data by searching for a frame header identifier, and checks whether the data frame to be processed is complete or not according to the data length and the check code of the data frame to be processed;
if the frame of the data to be processed is complete, analyzing the frame of the data to be processed according to the frame type, the frame count and the frame ID;
if the frame type of the analyzed data frame to be processed is a request frame, packaging a frame header, response information, response data and a check code to obtain a response data frame, and sending the response data frame to a sending end by a receiving end, wherein the response information comprises frame count of the frame to be processed, frame ID of the frame to be processed and a received correct request frame;
the sending the data frame to be sent to the receiving end by the sending end includes:
at a transmitting end, acquiring configuration parameters, wherein the configuration parameters comprise a frame ID, a transmission type, a preset transmission period and a corresponding relation of an enabling state, and the transmission type comprises a period type and an event type;
determining the transmission type, the preset transmission period and the enabling state of the data frame to be transmitted according to the frame ID of the data frame to be transmitted;
if the transmission type of the data frame to be transmitted is periodic, writing the data frame to be transmitted into a buffer area according to a preset transmission period;
if the sending type of the data frame to be sent is event type, writing the data frame to be sent into a buffer area when the data frame to be sent is in an enabling state;
and reading the data frames to be transmitted from the buffer area according to the first-in first-out sequence, and transmitting the data frames to be transmitted to the receiving end.
2. The communication method as claimed in claim 1, wherein the receiving end determining the data frame to be processed by looking up the frame header identification from the received data comprises:
the receiving end determines a data frame to be processed from the received data by searching a frame header identifier according to a preset analysis period, wherein the preset analysis period is smaller than a preset sending period.
3. The communication method of claim 1, wherein parsing the frame of data to be processed based on the frame type, the frame count, and the frame ID comprises:
if the frame type of the data frame to be processed is a request frame, judging whether the frame ID in the data frame to be processed is in a preset range, if not, sending an error information code to an application layer, and if so, informing the application layer of receiving the correct data frame to be processed;
if the frame type of the data frame to be processed is a response frame, judging whether the frame ID in the data frame to be processed is correct, if not, transmitting an error information code to an application layer, if so, judging whether the frame count and the frame ID in response information in the data frame to be processed are the same as the frame count and the frame ID of the data frame when requested, if not, transmitting the error information code to the application layer, and if so, notifying the application layer of receiving the correct data frame to be processed.
4. The communication method as claimed in claim 1, wherein, if the frame type of the parsed data frame to be processed is a request frame, the frame header, the response information, the response data and the check code are encapsulated to obtain a response data frame, the receiving end sends the response data frame to the transmitting end, and the response information includes the frame count of the frame to be processed, the frame ID of the frame to be processed and the correct request frame received, and then includes:
if the sending type of the data frame to be sent is periodic, if the sending end does not receive the response data frame of the receiving end or the number of times that the received response data frame is in error exceeds the preset number of times, sending an error information code to the application layer;
if the sending type of the data frame to be sent is event type, if the sending end does not receive the response data frame of the receiving end after exceeding the preset time, the sending end resends, and when the resending times exceeds the preset times, the sending end sends error information codes to the application layer.
5. A communication device, the communication device comprising:
the packaging module is used for packaging a frame header, data to be transmitted and a check code at a transmitting end to obtain a data frame to be transmitted, wherein the frame header comprises a frame header identifier, a data length, a frame count, a frame type and a frame ID, and the frame type comprises a request frame and a response frame;
the sending module is used for sending the data frame to be sent to the receiving end by the sending end, wherein when the sending end is a microcontroller, the receiving end is a microprocessor, and when the sending end is a microprocessor, the receiving end is a microcontroller;
the receiving module is used for receiving the data from the transmitting end;
the verification module is used for determining a data frame to be processed from received data by the receiving end through searching a frame header identifier, and verifying whether the data frame to be processed is complete or not according to the data length of the data frame to be processed and a verification code;
the analysis module is used for analyzing the data frame to be processed according to the frame type, the frame count and the frame ID if the data frame to be processed is complete;
the response module is used for encapsulating the frame header, response information, response data and check codes to obtain a response data frame if the frame type of the analyzed data frame to be processed is a request frame, and the receiving end sends the response data frame to the sending end, wherein the response information comprises the frame count of the frame to be processed, the frame ID of the frame to be processed and the received correct request frame;
the sending module is used for:
at a transmitting end, acquiring configuration parameters, wherein the configuration parameters comprise a frame ID, a transmission type, a preset transmission period and a corresponding relation of an enabling state, and the transmission type comprises a period type and an event type;
determining the transmission type, the preset transmission period and the enabling state of the data frame to be transmitted according to the frame ID of the data frame to be transmitted;
if the transmission type of the data frame to be transmitted is periodic, writing the data frame to be transmitted into a buffer area according to a preset transmission period;
if the sending type of the data frame to be sent is event type, writing the data frame to be sent into a buffer area when the data frame to be sent is in an enabling state;
and reading the data frames to be transmitted from the buffer area according to the first-in first-out sequence, and transmitting the data frames to be transmitted to the receiving end.
6. The communication device of claim 5, wherein the parsing module is configured to:
if the frame type of the data frame to be processed is a request frame, judging whether the frame ID in the data frame to be processed is in a preset range, if not, sending an error information code to an application layer, and if so, informing the application layer of receiving the correct data frame to be processed;
if the frame type of the data frame to be processed is a response frame, judging whether the frame ID in the data frame to be processed is correct, if not, transmitting an error information code to an application layer, if so, judging whether the frame count and the frame ID in response information in the data frame to be processed are the same as the frame count and the frame ID of the data frame when requested, if not, transmitting the error information code to the application layer, and if so, notifying the application layer of receiving the correct data frame to be processed.
7. A communication device comprising a processor, a memory, and a communication program stored on the memory and executable by the processor, wherein the communication program, when executed by the processor, implements the steps of the communication method according to any one of claims 1 to 4.
8. A readable storage medium, wherein a communication program is stored on the readable storage medium, wherein the communication program, when executed by a processor, implements the steps of the communication method according to any one of claims 1 to 4.
CN202210834469.XA 2022-07-14 2022-07-14 Communication method, device, equipment and readable storage medium Active CN115314155B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210834469.XA CN115314155B (en) 2022-07-14 2022-07-14 Communication method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210834469.XA CN115314155B (en) 2022-07-14 2022-07-14 Communication method, device, equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN115314155A CN115314155A (en) 2022-11-08
CN115314155B true CN115314155B (en) 2024-01-09

Family

ID=83856365

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210834469.XA Active CN115314155B (en) 2022-07-14 2022-07-14 Communication method, device, equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN115314155B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115664599B (en) 2022-12-08 2023-03-28 杭州云酷智能科技有限公司 Data transmission method and device, electronic equipment and storage medium

Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6092116A (en) * 1996-12-11 2000-07-18 Lsi Logic Corporation DMA controller with response message and receive frame action tables
US7178133B1 (en) * 2001-04-30 2007-02-13 Mips Technologies, Inc. Trace control based on a characteristic of a processor's operating state
KR20090030765A (en) * 2007-09-21 2009-03-25 쌍용자동차 주식회사 Forwarding method of a can message for a car network communication
CN103546250A (en) * 2013-09-18 2014-01-29 中标软件有限公司 Communication method and communication system for vehicular terminal
CN104104475A (en) * 2013-04-02 2014-10-15 安凯(广州)微电子技术有限公司 Response signal generation method, receiving method and device
CN104914782A (en) * 2014-03-10 2015-09-16 深圳市蓝海华腾技术股份有限公司 Data communication method and related equipment for servo driver of numerically-controlled machine tool
CN104954374A (en) * 2015-06-15 2015-09-30 上海网车科技有限公司 IOV (Internet of Vehicles) communication protocol design method
CN106184069A (en) * 2016-07-07 2016-12-07 苏州大学 Automotive electronics micro-controller communications method based on CAN LIN network
CN108268420A (en) * 2016-12-31 2018-07-10 智车优行科技(北京)有限公司 Communication means, processor and electronic equipment between processor
CN109033338A (en) * 2018-07-23 2018-12-18 北京新能源汽车股份有限公司 Method and system for generating database file of automobile communication protocol
WO2021008248A1 (en) * 2019-07-12 2021-01-21 天地融科技股份有限公司 Data frame reception method and device and communication method and system
CN112673584A (en) * 2019-07-31 2021-04-16 北京小米移动软件有限公司 Data transmission method and device
CN113079072A (en) * 2020-01-06 2021-07-06 广州汽车集团股份有限公司 Vehicle data acquisition method and system, computer equipment and storage medium
WO2021149537A1 (en) * 2020-01-21 2021-07-29 株式会社オートネットワーク技術研究所 Management device, method for allocating identification information of on-vehicle device, on-vehicle system, and data structure

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP7003544B2 (en) * 2017-09-29 2022-01-20 株式会社デンソー Anomaly detection device, anomaly detection method, program and communication system

Patent Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6092116A (en) * 1996-12-11 2000-07-18 Lsi Logic Corporation DMA controller with response message and receive frame action tables
US7178133B1 (en) * 2001-04-30 2007-02-13 Mips Technologies, Inc. Trace control based on a characteristic of a processor's operating state
KR20090030765A (en) * 2007-09-21 2009-03-25 쌍용자동차 주식회사 Forwarding method of a can message for a car network communication
CN104104475A (en) * 2013-04-02 2014-10-15 安凯(广州)微电子技术有限公司 Response signal generation method, receiving method and device
CN103546250A (en) * 2013-09-18 2014-01-29 中标软件有限公司 Communication method and communication system for vehicular terminal
CN104914782A (en) * 2014-03-10 2015-09-16 深圳市蓝海华腾技术股份有限公司 Data communication method and related equipment for servo driver of numerically-controlled machine tool
CN104954374A (en) * 2015-06-15 2015-09-30 上海网车科技有限公司 IOV (Internet of Vehicles) communication protocol design method
CN106184069A (en) * 2016-07-07 2016-12-07 苏州大学 Automotive electronics micro-controller communications method based on CAN LIN network
CN108268420A (en) * 2016-12-31 2018-07-10 智车优行科技(北京)有限公司 Communication means, processor and electronic equipment between processor
CN109033338A (en) * 2018-07-23 2018-12-18 北京新能源汽车股份有限公司 Method and system for generating database file of automobile communication protocol
WO2021008248A1 (en) * 2019-07-12 2021-01-21 天地融科技股份有限公司 Data frame reception method and device and communication method and system
CN112673584A (en) * 2019-07-31 2021-04-16 北京小米移动软件有限公司 Data transmission method and device
CN113079072A (en) * 2020-01-06 2021-07-06 广州汽车集团股份有限公司 Vehicle data acquisition method and system, computer equipment and storage medium
WO2021149537A1 (en) * 2020-01-21 2021-07-29 株式会社オートネットワーク技術研究所 Management device, method for allocating identification information of on-vehicle device, on-vehicle system, and data structure

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
低压电机保护群控系统中基于CAN总线的数据通信;林中一, 孙新亚, 李迎春;继电器(第03期);全文 *

Also Published As

Publication number Publication date
CN115314155A (en) 2022-11-08

Similar Documents

Publication Publication Date Title
CN109558290B (en) Server, interface automatic test method and storage medium
WO2018127228A1 (en) Random access feedback and processing methods, base station and terminal
US6594697B1 (en) Client system having error page analysis and replacement capabilities
RU2332798C2 (en) Method and device of error acknowledgement for wireless communications system
CN109451032B (en) Message transmission system
CN115314155B (en) Communication method, device, equipment and readable storage medium
US20230262775A1 (en) Method and apparatus for implementing collision detection in data transmission
CN112104660A (en) Data transmission method, related equipment and readable storage medium
CN104348578B (en) The method and device of data processing
CN111752579A (en) Bluetooth terminal upgrading method and device, storage medium and electronic equipment
CN110855686A (en) SPI protocol communication method, system, equipment and computer storage medium
CN105635802A (en) Transmission method of digital media data and device
US9170801B2 (en) Data card updating method, personal computer, and data card
EP3893419A1 (en) Data retransmission decoding method, apparatus and system, and communication device
CN114788199A (en) Data verification method and device
CN109348509B (en) Communication method and apparatus, electronic device, and storage medium
CN111432426A (en) Method, device, equipment and storage medium for testing Bluetooth transmission speed
US20120066305A1 (en) Transmitting system and method thereof
EP3038390B1 (en) Processing method and apparatus for signaling tracing
US7162224B2 (en) System and method for piggybacking data across an open data channel of a wireless device
CN112787978B (en) Data acquisition method and device, computer equipment and computer-readable storage medium
CN218941111U (en) Microcontroller, electronic equipment and vehicle
CN115720201B (en) Method for testing data transmission stability of transparent transmission equipment, terminal equipment and medium
CN115484004B (en) Error message retry method and device, electronic equipment and storage medium
CN114880148B (en) Data processing method, device and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant