A serial communication method and device, electronic equipment and storage medium
By utilizing two or more serial ports in the intelligent cockpit domain control system, allocating communication data according to data type, and monitoring heartbeat link frames, the problem of disconnection between the MCU and MPU communication link is solved, thus achieving continuity of data transmission and stability of communication functions.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- AUTOLINK INFORMATION TECHNOLOGY CO LTD
- Filing Date
- 2026-04-22
- Publication Date
- 2026-07-31
AI Technical Summary
In intelligent cockpit domain control systems, once the serial communication link between the MCU and MPU fails, the communication data interaction is interrupted. Existing technologies require waiting for the MCU or MPU to be reset to restore communication, which affects data communication.
The communication data between the MCU and MPU is distributed to the corresponding serial port according to the type through two or more serial ports, and the serial port communication status is monitored through the heartbeat link frame. In case of abnormality, the system dynamically switches to other normal serial ports for data transmission to ensure communication continuity.
It enables timely switching of data transmission paths when serial communication fails, avoiding the impact of communication link disconnection on data communication and ensuring the normal operation of communication functions.
Smart Images

Figure CN122489322A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cockpit communication technology, and more specifically, to a serial communication method, apparatus, electronic device, and storage medium. Background Technology
[0002] Intelligent cockpit domain control systems typically consist of a System-on-Chip (SOC) and a Microcontroller Unit (MCU). The SOC, also known as an MPU (Microprocessor Unit), is responsible for central control and instrument functions such as entertainment, settings, and third-party ecosystem integration. The MCU, on the other hand, is responsible for power management of the domain control host, network management with the vehicle, and CAN / LIN communication.
[0003] Currently, the MPU and MCU communicate via UART / SPI serial ports for data such as CAN, LIN, and MCU-MPU proprietary protocols, playing a very important communication role. Typically, the domain controller host has one or two or more UART / SPI ports.
[0004] However, if there is only one serial port, the communication link between the MCU and the MPU will also fail after the serial port fails. If there are two or more serial ports, the communication data exchange performed by the corresponding serial port will also fail after the corresponding serial port fails. The only solution is to wait for the MCU and MPU to try to restore the serial communication, or for the MCU to reset the MPU and restore the serial communication, which will affect the data communication. Summary of the Invention
[0005] In view of this, the purpose of this application is to provide a serial communication method, device, electronic device and storage medium, which utilizes two or more serial ports to allocate communication data between the MCU and MPU according to type to the corresponding serial port, thereby decoupling the communication data between the MCU and MPU, and judging the serial communication by listening to the heartbeat link frame. In the event of a serial communication failure, the communication data of the abnormal serial port is immediately and dynamically switched to other normal serial ports for data communication, ensuring the normal operation of the communication function and avoiding the impact on data communication after the communication link is disconnected.
[0006] In a first aspect, embodiments of this application provide a serial communication method applied to an intelligent cockpit domain controller; the intelligent cockpit domain controller includes an MCU and an MPU, and the intelligent cockpit domain controller has at least two serial ports; the method includes: In response to the establishment of serial communication between the MCU and the MPU after each power-on, a corresponding heartbeat link is established for each serial port between the MCU and the MPU; The communication data between the MCU and the MPU is divided according to the data type, and the MCU distributes the classified communication data to the corresponding serial port. The heartbeat link is continuously monitored to obtain the heartbeat link frame of each serial port. The serial port's communication status is determined based on the heartbeat link frame of each serial port. When an abnormal serial port communication is detected, the communication data of the abnormal serial port is transferred to a target serial port according to agreed rules; wherein, the target serial port is another normal serial port. Reset the faulty serial port to attempt to restore serial communication, and if the faulty serial port successfully restores communication, transfer the original communication data of the faulty serial port back to the faulty serial port.
[0007] In one possible implementation, the step of determining whether the serial port is communicating normally based on the heartbeat link frame of each serial port, and when it is determined that the serial port communication is abnormal, transferring the communication data of the abnormal serial port to the target serial port according to the agreed rules, includes: In response to determining the target timeout of the heartbeat link frame of any serial port, the serial port is identified as an abnormal serial port, and the heartbeat link frames of all serial ports are determined to have timed out. If the heartbeat link frame of all serial ports times out, the communication data of the abnormal serial port will be transferred to the target serial port according to the agreed rules.
[0008] In one possible implementation, determining the target timeout time for the heartbeat link frame of any serial port includes: If the MCU sends multiple heartbeat query frames without receiving a response from the MPU, the MCU determines that the serial communication with the MPU on this channel is abnormal. The MCU attempts to reconnect by resetting the faulty serial port.
[0009] In one possible implementation, determining the target timeout time for the heartbeat link frame of any serial port includes: If the MPU does not receive a heartbeat query frame from the MCU within the target time after the last heartbeat response frame, the MPU determines that the serial communication with the MCU on this channel is abnormal. The MPU attempts to reconnect to the faulty serial port by resetting it, and displays a message indicating a serial port communication error on the MPU's interface.
[0010] In one possible implementation, the method further includes: In response to the failure of the MPU to restore communication via the abnormal serial port, an entry button for restarting the domain controller is provided on the target interface; In response to the user clicking the entry button on the target interface, the smart cockpit domain controller is reset and restarted.
[0011] In one possible implementation, the method further includes: If the heartbeat link frame of all serial ports times out of the target time, it is determined that all serial ports have failed at the same time, and the failure time is determined by the MCU and MPU. When the failure time exceeds the second target time, the MCU automatically restarts the MPU to restore serial communication.
[0012] In one possible implementation, the continuous monitoring of the heartbeat link to obtain the heartbeat link frame for each serial port includes: The monitoring period is determined based on project requirements. During the monitoring period, the MCU sends the heartbeat query frame to the MPU and the MPU replies with the corresponding heartbeat response frame to the MCU; wherein, the monitoring period represents the number of heartbeat query frames continuously sent by the MCU.
[0013] Secondly, embodiments of this application also provide a serial communication device applied to a smart cockpit domain controller; the smart cockpit domain controller includes an MCU and an MPU, and the smart cockpit domain controller has at least two serial ports; the device includes: The communication module is used to establish a corresponding heartbeat link between each serial port between the MCU and the MPU in response to the establishment of serial communication between the MCU and the MPU after each power-on. The monitoring module is used to classify the communication data between the MCU and the MPU according to the data type, and to allocate the classified communication data to the corresponding serial port through the MCU, and to continuously monitor the heartbeat link to obtain the heartbeat link frame of each serial port. The first switching module is used to determine whether the serial port is communicating normally based on the heartbeat link frame of each serial port. When the serial port communication is determined to be abnormal, the communication data of the abnormal serial port is transferred to the target serial port according to the agreed rules; wherein, the target serial port is the normal serial port of another port. The second switching module is used to reset the abnormal serial port to attempt to restore serial communication, and in response to the successful restoration of communication of the abnormal serial port, it switches the original communication data of the abnormal serial port back to the abnormal serial port.
[0014] In one possible implementation, the first switching module is specifically used to: determine that the serial port is an abnormal serial port in response to determining that the heartbeat link frame of any serial port has exceeded the target time, and determine whether the heartbeat link frame of all serial ports has exceeded the time limit. If the heartbeat link frame of all serial ports times out, the communication data of the abnormal serial port will be transferred to the target serial port according to the agreed rules.
[0015] In one possible implementation, the first switching module is specifically used for: If the MCU sends multiple heartbeat query frames without receiving a response from the MPU, the MCU determines that the serial communication with the MPU on this channel is abnormal. The MCU attempts to reconnect by resetting the faulty serial port.
[0016] In one possible implementation, the first switching module is specifically used for: If the MPU does not receive a heartbeat query frame from the MCU within the target time after the last heartbeat response frame, the MPU determines that the serial communication with the MCU on this channel is abnormal. The MPU attempts to reconnect to the faulty serial port by resetting it, and displays a message indicating a serial port communication error on the MPU's interface.
[0017] In one possible implementation, the device further includes: The recovery module is used to provide an entry button for restarting the domain controller on the target interface in response to the failure of the MPU to restore communication via an abnormal serial port. The reset module is used to reset and restart the smart cockpit domain controller in response to the user clicking the entry button on the target interface.
[0018] In one possible implementation, the device further includes: The determination module is used to determine that all serial ports have failed at the same time when the heartbeat link frame of all serial ports times out of the target time, and to determine the failure time through the MCU and MPU. The restart module is used to automatically restart the MPU through the MCU to restore serial communication when the failure time exceeds the second target time.
[0019] In one possible implementation, the monitoring module is specifically used for: The monitoring period is determined based on project requirements. During the monitoring period, the MCU sends the heartbeat query frame to the MPU and the MPU replies with the corresponding heartbeat response frame to the MCU; wherein, the monitoring period represents the number of heartbeat query frames continuously sent by the MCU.
[0020] Thirdly, embodiments of this application provide an electronic device, including: a processor, a storage medium, and a bus. The storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the serial communication method as described in any of the first aspects.
[0021] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the serial communication method described in any one of the first aspects.
[0022] This application provides a serial communication method, apparatus, electronic device, and storage medium. In response to the establishment of serial communication between the MCU and MPU after each power-on, a corresponding heartbeat link is established for each serial port between the MCU and MPU. The communication data between the MCU and MPU is divided according to data type, and the MCU distributes the classified communication data to the corresponding serial port. The heartbeat link is continuously monitored to obtain the heartbeat link frame of each serial port. Based on the heartbeat link frame of each serial port, it is determined whether the serial port is communicating normally. When a serial port communication is determined to be abnormal, the communication data of the abnormal serial port is transferred to the target serial port according to agreed rules. The abnormal serial port is reset to attempt to restore serial communication. In response to the successful restoration of communication by the abnormal serial port, the original communication data of the abnormal serial port is transferred back to that serial port. This application utilizes two or more serial ports to allocate communication data between the MCU and MPU according to their types to the corresponding serial ports. This decouples the communication data between the MCU and MPU. It also detects serial communication by listening to the heartbeat link frame and dynamically switches the communication data of the abnormal serial port to other normal serial ports immediately when the serial communication is abnormal. This ensures the normal operation of the communication function and avoids the impact on data communication after the communication link is disconnected.
[0023] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0024] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 This is a flowchart of a serial communication method provided according to an embodiment of this application; Figure 2 This is a schematic diagram of the architecture of the intelligent cockpit domain control host; Figure 3 This is a schematic diagram of the overall serial communication process; Figure 4 This is a schematic diagram of the structure of a serial communication device provided according to an embodiment of this application; Figure 5 This is a schematic diagram of the structure of an electronic device provided according to an embodiment of this application. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0027] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0028] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0029] Considering that intelligent cockpit domain control systems are typically composed of a System-on-Chip (SOC) and a Microcontroller Unit (MCU), the SOC, also known as a Microprocessor Unit (MPU), is responsible for central control and instrument functions such as entertainment, settings, and third-party ecosystems, while the MCU is responsible for power management of the domain control host, network management with the vehicle, and CAN / LIN communication.
[0030] Currently, the MPU and MCU communicate via UART / SPI serial ports for data such as CAN, LIN, and MCU-MPU proprietary protocols, playing a very important communication role. Typically, the domain controller host has one or two or more UART / SPI ports.
[0031] However, if there is only one serial port, the communication link between the MCU and the MPU will also fail after the serial port fails. If there are two or more serial ports, the communication data exchange performed by the corresponding serial port will also fail after the corresponding serial port fails. The only solution is to wait for the MCU and MPU to try to restore the serial communication, or for the MCU to reset the MPU and restore the serial communication, which will affect the data communication.
[0032] To address this issue, this application provides a serial communication method, apparatus, electronic device, and storage medium. By using two or more serial ports, communication data between the MCU and MPU is allocated to corresponding serial ports according to their type, thus decoupling the communication data between the MCU and MPU. Serial communication is determined by monitoring heartbeat link frames, and in the event of a serial communication anomaly, the communication data of the abnormal serial port is dynamically switched to other normal serial ports for data communication, ensuring the normal operation of the communication function and preventing the impact on data communication after a communication link is lost.
[0033] Figure 1 This is a flowchart of a serial communication method provided according to an embodiment of this application. For example... Figure 1 As shown, the serial communication method of this application embodiment may specifically include: S101. In response to the establishment of serial communication between the MCU and MPU after each power-on, a corresponding heartbeat link is established for each serial port between the MCU and MPU.
[0034] S102. Divide the communication data between the MCU and MPU according to the data type, and use the MCU to allocate the classified communication data to the corresponding serial port, and continuously monitor the heartbeat link to obtain the heartbeat link frame of each serial port.
[0035] S103. Determine whether the serial port is communicating normally based on the heartbeat link frame of each serial port. When the serial port communication is determined to be abnormal, the communication data of the abnormal serial port is transferred to the target serial port according to the agreed rules.
[0036] S104. Reset the abnormal serial port to attempt to restore serial communication, and in response to the successful restoration of communication of the abnormal serial port, transfer the original communication data of the abnormal serial port back to the abnormal serial port.
[0037] In the above serial communication method, the communication data between the MCU and MPU is distributed to the corresponding serial ports according to the type through two or more serial ports. This decouples the communication data between the MCU and MPU. The serial communication is judged by listening to the heartbeat link frame. When the serial communication is abnormal, the communication data of the abnormal serial port is immediately switched to other normal serial ports for data communication. This ensures the normal operation of the communication function and avoids the impact on data communication after the communication link is disconnected.
[0038] The exemplary steps described above in the embodiments of this application are illustrated below with specific examples: S101, in response to the establishment of serial communication between the MCU and MPU after each power-on, establishes a corresponding heartbeat link for each serial port between the MCU and MPU.
[0039] It should be noted that the serial communication method of this application is applied to an intelligent cockpit domain controller; the intelligent cockpit domain controller includes an MCU and an MPU (or SOC); the intelligent cockpit domain controller has at least two serial ports, that is, at least two serial ports exist between the MCU and the MPU. The serial port type can be UART, SPI, or a mixture of UART and SPI, i.e., UART / SPI serial port. It can be entirely UART, entirely SPI, or a mixture of UART and SPI. For example, as... Figure 2 As shown, there are three serial ports between the MCU and MPU of the intelligent cockpit domain controller.
[0040] In this embodiment, after each power-on of the domain controller, the MCU and MPU establish serial communication, i.e., communication connections for all serial ports, and establish a corresponding heartbeat link for each serial port between the MCU and MPU for subsequent processing. For example, as Figure 2 and Figure 3 As shown in step S102, the communication data between the MCU and MPU is divided according to the data type, and the MCU distributes the classified communication data to the corresponding serial ports. The heartbeat link is continuously monitored to obtain the heartbeat link frame of each serial port.
[0041] In this embodiment, the communication data types include at least internal data, central control data, and instrument data. Specifically, the communication data types include internal communication data between the MCU and MPU, vehicle CAN / LIN data related to the central control system, and vehicle CAN / LIN data related to the instrument cluster. The communication data between the MCU and MPU is divided according to data type. For example, internal communication data between the MCU and MPU uses serial port 1, vehicle CAN / LIN data related to the central control system uses serial port 2, and vehicle CAN / LIN data related to the instrument cluster uses serial port 3. The MCU then distributes the categorized communication data to the corresponding serial ports and continuously monitors the heartbeat links to obtain the heartbeat link frames for each serial port for subsequent processing. For example, as... Figure 2 and Figure 3 As shown.
[0042] It can be added that, such as Figure 2As shown, the CAN / LIN transceiver module is responsible for receiving CAN / LIN bus data and sending domain control CAN / LIN data to the CAN / LIN bus. The CAN / LIN parsing module and encapsulation module are responsible for parsing the CAN / LIN data and encapsulating it with private protocols, so that the MCU can obtain the communication data.
[0043] It should be noted that, on the MCU side, the MCU receives communication data and parses it to obtain the data type, and then the MCU classifies the communication data according to the data type; on the MPU side, the MPU receives communication data and parses it to obtain the data type, and then the MPU classifies the communication data according to the data type.
[0044] Optionally, when continuously monitoring the heartbeat link and acquiring heartbeat link frames from each serial port, the monitoring period is determined based on project requirements. During the monitoring period, the MCU sends heartbeat query frames to the MPU, and the MPU replies with corresponding heartbeat response frames to the MCU. The monitoring period represents the number of heartbeat query frames continuously sent by the MCU.
[0045] Specifically, for example, the MCU and MPU establish communication connections for all serial ports and send heartbeat link frames at a listening period of 1 second (this time can be adjusted according to the actual needs of the project). The MCU sends a heartbeat query frame, and the MPU replies with a heartbeat response frame, thereby monitoring whether the serial port communication is normal.
[0046] S103 determines whether the serial port is communicating normally based on the heartbeat link frame of each serial port. When the serial port communication is found to be abnormal, the communication data of the abnormal serial port is transferred to the target serial port according to the agreed rules.
[0047] In this embodiment of the application, the target serial port is another normal serial port. The heartbeat link frame of each serial port in step S102 is used to determine whether the serial port is communicating normally. When the serial port communication is determined to be abnormal (i.e. the serial port is abnormal), the communication data of the abnormal serial port is transferred to the target serial port, i.e. other normal serial ports, according to the agreed rules.
[0048] In some implementations, in response to determining that the heartbeat link frame of any serial port has exceeded the target time, the serial port is determined to be an abnormal serial port, and it is determined whether the heartbeat link frames of all serial ports have exceeded the time limit; if the heartbeat link frames of all serial ports have not exceeded the time limit, the communication data of the abnormal serial port is transferred to the target serial port based on the agreed rules.
[0049] It can be added here that, until the abnormal serial port successfully resumes communication, the communication data of the abnormal serial port will continue to be transferred to the target serial port.
[0050] Optionally, when determining that the heartbeat link frame of any serial port has timed out to the target time, if the MCU fails to receive a response from the MPU after continuously sending multiple heartbeat query frames, the MCU determines that the serial communication with the MPU on that channel is abnormal; and attempts to reconnect by resetting the abnormal serial port. Here, heartbeat link frame timeout indicates that the MCU has failed to receive a response from the MPU after continuously sending multiple heartbeat query frames.
[0051] It should be noted that when transferring communication data from an abnormal serial port to the target serial port, if the first serial port communication fails, the communication data from the abnormal serial port is transferred to the second serial port; if the second serial port communication fails, the communication data from the abnormal serial port is transferred to the third serial port; if the third serial port communication fails, the communication data from the abnormal serial port is transferred to the first serial port; if the first and second serial ports communication fails, the communication data from the abnormal serial ports is transferred to the third serial port; and if the second and third serial ports communication fails, the communication data from the abnormal serial ports is transferred to the first serial port.
[0052] Specifically, for example, if the heartbeat link frame times out by 3 seconds (this time can be adjusted according to the actual needs of the project), meaning the MCU sends three consecutive heartbeat query frames without receiving a response from the MPU, the MCU determines that the serial communication with the MPU on that channel is abnormal, and the MCU resets the serial port to attempt reconnection. The MCU serial port heartbeat link monitoring and switching module transfers the communication data of that serial port to other serial ports according to the agreed rules. If serial port 1 is abnormal, it transfers to serial port 2; if serial port 2 is abnormal, it transfers to serial port 3; if serial port 3 is abnormal, it transfers to serial port 1. If both serial ports 1 and 2 are abnormal, it transfers to serial port 3; if both serial ports 2 and 3 are abnormal, it transfers to serial port 1. This operation is maintained until the abnormal serial port resumes communication; after the abnormal serial port resumes communication (i.e., the heartbeat link frame restarts), the original communication data is transferred back to that serial port.
[0053] Optionally, when determining the target timeout of the heartbeat link frame of any serial port, if the MPU does not receive a heartbeat query frame from the MCU within the target time after the last heartbeat response frame, the MPU determines that the serial port communication with the MCU on that channel is abnormal; the MPU attempts to reconnect by resetting the abnormal serial port, and displays a message on the MPU interface indicating that the corresponding serial port communication is abnormal.
[0054] Specifically, for example, if the MPU does not receive a heartbeat query frame from the MCU 3 seconds after the last heartbeat response frame (this time can be adjusted according to the actual needs of the project), the MPU determines that the serial communication with the MCU on that channel is abnormal. The MPU resets the serial port and attempts to reconnect, and displays a message on the MPU interface indicating that the corresponding serial communication is abnormal.
[0055] In some implementations, in response to the MPU's failure to restore communication via an abnormal serial port, an entry button for restarting the domain controller is provided on the target interface; in response to the user clicking the entry button on the target interface, the intelligent cockpit domain controller is reset and restarted.
[0056] Specifically, when the MPU restores communication to the abnormal serial port, if the serial port reset and reconnection fails multiple times (e.g., three times), an entry button for restarting the domain controller is provided on the interface. If the user actively clicks the restart button, the domain controller will perform a reset and restart.
[0057] S104, reset the abnormal serial port to attempt to restore serial communication, and in response to the successful restoration of communication of the abnormal serial port, transfer the original communication data of the abnormal serial port back to the abnormal serial port.
[0058] In this embodiment of the application, the abnormal serial port is reset in an attempt to restore serial communication. When the abnormal serial port successfully restores communication (i.e., the abnormal serial port restarts the heartbeat link frame), the original communication data of the abnormal serial port is transferred back to the serial port.
[0059] The serial communication method provided in this application embodiment, in response to the establishment of serial communication between the MCU and MPU after each power-on, establishes a corresponding heartbeat link for each serial port between the MCU and MPU, divides the communication data between the MCU and MPU according to the data type, and distributes the classified communication data to the corresponding serial port through the MCU, continuously monitors the heartbeat link, obtains the heartbeat link frame of each serial port, determines whether the serial port is communicating normally based on the heartbeat link frame of each serial port, and when the serial port communication is determined to be abnormal, the communication data of the abnormal serial port is transferred to the target serial port according to the agreed rules, the abnormal serial port is reset to attempt to restore serial communication, and in response to the successful restoration of communication of the abnormal serial port, the original communication data of the abnormal serial port is transferred back to the serial port. The serial communication method of this application allocates the communication data between the MCU and MPU to the corresponding serial ports according to their types through two or more serial ports. This decouples the communication data between the MCU and MPU. The serial communication is judged by listening to the heartbeat link frame. When the serial communication is abnormal, the communication data of the abnormal serial port is immediately dynamically switched to other normal serial ports for data communication. This ensures the normal operation of the communication function and avoids the impact on data communication after the communication link is disconnected.
[0060] Furthermore, if the heartbeat link frame of all serial ports times out to the target time, it is determined that all serial ports have failed at the same time, and the failure time is determined by the MCU and MPU. If the failure time exceeds the second target time, the MCU will automatically restart the MPU to restore serial communication.
[0061] Specifically, for example, if all serial ports fail at the same time, the MCU and MPU determine the duration of the situation. If it exceeds 10 seconds (this time can be adjusted according to the actual needs of the project), the MCU will automatically restart the MPU to restore serial communication.
[0062] Therefore, in this application, the domain controller host is equipped with two or more UART / SPI serial ports, which split the communication data between the MCU and the MPU into fixed serial ports. Each serial port has a periodic heartbeat link. When a serial port times out without a heartbeat link, the communication data of that serial port is switched to another serial port. After recovery, the communication data is switched back. This achieves the goal of not affecting data communication after the communication link is disconnected. Users are almost unaware of the data disconnection, and even if a serial port is damaged in hardware, it will not affect data communication.
[0063] In summary, this application utilizes two or more serial ports to distribute communication data between the MCU and MPU according to type, thereby decoupling the communication data between the MCU and MPU. The status of serial port communication is determined by the heartbeat link frame of each serial port; if the heartbeat link times out, the communication data of that serial port is immediately transferred to another serial port. This ensures that normal communication can be maintained even when not all serial ports fail, which is very user-friendly. Compared with existing technologies, data diversion improves communication efficiency, and monitoring the heartbeat link frame to determine serial port communication and dynamically switching the corresponding serial port data communication ensures normal communication functionality.
[0064] It should be noted that the serial communication method of this application can also be a dynamic switching method for serial communication.
[0065] Figure 4 This is a schematic diagram of the structure of a serial communication device provided according to an embodiment of this application; as shown below. Figure 4 As shown, the serial communication device 400 of this application embodiment may specifically include: Communication module 401 is used to establish a corresponding heartbeat link between each serial port between the MCU and the MPU in response to the establishment of serial communication between the MCU and the MPU after each power-on. The monitoring module 402 is used to classify the communication data between the MCU and the MPU according to the data type, and to allocate the classified communication data to the corresponding serial port through the MCU, and to continuously monitor the heartbeat link to obtain the heartbeat link frame of each serial port. The first switching module 403 is used to determine whether the serial port is communicating normally based on the heartbeat link frame of each serial port. When the serial port communication is determined to be abnormal, the communication data of the abnormal serial port is transferred to the target serial port according to the agreed rules; wherein, the target serial port is the normal serial port of another port. The second switching module 404 is used to reset the abnormal serial port to attempt to restore serial communication, and in response to the successful restoration of communication of the abnormal serial port, the original communication data of the abnormal serial port is transferred back to the abnormal serial port.
[0066] In one possible implementation, the first switching module is specifically used to: determine that the serial port is an abnormal serial port in response to determining that the heartbeat link frame of any serial port has exceeded the target time, and determine whether the heartbeat link frame of all serial ports has exceeded the time limit. If the heartbeat link frame of all serial ports times out, the communication data of the abnormal serial port will be transferred to the target serial port according to the agreed rules.
[0067] In one possible implementation, the first switching module is specifically used for: If the MCU sends multiple heartbeat query frames without receiving a response from the MPU, the MCU determines that the serial communication with the MPU on this channel is abnormal. The MCU attempts to reconnect by resetting the faulty serial port.
[0068] In one possible implementation, the first switching module is specifically used for: If the MPU does not receive a heartbeat query frame from the MCU within the target time after the last heartbeat response frame, the MPU determines that the serial communication with the MCU on this channel is abnormal. The MPU attempts to reconnect to the faulty serial port by resetting it, and displays a message indicating a serial port communication error on the MPU's interface.
[0069] In one possible implementation, the device further includes: The recovery module is used to provide an entry button for restarting the domain controller on the target interface in response to the failure of the MPU to restore communication via an abnormal serial port. The reset module is used to reset and restart the smart cockpit domain controller in response to the user clicking the entry button on the target interface.
[0070] In one possible implementation, the device further includes: The determination module is used to determine that all serial ports have failed at the same time when the heartbeat link frame of all serial ports times out of the target time, and to determine the failure time through the MCU and MPU. The restart module is used to automatically restart the MPU through the MCU to restore serial communication when the failure time exceeds the second target time.
[0071] In one possible implementation, the monitoring module is specifically used for: The monitoring period is determined based on project requirements. During the monitoring period, the MCU sends the heartbeat query frame to the MPU and the MPU replies with the corresponding heartbeat response frame to the MCU; wherein, the monitoring period represents the number of heartbeat query frames continuously sent by the MCU.
[0072] The serial communication device provided in this application embodiment, in response to the establishment of serial communication between the MCU and MPU after each power-on, establishes a corresponding heartbeat link for each serial port between the MCU and MPU, divides the communication data between the MCU and MPU according to the data type, and distributes the classified communication data to the corresponding serial port through the MCU, continuously monitors the heartbeat link, obtains the heartbeat link frame of each serial port, determines whether the serial port is communicating normally based on the heartbeat link frame of each serial port, and when it is determined that the serial port communication is abnormal, the communication data of the abnormal serial port is transferred to the target serial port according to the agreed rules, the abnormal serial port is reset to attempt to restore serial communication, and in response to the successful restoration of communication of the abnormal serial port, the original communication data of the abnormal serial port is transferred back to the serial port. The serial communication device of this application allocates the communication data between the MCU and MPU to the corresponding serial ports according to their types through two or more serial ports. This decouples the communication data between the MCU and MPU. It also judges the serial communication by listening to the heartbeat link frame, and immediately switches the communication data of the abnormal serial port to other normal serial ports for data communication when the serial communication is abnormal. This ensures the normal operation of the communication function and avoids the impact on data communication after the communication link is disconnected.
[0073] like Figure 5 As shown in the embodiment of this application, an electronic device 500 includes a processor 501, a memory 502, and a bus. The memory 502 stores machine-readable instructions that can be executed by the processor 501. When the electronic device is running, the processor 501 communicates with the memory 502 via the bus. The processor 501 executes the machine-readable instructions to perform the steps of the serial communication method described above.
[0074] Specifically, the memory 502 and processor 501 mentioned above can be general-purpose memory and processor, without any specific limitations. When the processor 501 runs the computer program stored in the memory 502, it can execute the serial communication method mentioned above.
[0075] Corresponding to the above-described serial communication method, this application embodiment also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the above-described serial communication method.
[0076] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the method embodiments, and will not be repeated here. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some communication interfaces; the indirect coupling or communication connection of devices or modules can be electrical, mechanical, or other forms.
[0077] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0078] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0079] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the deployment methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.
[0080] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A serial communication method, characterized in that, The method is applied to a smart cockpit domain controller; the smart cockpit domain controller includes an MCU and an MPU, and the smart cockpit domain controller has at least two serial ports; the method includes: In response to the establishment of serial communication between the MCU and the MPU after each power-on, a corresponding heartbeat link is established for each serial port between the MCU and the MPU; The communication data between the MCU and the MPU is divided according to the data type, and the MCU distributes the classified communication data to the corresponding serial port. The heartbeat link is continuously monitored to obtain the heartbeat link frame of each serial port. The serial port's communication status is determined based on the heartbeat link frame of each serial port. When an abnormal serial port communication is detected, the communication data of the abnormal serial port is transferred to a target serial port according to agreed rules; wherein, the target serial port is another normal serial port. Reset the faulty serial port to attempt to restore serial communication, and if the faulty serial port successfully restores communication, transfer the original communication data of the faulty serial port back to the faulty serial port.
2. The method according to claim 1, characterized in that, The step of determining whether a serial port is communicating normally based on the heartbeat link frame of each serial port, and transferring the communication data of the abnormal serial port to the target serial port according to the agreed rules when the serial port communication is abnormal, includes: In response to determining the target timeout of the heartbeat link frame of any serial port, the serial port is identified as an abnormal serial port, and the heartbeat link frames of all serial ports are determined to have timed out. If the heartbeat link frame of all serial ports times out, the communication data of the abnormal serial port will be transferred to the target serial port according to the agreed rules.
3. The method according to claim 2, characterized in that, The determination of the target timeout time for the heartbeat link frame of any serial port includes: If the MCU sends multiple heartbeat query frames without receiving a response from the MPU, the MCU determines that the serial communication with the MPU on this channel is abnormal. The MCU attempts to reconnect by resetting the faulty serial port.
4. The method according to claim 1, characterized in that, The determination of the target timeout time for the heartbeat link frame of any serial port includes: If the MPU does not receive a heartbeat query frame from the MCU within the target time after the last heartbeat response frame, the MPU determines that the serial communication with the MCU on this channel is abnormal. The MPU attempts to reconnect to the faulty serial port by resetting it, and displays a message indicating a serial port communication error on the MPU's interface.
5. The method according to claim 1, characterized in that, The method further includes: In response to the failure of the MPU to restore communication via the abnormal serial port, an entry button for restarting the domain controller is provided on the target interface; In response to the user clicking the entry button on the target interface, the smart cockpit domain controller is reset and restarted.
6. The method according to claim 1, characterized in that, The method further includes: If the heartbeat link frame of all serial ports times out of the target time, it is determined that all serial ports have failed at the same time, and the failure time is determined by the MCU and MPU. When the failure time exceeds the second target time, the MCU automatically restarts the MPU to restore serial communication.
7. The method according to claim 1, characterized in that, The step of continuously monitoring the heartbeat link and acquiring the heartbeat link frame of each serial port includes: The monitoring period is determined based on project requirements. During the monitoring period, the MCU sends the heartbeat query frame to the MPU and the MPU replies with the corresponding heartbeat response frame to the MCU; wherein, the monitoring period represents the number of heartbeat query frames continuously sent by the MCU.
8. A serial communication device applied to a smart cockpit domain controller; the smart cockpit domain controller includes an MCU and an MPU, and the smart cockpit domain controller has at least two serial ports; characterized in that, The device includes: The communication module is used to establish a corresponding heartbeat link between each serial port between the MCU and the MPU in response to the establishment of serial communication between the MCU and the MPU after each power-on. The monitoring module is used to classify the communication data between the MCU and the MPU according to the data type, and to allocate the classified communication data to the corresponding serial port through the MCU, and to continuously monitor the heartbeat link to obtain the heartbeat link frame of each serial port. The first switching module is used to determine whether the serial port is communicating normally based on the heartbeat link frame of each serial port. When the serial port communication is determined to be abnormal, the communication data of the abnormal serial port is transferred to the target serial port according to the agreed rules; wherein, the target serial port is the normal serial port of another port. The second switching module is used to reset the abnormal serial port to attempt to restore serial communication, and in response to the successful restoration of communication of the abnormal serial port, it switches the original communication data of the abnormal serial port back to the abnormal serial port.
9. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, they perform the steps of the serial communication method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the serial communication method as described in any one of claims 1 to 7.