CAN message processing method and device, electronic equipment and storage medium
By setting the loop buffer and numbered sending buffer in the controller driver layer, dynamically scheduling the sending priority of CAN messages, solving the problem of untimely sending frame drops and high-priority messages in domestic controllers when processing CAN messages. Problem, improving system performance.
Patent Information
- Application Number
- CN202411383682.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2024-12-17
AI Technical Summary
Domestic controllers are prone to losing frames and cannot send high-priority packets in time when processing CAN messages, resulting in a degradation of system performance.
The driver layer of the controller sets the receiving loop buffer and the sending buffer, and the sending buffer is numbered, and messages are stored and read through the loop buffer, and sending dynamically based on the priority of the message to avoid packet coverage and Priority reversal.
It effectively avoids the overwrite of packet reception and priority inversion, ensures timely sending of high-priority packets, and improves the processing capability and system performance of the CAN controller.
Smart Images

Figure CN119155268A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of domestic controllers, and in particular to a CAN message processing method, device, electronic equipment and storage medium. Background Art
[0002] As a core component in the electronic and electrical architecture of a vehicle, GW realizes the sharing of information on the bus within each network segment. Currently, the most widely used communication bus in the automotive field is CAN. The number of CAN controllers of the gateway controller and its receive / send MB directly determine the performance of the gateway.
[0003] At present, the mainstream gateway controller chips in the automotive industry are Infineon AURIXTM TCxxx series, NXPS32K series, etc., which are all foreign chips, and their integrated CAN core supports up to 256 MB for configuring the sending and receiving messages. There are relatively few domestic chips with completely independent intellectual property rights suitable for automotive gateways. For example, Haiwei Huaxin HHD32F107VCH has 6-way CAN controllers, but each CAN controller has only one set of acceptance filters for receiving messages and one send data buffer for sending messages.
[0004] Based on domestic chips, the engineering implementation uses CAN interrupts to parse, process and route received messages to the destination network segment. This technical solution can work normally when the vehicle electrical architecture is relatively simple and the communication message signal volume is small. It uses a 500kbps communication rate. Ideally, the complete message is received at 3.6 frames / ms. When the system tasks increase or the signal volume increases, it is easy to have: 1) frame loss, that is, there is no time to process the cached message in the receiving RAM in time, resulting in it being overwritten by the next frame message; 2) internal message priority inversion, that is, low-priority messages fail to compete for the bus and occupy TxMB, resulting in high-priority messages unable to enter TxMB. Therefore, there are technical problems in the prior art that the CAN message processing of domestic controllers is prone to frame loss and high-priority messages cannot be sent in time. Summary of the invention
[0005] In view of this, it is necessary to provide a CAN message processing method, device, electronic device and storage medium to solve the technical problems in the prior art that CAN message processing of domestic controllers is prone to frame loss and high-priority messages cannot be sent in time.
[0006] In order to solve the above technical problems, on the one hand, the present invention provides a CAN message processing method, comprising: A receiving ring buffer and a sending buffer are set in the driver layer of the controller, and the sending buffer is numbered to obtain a numbered sending buffer; When the driver layer receives a message, it stores the message in the receiving ring buffer; Read the message in the circular buffer to obtain multiple messages to be sent, and store the multiple messages to be sent in the numbered sending buffer to obtain the numbers corresponding to the multiple messages to be sent, calculate based on the numbers corresponding to the multiple messages to be sent, obtain the priorities of the multiple messages to be sent, and determine the current message to be sent and send it based on the priorities of the multiple messages to be sent.
[0007] In a possible implementation, storing the message in a receiving ring buffer includes: An algorithm based on a circular linked list is designed to store messages in a receiving circular buffer.
[0008] In a possible implementation, the method further includes: When the current message to be sent is not sent successfully, the sending time of the current message to be sent is obtained, and the sending time of the current message to be sent is matched with a preset time threshold. When the time of the current message to be sent is greater than the preset time threshold, the current message to be sent is discarded, and based on the priorities of multiple messages to be sent, the current message to be sent is re-determined.
[0009] In a possible implementation, discarding the current message to be sent and re-determining the current message to be sent based on priorities of multiple messages to be sent includes: The current message to be sent is discarded, and the priorities of the multiple messages to be sent are updated to obtain the updated priorities of the multiple messages to be sent, and the current message to be sent is re-determined based on the updated priorities of the multiple messages to be sent.
[0010] In a possible implementation, the calculating based on the numbers corresponding to the multiple messages to be sent to obtain the priority of the message to be sent includes: Based on the numbers corresponding to the multiple messages to be sent, a number table corresponding to the messages to be sent is obtained, and based on the number table corresponding to the messages to be sent, calculation is performed to obtain the priority of the messages to be sent.
[0011] In a possible implementation, the calculating based on the number table corresponding to the message to be sent to obtain the priority of the message to be sent includes: The number table corresponding to the message to be sent is calculated based on the priority search algorithm to obtain the priority of the message to be sent.
[0012] In a possible implementation, the method further includes: Send the current message to be sent through the interrupt callback function.
[0013] On the other hand, the present invention also provides a CAN message processing device, comprising: The driver module is used to set a receiving ring buffer and a sending buffer in the driver layer of the controller, and number the sending buffer to obtain the numbered sending buffer; A storage module, used for storing the message in a receiving ring buffer when the driver layer receives the message; A reading module is used to read the message in the circular buffer, obtain multiple messages to be sent, and store the multiple messages to be sent in a numbered sending buffer, obtain the numbers corresponding to the multiple messages to be sent, calculate based on the numbers corresponding to the multiple messages to be sent, obtain the priorities of the multiple messages to be sent, and determine the current message to be sent and send it based on the priorities of the multiple messages to be sent.
[0014] On the other hand, the present invention also provides an electronic device, including a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in the CAN message processing method in any of the above implementations.
[0015] On the other hand, the present invention also provides a computer-readable storage medium for storing a computer-readable program or instruction, which, when executed by a processor, can implement the steps of the CAN message processing method described in any of the above-mentioned implementations.
[0016] The beneficial effects of the present invention are as follows: the CAN message processing method provided by the present invention comprises: setting a receiving circular buffer and a sending buffer in the driving layer of the controller, and numbering the sending buffer to obtain a numbered sending buffer; when the driving layer receives a message, storing the message in the receiving circular buffer, the purpose of which is to cache the message through the circular buffer, so as to avoid the message reception being overwritten; reading the message in the circular buffer to obtain a plurality of messages to be sent, and storing the plurality of messages to be sent in the numbered sending buffer, obtaining the numbers corresponding to the plurality of messages to be sent, calculating based on the numbers corresponding to the plurality of messages to be sent, obtaining the priorities of the plurality of messages to be sent, and determining the current message to be sent and sending it based on the priorities of the plurality of messages to be sent, the purpose of which is to obtain the highest priority by numbering the plurality of messages to be sent, and calculating the priorities of the plurality of numbered messages to be sent, and determining the current message to be sent based on the highest priority, so as to dynamically schedule the sending frequency of the CAN generator, so that high-priority messages can be sent in time. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 A flow chart of an embodiment of a method for processing CAN (Controller Area Network) messages provided by the present invention; Figure 2 A CAN data frame receiving data stream of an embodiment of the CAN message processing method provided by the present invention; Figure 3 A state diagram of the priority of messages to be sent according to an embodiment of the CAN message processing method provided by the present invention; Figure 4 A message sending flow chart of an embodiment of the CAN message processing method provided by the present invention; Figure 5 A schematic structural diagram of an embodiment of a CAN message processing device provided by the present invention; Figure 6 A schematic structural diagram of an embodiment of an electronic device provided by the present invention. DETAILED DESCRIPTION
[0019] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0020] In the description of the embodiments of the present application, unless otherwise specified, “plurality” means two or more than two.
[0021] The terms "including" and "having" and any variations thereof in the embodiments of the present invention are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product or equipment comprising a series of steps or modules is not necessarily limited to those steps or modules clearly listed, but may include other steps or modules not clearly listed or inherent to these processes, methods, products or equipment.
[0022] The naming or numbering of the steps in the embodiments of the present invention does not mean that the steps in the method flow must be executed in the time / logical sequence indicated by the naming or numbering. The execution order of the named or numbered process steps can be changed according to the technical purpose to be achieved, as long as the same or similar technical effects can be achieved.
[0023] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0024] It should be noted that: GW (Gate Way, gateway controller); MCU (Microcontroller Unit); MB (Mail box); TxMB (send mailbox); RxMB (Receive Mailbox).
[0025] The present invention provides a CAN message processing method, device, electronic device and storage medium, which are respectively described below.
[0026] Figure 1 A flow chart of an embodiment of a method for processing a CAN (Controller Area Network) message provided by the present invention includes: S101, setting a receiving ring buffer and a sending buffer in the driving layer of the controller, and numbering the sending buffer to obtain a numbered sending buffer; S102, when the driver layer receives the message, it stores the message in the receiving ring buffer; S103, read the message in the circular buffer to obtain multiple messages to be sent, and store the multiple messages to be sent in the numbered sending buffer to obtain the numbers corresponding to the multiple messages to be sent, calculate based on the numbers corresponding to the multiple messages to be sent, obtain the priorities of the multiple messages to be sent, and determine the current message to be sent and send it based on the priorities of the multiple messages to be sent.
[0027] It is understandable that, in view of the shortcomings of the existing domestic chip technology, the present invention makes corresponding design improvements to the message receiving and processing strategy and the sending and processing strategy.
[0028] At the receiving end, by imitating multiple RxMB schemes of foreign chips in the CAN driver layer and using virtual Buffer, it is ensured that all received messages can be received in the buffer, thus avoiding the phenomenon of message reception overwriting; At the sending end, by prioritizing and grouping the messages to be sent, a priority search algorithm is used to find the highest priority message to be sent, and the messages are sent using periodic triggering and send confirmation interrupt triggering. The CAN generator sending frequency is dynamically scheduled to maximize the use of the CAN transmitter.
[0029] It can be further understood that, by designing corresponding CAN message receiving and sending strategies on the software side when the hardware performance of domestic CAN controller chips is insufficient in this solution, the problems of message reception frame loss, poor message sending timeliness and message sending priority inversion that occur when using domestic chips are effectively solved.
[0030] It can be further understood that the present application is mainly about the message receiving and processing strategy when the RxMB is insufficient in the CAN controller; secondly, it is the priority processing when the CAN message is sent, and the highest priority message to be sent is found by table lookup to avoid internal sending priority inversion; finally, it is the CAN message sending method, which adopts the solution of application layer sending and message confirmation interrupt to trigger the sending of the next frame of CAN message.
[0031] Figure 2 A CAN data frame receiving data stream of an embodiment of the CAN message processing method provided by the present invention includes: An algorithm based on a circular linked list is designed to store messages in a receiving circular buffer.
[0032] It can be understood that a ring buffer is designed in the CAN driver-CanDrv layer to cache the message data frames received by the underlying CAN module; The size of the cache area can be set according to actual project requirements; The buffer adopts a circular linked list design algorithm to cache the message frames received from the bottom layer to the end of the chain; The upper application layer reads the message from the ring buffer chain head; The message is cached into the ring buffer during the CAN receive interrupt to ensure the timeliness of the message reception response; The application layer reads the message in the application program.
[0033] In a possible implementation, the method further includes: When the current message to be sent is not sent successfully, the sending time of the current message to be sent is obtained, and the sending time of the current message to be sent is matched with a preset time threshold. When the time of the current message to be sent is greater than the preset time threshold, the current message to be sent is discarded, and based on the priorities of multiple messages to be sent, the current message to be sent is re-determined.
[0034] It is understandable that for messages that have not been successfully sent for a long time in the CAN transmitter, long-time message sending confirmation and processing are required, which is specifically manifested in recording the fault, discarding the message and resetting the CAN transmitter to the idle state.
[0035] Figure 3 A state diagram of a priority level of a message to be sent according to an embodiment of the CAN message processing method provided by the present invention includes: The current message to be sent is discarded, and the priorities of the multiple messages to be sent are updated to obtain the updated priorities of the multiple messages to be sent, and the current message to be sent is re-determined based on the updated priorities of the multiple messages to be sent.
[0036] It can be understood that by addressing the insufficient hardware performance of domestic CAN controller chips in this solution and designing corresponding CAN message receiving and sending strategies on the software side, the problems of message reception frame loss, poor message sending timeliness and message sending priority inversion that occur when using domestic chips are effectively solved.
[0037] In a possible implementation, the priority of the message to be sent is obtained by calculating based on the numbers corresponding to the multiple messages to be sent, including: Based on the numbers corresponding to the multiple messages to be sent, a number table corresponding to the messages to be sent is obtained, and based on the number table corresponding to the messages to be sent, calculation is performed to obtain the priority of the messages to be sent.
[0038] It can be understood that the number table corresponding to the message to be sent is shown in Table 1: Table 1: Number table corresponding to the messages to be sent
[0039] It can be understood that, as shown in Table 1, a buffer is set at the application layer and the buffer is numbered, and when the application is running, the processed messages to be sent are cached in the buffer; There is a one-to-one correspondence between the messages to be sent and the buffers, that is, one buffer is associated with a specific frame of messages to be sent; The lower the buffer number, the higher the corresponding message priority; In this project, the number range is 0-63, and there are 64 messages that need to be sent. When the number of messages to be sent is greater than 64, the buffer needs to be expanded according to this solution.
[0040] It can be further understood that if Figure 3 As shown in the figure, it is the status table of the message to be sent: When there are messages to be sent in the sending buffer, its corresponding status table needs to be updated and displayed, where RdyTbl[] has a one-to-one correspondence with the buffer in Table 1; In the present invention, 64 sending buffer numbers are evenly grouped into 8 groups, represented by RdyGrp; each group contains 8 data, corresponding to 8 data frames in the buffer; When there is a message to be sent, it is first stored in the corresponding buffer in Table 1, and the association relationship of the remaining message status tables to be sent is calculated by its buffer number. The calculation method is as follows: First, obtain the message buffer ID; Calculate the X and Y values in the corresponding message status table to be sent according to the message ID, that is: Y=ID / 8; X =ID %8; According to the message sending priority ID, calculate its RdyGrp=RdyGrp|| (1< <Y); According to the message sending priority ID, calculate its RdyTbl[Y]=RdyTbl[Y]||(1< <X); As long as there is a data frame to be sent in any group, its corresponding group status bit is 1, and the corresponding RdyGrp corresponding status bit is 1; For example, when RdyGrp=0x00000100, it means that there is data to be sent in group 2; When the message corresponding to the buffer is sent, the corresponding RdyGrp and RdyTbl[] in the status table need to be updated synchronously.
[0041] In a possible implementation, the priority of the message to be sent is obtained by performing calculation based on the number table corresponding to the message to be sent, including: The number table corresponding to the message to be sent is calculated based on the priority search algorithm to obtain the priority of the message to be sent.
[0042] It can be understood that the following is the program running process of searching for numbered messages to be sent based on the priority search algorithm:
[0043] It can be further understood that, through the OSUMapTbl[] table, it is found out in which group the highest priority message to be sent is located, that is, Y= OSUMapTbl[RdyGrp]; Through the OSUMapTbl[] table, find out which position of the Y group the highest priority message currently to be sent is in, that is, X = OSUMapTbl[RdyGrp[Y]]; Combined with X and Y, the buffer location where the message to be sent is stored is calculated, which is the message with the highest priority among all the messages currently to be sent.
[0044] Figure 4 A message sending flow chart of an embodiment of the CAN message processing method provided by the present invention includes: Send the current message to be sent through the interrupt callback function.
[0045] It is understandable that if Figure 4 As shown in the figure, it is the message sending flow chart: Message sending can be actively initiated by the application, that is, the application directly stores the message in the CAN controller transmitter and activates the sending; The message sending can also be triggered by the CAN send interrupt callback function; For messages that have not been successfully sent for a long time in the CAN generator, it is necessary to confirm and process the message sending for a long time, which is specifically manifested in recording the fault, discarding the message and resetting the CAN transmitter to the idle state.
[0046] It can be further understood that the present application adopts periodic triggering and sending confirmation interrupt triggering to send messages, and dynamically schedules the sending frequency of the CAN generator to achieve the purpose of maximizing the use of the CAN transmitter.
[0047] Figure 5 A schematic structural diagram of an embodiment of a CAN message processing device provided by the present invention includes: The driving module 501 is used to set a receiving ring buffer and a sending buffer in the driving layer of the controller, and number the sending buffer to obtain a numbered sending buffer; The storage module 502 is used to store the message in the receiving ring buffer when the driver layer receives the message; The reading module 503 is used to read the message in the circular buffer, obtain multiple messages to be sent, and store the multiple messages to be sent in the numbered sending buffer, obtain the numbers corresponding to the multiple messages to be sent, calculate based on the numbers corresponding to the multiple messages to be sent, obtain the priorities of the multiple messages to be sent, and determine the current message to be sent and send it based on the priorities of the multiple messages to be sent. The CAN message processing device 500 provided in the above embodiment can implement the technical solution described in the above CAN message processing method embodiment. The specific implementation principles of the above modules or units can refer to the corresponding content in the above CAN message processing method embodiment, which will not be repeated here.
[0048] like Figure 6 As shown, the present invention also provides an electronic device 600. The electronic device 600 includes a processor 601, a memory 602 and a display 603. Figure 6 Only some components of the electronic device 600 are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0049] In some embodiments, the processor 601 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run program codes or process data stored in the memory 602, such as the CAN message processing method of the present invention.
[0050] In some embodiments, the processor 601 may be a single server or a server group. The server group may be centralized or distributed. In some embodiments, the processor 601 may be local or remote. In some embodiments, the processor 601 may be implemented in a cloud platform. In one embodiment, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, an internal cloud, a multi-cloud, etc., or any combination thereof.
[0051] In some embodiments, the memory 602 may be an internal storage unit of the electronic device 600, such as a hard disk or memory of the electronic device 600. In other embodiments, the memory 602 may also be an external storage device of the electronic device 600, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., equipped on the electronic device 600.
[0052] Furthermore, the memory 602 may include both an internal storage unit of the electronic device 600 and an external storage device. The memory 602 is used to store application software installed in the electronic device 600 and various data.
[0053] In some embodiments, the display 603 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 603 is used to display information on the electronic device 600 and to display a visual user interface. The components 601-603 of the electronic device 600 communicate with each other via a system bus.
[0054] In one embodiment, when the processor 601 executes the CAN message processing program in the memory 602, the following steps may be implemented: A receiving ring buffer and a sending buffer are set in the driver layer of the controller, and the sending buffer is numbered to obtain a numbered sending buffer; When the driver layer receives a message, it stores the message in the receiving ring buffer; Read the message in the circular buffer to obtain multiple messages to be sent, and store the multiple messages to be sent in the numbered sending buffer to obtain the numbers corresponding to the multiple messages to be sent, calculate based on the numbers corresponding to the multiple messages to be sent, obtain the priorities of the multiple messages to be sent, and determine the current message to be sent and send it based on the priorities of the multiple messages to be sent.
[0055] It should be understood that: when the processor 601 executes the CAN message processing program in the memory 602, in addition to the above functions, other functions can also be implemented. For details, please refer to the description of the corresponding method embodiment above.
[0056] Furthermore, the embodiment of the present invention does not specifically limit the type of the electronic device 600 mentioned, and the electronic device 600 may be a portable electronic device such as a mobile phone, a tablet computer, a personal digital assistant (PDA), a wearable device, a laptop computer, etc. Exemplary embodiments of portable electronic devices include but are not limited to portable electronic devices equipped with IOS, Android, Microsoft or other operating systems. The above-mentioned portable electronic devices may also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments of the present invention, the electronic device 600 may not be a portable electronic device, but a desktop computer with a touch-sensitive surface (e.g., a touch panel).
[0057] Accordingly, an embodiment of the present application also provides a computer-readable storage medium, which is used to store computer-readable programs or instructions. When the program or instructions are executed by a processor, the steps or functions in the CAN message processing method provided in the above-mentioned method embodiments can be implemented.
[0058] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the computer program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0059] The CAN message processing method, device, electronic device and storage medium provided by the present invention are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A CAN message processing method, It is characterized in that include: A receiving ring buffer and a sending buffer are set in the driver layer of the controller, and the sending buffer is numbered to obtain a numbered sending buffer; When the driver layer receives a message, it stores the message in the receiving ring buffer; Read the message in the circular buffer to obtain multiple messages to be sent, and store the multiple messages to be sent in the numbered sending buffer to obtain the numbers corresponding to the multiple messages to be sent, calculate based on the numbers corresponding to the multiple messages to be sent, obtain the priorities of the multiple messages to be sent, and determine the current message to be sent and send it based on the priorities of the multiple messages to be sent.
2. The CAN message processing method according to claim 1, It is characterized in that The storing of the message into the receiving ring buffer comprises: An algorithm based on a circular linked list is designed to store messages in a receiving circular buffer.
3. The CAN message processing method according to claim 1, It is characterized in that The method further comprises: When the current message to be sent is not sent successfully, the sending time of the current message to be sent is obtained, and the sending time of the current message to be sent is matched with a preset time threshold. When the time of the current message to be sent is greater than the preset time threshold, the current message to be sent is discarded, and based on the priorities of multiple messages to be sent, the current message to be sent is re-determined.
4. The CAN message processing method according to claim 3, It is characterized in that The step of discarding the current message to be sent and re-determining the current message to be sent based on the priorities of the multiple messages to be sent includes: The current message to be sent is discarded, and the priorities of the multiple messages to be sent are updated to obtain the updated priorities of the multiple messages to be sent, and the current message to be sent is re-determined based on the updated priorities of the multiple messages to be sent.
5. The CAN message processing method according to claim 1, It is characterized in that The calculating based on the numbers corresponding to the multiple messages to be sent to obtain the priority of the message to be sent includes: Based on the numbers corresponding to the multiple messages to be sent, a number table corresponding to the messages to be sent is obtained, and based on the number table corresponding to the messages to be sent, calculation is performed to obtain the priority of the messages to be sent.
6. The CAN message processing method according to claim 5, It is characterized in that The calculation based on the number table corresponding to the message to be sent to obtain the priority of the message to be sent includes: The number table corresponding to the message to be sent is calculated based on the priority search algorithm to obtain the priority of the message to be sent.
7. The CAN message processing method according to claim 1, It is characterized in that The method further comprises: Send the current message to be sent through the interrupt callback function.
8. A CAN message processing device, It is characterized in that include: The driver module is used to set a receiving ring buffer and a sending buffer in the driver layer of the controller, and number the sending buffer to obtain the numbered sending buffer; A storage module, used for storing the message in a receiving ring buffer when the driver layer receives the message; A reading module is used to read the message in the circular buffer, obtain multiple messages to be sent, and store the multiple messages to be sent in a numbered sending buffer, obtain the numbers corresponding to the multiple messages to be sent, calculate based on the numbers corresponding to the multiple messages to be sent, obtain the priorities of the multiple messages to be sent, and determine the current message to be sent and send it based on the priorities of the multiple messages to be sent.
9. An electronic device, It is characterized in that comprising a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in the CAN message processing method as described in any one of claims 1 to 7 above.
10. A computer-readable storage medium, It is characterized in that Used to store computer-readable programs or instructions, which, when executed by a processor, can implement the steps of the CAN message processing method described in any one of claims 1 to 7.
Citation Information
Cited By
Sliding window protocol data receiving and recombining method and device based on CAN bus
CN120956675A
