Data transmission control method, electronic equipment and storage medium
By introducing transmission control module and queue management mechanism into CAN nodes, data conflict and congestion problems in the CAN bus network are solved, bus utilization and data transmission efficiency are improved, and memory requirements are reduced.
Patent Information
- Application Number
- CN202410127103.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-29
- Publication Date
- 2025-07-29
AI Technical Summary
In CAN bus networks, data conflicts and congestion problems lead to reduced network reliability, increased data latency, and existing solutions increase memory requirements or reduce transmission efficiency.
By introducing a transmission control module into the CAN node, setting the sending queue and receiving queue, controlling the retransmission process, reducing the use of the bus, and managing signal frame transmission using priority and timeout mechanisms.
It improves the utilization rate of the CAN bus, reduces data conflicts, reduces memory requirements, and ensures the reliability and efficiency of data transmission.
Smart Images

Figure CN120389836A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communications, and particularly to a data transmission control method, an electronic device, and a computer-readable storage medium under the CAN protocol. Background Art
[0002] In a typical fire control system, Controller Area Network (CAN for short) is a common way for communication between fire alarm control devices. In a CAN network, there can be up to 64 fire alarm control devices at most. Each fire alarm control device can send events to other fire alarm control devices through the CAN bus. In some cases, multiple fire alarm control devices may send multiple events at the same time. The CAN bus adopts a non-preemptive medium access control method, that is, each fire alarm control device has an equal opportunity to send events without assigning priorities. This may lead to data conflicts and congestion, especially in high-traffic situations.
[0003] When a fire alarm control device has a transmission failure, the fire alarm control device will re-send the event until the event is successfully received. However, this retransmission request may cause the following problems:
[0004] Network congestion: When multiple fire alarm control devices transmit events simultaneously, conflicts may occur. If each fire alarm control device uses a retransmission request to resolve the conflict, this will cause all the fire alarm control devices in the network to continuously retry sending, resulting in network congestion;
[0005] Data delay: Each retransmission request will increase the data transmission time. Especially in long-distance transmission or high-load networks, the data delay may become very serious;
[0006] Reduced reliability: If the retransmission request is not correctly implemented or configured, it may lead to data transmission failure or errors. In addition, if the retransmission request does not limit the number of retries or the interval, it may cause infinite retransmission of data, thus reducing the reliability of the network;
[0007] Communication failure: If the fire alarm control devices in the network cannot correctly handle the retransmission request, it may lead to communication failure or network interruption. For example, if a fire alarm control device does not correctly respond to the data request from other fire alarm control devices during the retransmission request, it may cause the communication link to be interrupted or the network to be paralyzed.
[0008] To solve this problem, there are the following common methods:
[0009] (1) Keep waiting, and after receiving responses from other nodes, send the next signal frame. This solution will greatly reduce the data transmission efficiency.
[0010] (2) Add a transmission buffer at the CAN controller driver level, for example, increase the length of the send queue in the Linux CAN driver. In cases of severe conflicts, the device will still prompt "no available buffer space". In addition, this solution will significantly increase the memory requirements. Summary of the Invention
[0011] The object of the present invention is to propose a data transmission control method, which can reduce the occupancy of the CAN node on the bus due to retransmitting signal frames when data conflicts occur on the bus, improve the utilization rate of the bus, thereby avoiding congestion, and has a relatively small memory requirement.
[0012] The present invention provides a data transmission control method, which is applied to a CAN node on a CAN bus. There is an application module, a transmission control module, and a CAN driver module in the CAN node. There is a send queue in the transmission control module, and the send queue is used to cache signal frames sent by the application module. The data transmission control method includes:
[0013] Broadcast and send frames to the CAN bus through the CAN driver module, and the send frames are periodically obtained from the send queue;
[0014] Obtain a receive frame from the CAN driver module, and the CAN driver module can obtain signals from the CAN bus;
[0015] Judge whether the receive frame is sent by the CAN node itself. If so, remove the signal frame consistent with the receive frame from the send queue. If not, send the receive frame to the application module.
[0016] The data transmission control method of the present invention performs retransmission control by the transmission control module, rather than by the CAN driver module. When data conflicts occur on the bus, this method can reduce the occupancy of the CAN node on the bus to alleviate / solve the data conflict problem, thereby ensuring that the data stream on the CAN bus is well controlled.
[0017] In another exemplary embodiment of the data transmission control method of the present invention, the send frame is one or more signal frames with the highest priority in the send queue, or the send frame is one or more signal frames cached earliest in the send queue.
[0018] In yet another exemplary embodiment of the data transmission control method of the present invention, the CAN driver module includes a CAN transceiver unit and a CAN control unit. The CAN transceiver unit is used to convert digital signals and physical signals on the CAN bus. The CAN control unit is configured to be able to receive, through the CAN transceiver unit, signal frames broadcast by the CAN node itself to other CAN nodes and signal frames broadcast by other CAN nodes to the CAN node from the CAN bus.
[0019] In yet another exemplary embodiment of the data transmission control method of the present invention, the data transmission control method further includes obtaining a signal frame sent by the application module; caching the signal frame in the sending queue.
[0020] In yet another exemplary embodiment of the data transmission control method of the present invention, before determining whether the received frame is sent by the CAN node itself, it further includes: determining whether the received frame is an error frame, and if so, sending the error frame to the application module and obtaining a new signal frame from the CAN bus; if not, identifying the identifier of the received frame to determine the sending node of the received frame.
[0021] In yet another exemplary embodiment of the data transmission control method of the present invention, before the step of removing the signal frame that is consistent with the received frame, it specifically includes: comparing the received frame with the signal frames in the sending queue, and if there is no consistent signal frame, discarding the received frame; if there is a consistent signal frame, entering the removal step. The present invention can ensure the correct transmission of data packets and avoid data error problems occurring during the transmission process.
[0022] In yet another exemplary embodiment of the data transmission control method of the present invention, a receiving queue is further provided in the transmission control module. The step of sending the received frame to the application module includes: caching the received frame in the receiving queue; sending the received frame to the application module through the receiving queue. By setting up a receiving queue to cache received frames, it is convenient for each application in the application module to obtain corresponding received frames through the receiving queue to support parallel processes and improve the processing or response speed of the CAN node for relevant data.
[0023] In another illustrative embodiment of the data transmission control method of the present invention, the data transmission control method further includes: when it is detected that the number of transmissions or the transmission time of the sending frame exceeds a threshold, removing the sending frame from the sending queue and reporting a transmission failure to the application module. To avoid transmission stagnation caused by the failure of the current sending frame, this solution sets a threshold. When the number of transmissions or the transmission time exceeds the threshold, the transmission of the current frame is terminated in a timely manner, and the transmission of the next frame is entered, thereby improving the efficiency of data transmission.
[0024] The present invention also provides an electronic device, which can be connected to a bus as a CAN node and includes an application module and a CAN driver module. It is characterized in that the electronic device further includes a transmission control module, and the transmission control module includes:
[0025] A sending queue;
[0026] A sending unit, which is used to broadcast and send frames to the bus through the CAN driver module, and the sending frames are periodically obtained from the sending queue;
[0027] A receiving unit, which is used to obtain a received frame from the CAN driver module, and the CAN driver module can obtain signals from the bus;
[0028] A judging unit, which is used to judge whether the received frame is sent by the CAN node itself. And when the result is yes, removing the signal frame consistent with the received frame from the sending queue, and when the result is no, sending the received frame to the application module. The retransmission control of the electronic device of the present invention is performed by the transmission control module, rather than by the CAN driver module. When data conflicts occur on the bus, this method can reduce the occupancy of the bus by the CAN node to reduce data conflicts, thereby ensuring good control of the data flow on the CAN bus.
[0029] In another illustrative embodiment of the electronic device of the present invention, the sending frame is one or more signal frames with the highest priority in the sending queue, or one or more signal frames cached earliest in the sending queue.
[0030] In still another illustrative embodiment of the electronic device of the present invention, the CAN driver module includes a CAN transceiver unit and a CAN control unit. The CAN transceiver unit is used to convert digital signals and physical signals on the bus. The CAN control unit is configured to be able to receive, through the CAN transceiver unit, signal frames broadcast by the CAN node itself to other CAN nodes and signal frames broadcast by other CAN nodes to the CAN node from the bus.
[0031] In yet another illustrative embodiment of the electronic device of the present invention, the transmission control module further includes: a first buffer unit, which is configured to obtain a signal frame to be sent from the application module and buffer the signal frame in the send queue.
[0032] In yet another illustrative embodiment of the electronic device of the present invention, the transmission control module further includes: an error frame identification unit, which is configured to obtain the received frame from the receiving unit and determine whether the received frame is an error frame. When the received frame is an error frame, it is further configured to send the error frame to the application module. When the received frame is a normal frame, it is further configured to send the received frame to the judgment unit.
[0033] In yet another illustrative embodiment of the electronic device of the present invention, the judgment unit further includes: an elimination subunit, which is configured to compare the received frame with the signal frames in the send queue. When there is no consistent signal frame, it is further configured to discard the received frame. When there is a consistent signal frame, it is further configured to delete the consistent signal frame. The present invention can ensure the correct transmission of data packets and avoid data error problems occurring during the transmission process.
[0034] In yet another illustrative embodiment of the electronic device of the present invention, the transmission control module further includes a receive queue and a second buffer unit. The second buffer unit is configured to buffer the received frame received from the judgment unit in the receive queue and send the received frame to the application module through the receive queue; the judgment unit sends the received frame to the application module through the second buffer unit. By setting up a receive queue to buffer the received frames, it is convenient for each application in the application module to obtain the corresponding received frames through the receive queue to support parallel processes and improve the processing or response speed of the CAN node for relevant data.
[0035] In yet another illustrative embodiment of the electronic device of the present invention, the transmission control module further includes: an interrupt unit, which is configured to determine whether the number of transmissions or the transmission time of the send frame exceeds a threshold, and when it exceeds the threshold, remove the send frame from the send queue and report a transmission failure to the application module. To avoid transmission stagnation caused by the failure of the current send frame, this solution sets a threshold and, when the number of transmissions or the transmission time exceeds the threshold, promptly aborts the transmission of the current frame and proceeds to the transmission of the next frame, thereby improving the efficiency of data transmission.
[0036] The present invention also provides a computer-readable storage medium storing instructions for implementing any one of the above-described data transmission control methods. In this solution, the retransmission control is performed by the transmission control module instead of the CAN driver module. When data conflicts occur on the bus, this method can reduce the occupancy of the CAN nodes on the bus to mitigate the data conflicts, thereby ensuring good control of the data stream on the CAN bus. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The following drawings are only schematic illustrations and explanations of the present invention and do not limit the scope of the present invention.
[0038] Figure 1 FIG. is a schematic diagram for illustrating the electronic device of the present invention.
[0039] Figure 2 FIG. is a schematic diagram for illustrating the data transmission control method of the present invention.
[0040] Figure 3 FIG. is another schematic diagram for illustrating the data transmission control method of the present invention.
[0041] Figure 4 FIG. is a flowchart for illustrating the electronic device of the present invention.
[0042] Figure 5 For illustrating Figure 1 a schematic diagram of the transmission control module in
[0043] Among them, the reference numerals are as follows:
[0044] 100, 200, N00 CAN nodes
[0045] 101 Application module
[0046] 102 Transmission control module
[0047] 1021 Sending unit
[0048] 1022 Receiving unit
[0049] 1023 Judgment unit
[0050] 103 CAN driver module
[0051] 1031 CAN control unit
[0052] 1032 CAN transceiver unit DETAILED DESCRIPTION OF THE EMBODIMENTS
[0053] For a clearer understanding of the technical features, objectives, and effects of the present invention, the specific embodiments of the present invention will now be described with reference to the accompanying drawings. In the drawings, the same reference numerals denote components having the same or similar structures but the same functions.
[0054] In this document, "schematic" means "serving as an example, instance, or illustration". Any illustration or embodiment described as "schematic" in this document should not be construed as a more preferred or advantageous technical solution.
[0055] To simplify the drawings, only the parts related to the present invention are schematically shown in each figure, and they do not represent the actual structure of the product as a whole. Additionally, for the sake of simplicity and easy understanding of the drawings, in some figures, only one of the components having the same structure or function is schematically shown, or only one of them is labeled.
[0056] In this document, "one" not only means "only this one", but also can mean "more than one" situation. In this document, "first", "second", etc. are only used for distinguishing from each other, rather than indicating their importance level, order, etc.
[0057] Figure 1 It is a schematic diagram for illustrating the electronic device of the present invention. Figure 1 A CAN network is shown in the figure. A plurality of CAN nodes (100, 200,..., N00) are connected to the CAN bus, and each CAN node is an electronic device supporting the CAN protocol. In the field of fire control, the electronic device can be a fire alarm control device (Control Panel). Taking CAN node 100 as an example, it includes an application module 101, a transmission control module 102, and a CAN driver module 103.
[0058] Among them, the application module 101 is an application program at the application layer of the CAN protocol. Taking the field of fire control as an example, the application module 101 is a fire alarm application program of the fire alarm control device (Control Panel). For other instrument control systems, the application module 101 is an application program for testing, controlling, etc. of the instrument control device.
[0059] The CAN driver module 103 is the software and hardware at the driver layer of the CAN protocol. The CAN transceiver unit 1032 can be implemented by using an existing independent CAN transceiver chip, or can be implemented by using a chip integrating the CAN transceiver unit and other functional modules. The CAN driver module 103 includes a CAN transceiver unit 1032 and a CAN control unit 1031. The CAN transceiver unit 1032 is used to convert the digital signal of the CAN control unit 1031 and the physical signal on the CAN bus.
[0060] Taking the field of fire control as an example, the fire alarm application program of the application module 101 determines that a fire event has occurred currently and needs to report this fire event to other fire alarm control devices. In the prior art, the application module 101 directly sends a signal frame indicating the event to the CAN driver module 103 and sends it to other fire alarm control devices through the CAN driver module 103. If other fire alarm control devices are broadcasting information at this time, data conflicts may occur, and the driver layer will continuously attempt to retransmit until the transmission is successful. Since the transmission tasks of the driver layers of each fire alarm control device are constantly occupying the bus, this will further exacerbate the data conflicts. The electronic device 100 of the present invention sets a transmission control module 102 between the application module 101 and the CAN driver module 103 to control the retransmission request. Specifically, the application module 101 first sends a signal frame indicating the event to the transmission control module 102, and the transmission control module 102 controls the CAN driver module 103 to send the signal frame to other fire alarm control devices. After sending the signal frame, if the transmission control module 102 monitors its own sent signal frame from the bus through the CAN driver module 103, it enters the transmission of the next frame in its transmission queue; otherwise, it continues to retransmit the current transmission frame through the CAN driver module 103. In this way, since the CAN driver module 103 itself is not responsible for retransmission control, for it, each transmission is a successful transmission, which reduces the occupancy of the bus by the CAN node during the transmission process and can alleviate / solve the conflict. In addition, timeout control can be set in the transmission control module 102. The timeout control can timely interrupt the current timed-out retransmission task and report it to the application layer for processing, and the transmission control module 102 can continue to send the next frame in its transmission queue, thereby further improving the transmission efficiency of the signal frame. The data transmission control method proposed by the present invention can be applied to the transmission control module 102 of the electronic device 100. The data transmission control method and the electronic device proposed by the present invention will be described below.
[0061] Figure 2 FIG. for illustrating the data transmission control method of the present invention. This data transmission control method is applied to a CAN node on a CAN bus, for example, it can be applied to Figure 1 the fire alarm control device 100 shown in. A application module 101, a transmission control module 102, and a CAN driver module 103 are provided in this CAN node. A transmission queue is set in the transmission control module 102, and the transmission queue is used to cache the signal frames sent by the application module 101. This data transmission control method includes:
[0062] S101: Broadcast and send a frame to the bus through the CAN driver module, and the send frame is obtained from the send queue periodically;
[0063] S102: Obtain a received frame from the CAN driver module, which can obtain signals from the bus;
[0064] S103: Determine whether the received frame is sent by the CAN node itself. If so, remove the signal frame that is the same as the received frame from the send queue. If not, send the received frame to the application module.
[0065] Figure 2 The data transmission control method shown is for retransmission control by the transmission control module, rather than by the CAN driver module. When data conflicts occur on the bus, this method can reduce the occupancy of the bus by CAN nodes to alleviate data conflicts, thereby ensuring good control of the data stream on the CAN bus. In addition, while sending signal frames, this data transmission control method can also receive signal frames sent by other CAN nodes in a timely manner for timely processing / response.
[0066] To transmit high-priority events in a timely manner, the sent frame broadcast in step S101 can use the signal frame with the highest priority in the send queue. For events with the same priority, the sent frame broadcast in step S101 can use the signal frame that was cached earliest in the send queue. When a CAN node can only send one signal frame at a time, the sent frame in S101 can be a signal frame in the send queue; when a CAN node can send multiple signal frames at a time, the sent frame in S101 can be multiple signal frames in the send queue. The "multiple" mentioned in this article includes a quantity of two or more. Correspondingly, for the "same" in "remove the signal frame that is the same as the received frame from the send queue" mentioned in step S103, it can be to determine whether the content transmitted by the two is the same, or to use the same judgment rule as the sent frame. For example, when the sent frame uses "the signal frame with the highest priority in the send queue", the signal frame that is the same as the received frame is the "signal frame with the highest priority in the send queue"; when the sent frame uses "the signal frame that was cached earliest in the send queue", the signal frame that is the same as the received frame is the "signal frame that was cached earliest in the send queue". And for "determine whether the content transmitted by the two is the same", it can be achieved by comparing whether their sequence numbers are the same, or by comparing whether their specific data contents are the same.
[0067] Figure 3 Another schematic diagram for explaining the data transmission control method of the present invention. In the figure, A, B, and C respectively represent the application module, the transmission control module, and the CAN driver module. Among them, the application module and the transmission control module belong to the application layer, and the transmission control module belongs to the driver layer. A send queue is set in the transmission control module. This data transmission control method includes:
[0068] S31: Obtain the signal frame sent by the application module and cache the signal frame in the sending queue.
[0069] S32: The sending task periodically obtains the signal frame from the sending queue, and then broadcasts the signal frame to the bus through the CAN driver module.
[0070] S33: Obtain a received frame from the CAN driver module, and the CAN driver module can obtain signals from the bus.
[0071] S34: Determine whether the received frame is an error frame or a normal frame. If it is an error frame, go to step S34a; if it is a normal frame, further identify the sending node of the normal frame. If it is sent by the CAN node itself, go to step S34b; if it is sent by other CAN nodes, send the received frame to the application module so that the application module can receive signals from other nodes in time and process / respond in time.
[0072] S34a: Send the error frame to the application module and obtain a new signal frame from the bus. Thus, the application module can process or respond to relevant error information in time according to the error frame.
[0073] S34b: Remove the signal frame that is the same as the received frame from the sending queue; after removing the identical signal frame, the sending task will send other signal frames in the sending queue according to a preset rule. For example, the sending task will send the signal frame with the highest priority among the remaining signal frames in the sending queue, or the sending task will send the signal frame that was cached first among the remaining signal frames in the sending queue.
[0074] In order to support parallel processes and improve the processing / response speed of the CAN node for relevant data, a receiving queue can be further set in the transmission control module. Accordingly, the "send the received frame to the application module" in step S34 above can be further refined to include S34c and S35. Among them, S34c: Cache the received frame in the receiving queue; S35: Send the received frame to the application module through the receiving queue.
[0075] In order to enable the transmission control module to obtain the signal frames sent by the CAN node itself, it can be achieved by configuring the CAN control unit in the CAN driver module. Specifically, the CAN control unit can be configured to be able to receive, through the CAN transceiver unit, the signal frames broadcast by the CAN node itself to other CAN nodes and the signal frames broadcast by other CAN nodes to the CAN node from the bus. Preferably, the judgment steps in S34 can be in the following order: First, judge whether the received frame is an error frame or a normal frame. If it is a normal frame, then further judge whether the received frame is sent by the CAN node itself. Thereby, the working efficiency in step S34 can be improved. For the identification of the sending node, it can be achieved by analyzing the identifier in the received frame.
[0076] Figure 4 A flowchart for illustrating an electronic device of the present invention is as follows. The following is combined with Figure 4 to illustrate a specific embodiment of the data transmission control method of the present invention.
[0077] S401: Obtain the signal frame sent by the application module and cache the signal frame in the sending queue.
[0078] S402: Broadcast and send the sending frame to the bus through the CAN driver module, and the sending frame is obtained from the sending queue periodically;
[0079] S403: Receive a received frame from the CAN driver module, and the CAN driver module can obtain signals from the bus;
[0080] S404: Judge whether the received frame is an error frame. If so, enter step S405; if not, enter step S406.
[0081] S405: Send the error frame to the application module and obtain a new signal frame from the bus.
[0082] S406: Identify the identifier of the received frame to determine the sending node of the received frame, and judge whether the received frame is sent by this CAN node itself. If so, enter step S409; if not, enter step S407.
[0083] S407: Cache the received frame in the receiving queue.
[0084] S408: Send the received frame to the application module through the receiving queue.
[0085] S409: Compare the received frame with the signal frames in the sending queue to judge whether there are consistent signal frames. If not, enter step S411; if so, enter the removal step. By setting step S409 to compare whether there are content-consistent signal frames, it can be ensured that the signal frames to be deleted have been successfully and correctly sent, improving the reliability of transmission.
[0086] S410: Remove the signal frame that is consistent with the received frame from the transmission queue.
[0087] S411: Discard the received frame.
[0088] In the above process, only after the current transmission frame is successfully sent will the next signal frame be sent. However, if the current transmission frame fails to be sent all the time, the signal frame that is consistent with this transmission frame will always exist in the transmission queue. This will cause this CAN node to be unable to continue broadcasting other signal frames to the bus. Therefore, an interruption step can be added to the above process. For example, when it is detected that the number of transmission attempts or the transmission time of the current transmission frame exceeds the threshold, remove this transmission frame from the transmission queue and report the transmission failure to the application module.
[0089] Figure 5 For illustration Figure 1 a schematic diagram of the transmission control module in Figure 1 shows an implementation manner of the transmission control module 102 in
[0090] After the transmission control module 102 obtains the signal frame to be transmitted from the application module 101, it can control the data transmission process, reduce the occupation of the bus during the transmission process, and solve the transmission problems caused by data conflicts. The transmission unit 1021 and the receiving unit 1022 of the transmission control module 102 are connected to the CAN driver module 103. Among them, the transmission unit 1021 can periodically obtain the transmission frame from the transmission queue and broadcast this transmission frame to the bus through the CAN driver module 103. Specifically, the transmission unit 1021 can read one or more signal frames with the highest priority in the transmission queue and use them as the transmission frame to provide to the CAN driver module; the transmission unit 1021 can also read one or more signal frames cached first in the transmission queue and use them as the transmission frame to provide to the CAN driver module. The receiving unit 1022 can obtain a received frame sent by the CAN driver module. The CAN driver module can obtain signals from the bus.
[0091] The judgment unit 1023 is connected to the transmission unit 1021 and the receiving unit 1022 and is used to specifically control the data transmission process. The judgment unit 1023 can judge whether the received frame received by the receiving unit 1022 is sent by this CAN node itself. If it is sent by this node itself, the judgment unit 1023 removes the signal frame that is consistent with this received frame from the transmission queue. If this received frame is sent by other CAN nodes, the judgment unit 1023 sends the received frame to the application module 101 so that the application module 101 can process / respond to this received frame in a timely manner.
[0092] In order to enable the receiving unit 1022 of the transmission control module 102 to obtain the signal frame broadcast by the current CAN node itself to the CAN bus from the CAN driver module 103, Figure 1 the CAN driver module 103 in
[0093] may adopt the following structure:
[0094] A first buffer unit is further provided in the transmission control module 102. The first buffer unit is connected to the application module 101, can obtain the signal frame to be sent from the application module 101, and cache the signal frame in the send queue. In addition, the transmission control module may further include a receive queue, and a second buffer unit is correspondingly provided. The second buffer unit is used to cache the received frame that needs to be sent to the application module in the receive queue, and send the received frame to the application module through the receive queue.
[0095] The CAN protocol also involves error frames, such as error frames for indicating bus break, error frames for indicating CRC check error, error frames for indicating too many retransmission times, etc. The CAN driver module 103 needs to report such error frames to the application module 101. Therefore, the transmission control module 102 of the present invention also needs to timely identify and report the error frames reported by the CAN driver module 103. Correspondingly, the transmission control module 102 may further be provided with an error frame identification unit. The error frame identification unit is arranged between the judgment unit 1023 and the receiving unit 1022. After the CAN driver module 103 sends a signal frame to the receiving unit 1022 of the transmission control module 102, the error frame identification unit first judges whether the received frame is an error frame. If it is an error frame, the error frame is sent to the application module. If it is not an error frame (i.e., a normal frame), it is then sent to the judgment unit 1023.
[0096] During data transmission, signal frames may be in error. Therefore, before deleting a signal frame from the transmission queue, it is advisable to first determine whether the signal frame to be deleted is consistent with the content of the current received frame. If they are consistent, the signal frame is deleted; if not, the signal frame is resent. Specifically, a rejection subunit may be further provided in the determination unit 1023. The rejection subunit is used to compare the content of the received frame with the content of the signal frames in the transmission queue, and discard the received frame when there is no consistent signal frame, and delete the consistent signal frame when there is a consistent signal frame.
[0097] If the determination unit 1023 determines that the current transmission frame is successfully transmitted, this electronic device will continue to transmit the next signal frame. However, if the transmission frame has been unsuccessfully transmitted, then the signal frames consistent with the transmission frame will always exist in the transmission queue, resulting in the CAN node being unable to continue broadcasting other signal frames to the bus. Therefore, an interrupt unit may be further provided in the transmission control module 102. The interrupt unit is used to determine whether the number of transmissions or the transmission time of the transmission frame exceeds a threshold, and when the threshold is exceeded, remove the transmission frame from the transmission queue and report the transmission failure to the application module.
[0098] The present invention also provides a computer-readable storage medium, on which computer program running instructions are stored. When the computer program running instructions are executed by a processor, each step in any of the above data transmission control methods is implemented.
[0099] Some aspects of the method and apparatus of the present invention can be fully executed by hardware, can be fully executed by software (including firmware, resident software, microcode, etc.), or can be executed by a combination of hardware and software. The above hardware or software can all be referred to as "data blocks", "modules", "engines", "units", "components" or "systems". The processor can be one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DAPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), processors, controllers, microcontrollers, microprocessors or combinations thereof. In addition, aspects of the present invention may be embodied as a computer product located in one or more computer-readable media, the product including computer-readable program code. For example, the computer-readable media may include, but are not limited to, magnetic storage devices (such as hard disks, floppy disks, magnetic tapes...), optical discs (such as compact discs (CDs), digital versatile discs (DVDs)...), smart cards, and flash memory devices (such as cards, sticks, key drives...). Optionally, the program code may also be downloaded from a server computer via a communication network.
[0100] The advantages of the data transmission control method, electronic device, and computer-readable storage medium proposed by the present invention are basically corresponding to the advantages of the data transmission control method proposed by the present invention. The features, advantages, or alternative embodiments mentioned in this regard can also be equally transferred to other claimed objects, and vice versa.
[0101] It should be understood that although this specification is described according to various embodiments, not every embodiment only contains an independent technical solution. This narrative way of the specification is only for clarity. Those skilled in the art should regard the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art. The nouns and pronouns regarding people in this patent application are not limited to specific genders.
[0102] The series of detailed descriptions listed above are only specific descriptions of the feasible embodiments of the present invention, and they are not intended to limit the protection scope of the present invention. Any equivalent implementation or change made without departing from the technical spirit of the present invention, such as the combination, division, or repetition of features, shall be included in the protection scope of the present invention.
Claims
1. A data transmission control method, characterized in that, It is applied to a CAN node on a CAN bus. In the CAN node, an application module, a transmission control module, and a CAN driver module are provided. A transmission queue is provided in the transmission control module. The transmission queue is used to cache signal frames sent by the application module. The data transmission control method includes: Broadcasting and sending a frame to the CAN bus through the CAN driver module. The sending frame is periodically obtained from the transmission queue. Obtaining a received frame from the CAN driver module. The CAN driver module can obtain signals from the CAN bus. Judging whether the received frame is sent by the CAN node itself. If so, removing the signal frame consistent with the received frame from the transmission queue. If not, sending the received frame to the application module.
2. The data transmission control method according to claim 1, wherein: The sending frame is one or more signal frames with the highest priority in the transmission queue, or one or more signal frames cached earliest in the transmission queue.
3. The data transmission control method according to claim 2, wherein The CAN driver module includes: A CAN transceiver unit, which is used to convert digital signals and physical signals on the CAN bus; and A CAN control unit, which is configured to be able to receive, through the CAN transceiver unit, signal frames broadcast by the CAN node itself to other CAN nodes and signal frames broadcast by other CAN nodes to the CAN node from the CAN bus.
4. The data transmission control method according to claim 2, characterized in that It further includes: Obtaining a signal frame sent by the application module; Caching the signal frame in the transmission queue.
5. The data transmission control method according to claim 2, characterized in that Before judging whether the received frame is sent by the CAN node itself, it further includes: Judging whether the received frame is an error frame. If so, sending the error frame to the application module and obtaining a new signal frame from the CAN bus. If not, identifying the identifier of the received frame to determine the sending node of the received frame.
6. The data transmission control method according to claim 2, wherein Before the step of removing the signal frame consistent with the received frame, it specifically includes: Comparing the received frame with the signal frames in the transmission queue. If there is no consistent signal frame, discarding the received frame. If there is a consistent signal frame, entering the removal step.
7. The data transmission control method according to claim 2, wherein A reception queue is also provided in the transmission control module. The step of sending the received frame to the application module includes: Caching the received frame in the reception queue; Sending the received frame to the application module through the reception queue.
8. The data transmission control method according to claim 2, wherein It further includes: When it is detected that the number of sending times or the sending time of the sending frame exceeds a threshold, removing the sending frame from the transmission queue and reporting sending failure to the application module.
9. An electronic device capable of being connected as a CAN node to a bus, comprising an application module (101) and a CAN driver module (103), characterized in that, The electronic device further includes a transmission control module (102). The transmission control module (102) includes: A transmission queue; A sending unit (1021), which is used to broadcast and send a frame to the bus through the CAN driver module (103). The sending frame is periodically obtained from the transmission queue. A receiving unit (1022) for obtaining a received frame from the CAN driver module (103), the CAN driver module (103) being capable of obtaining signals from the bus; A judging unit (1023) for judging whether the received frame is sent by the CAN node itself, and when the result is yes, removing the signal frame consistent with the received frame from the sending queue, and when the result is no, sending the received frame to the application module (101).
10. The electronic device according to claim 9, wherein: The sent frame is one or more signal frames with the highest priority in the sending queue, or one or more signal frames cached earliest in the sending queue.
11. The electronic device according to claim 10, characterized in that, The CAN driver module (103) includes: A CAN transceiver unit (1032) for converting digital signals and physical signals on the bus; and A CAN control unit (1031) configured to be able to receive, through the CAN transceiver unit (1032), signal frames broadcast by the CAN node itself to other CAN nodes and signal frames broadcast by other CAN nodes to the CAN node from the bus.
12. The electronic device according to claim 10, characterized in that The transmission control module (102) further includes: A first buffer unit for obtaining signal frames to be sent from the application module (101) and caching the signal frames in the sending queue.
13. The electronic device according to claim 10, wherein The transmission control module (102) further includes: An error frame identification unit for obtaining the received frame from the receiving unit (1022) and judging whether the received frame is an error frame. When the received frame is an error frame, it is further configured to send the error frame to the application module (101). When the received frame is a normal frame, it is further configured to send the received frame to the judging unit (1023).
14. The electronic device according to claim 10, wherein The judging unit (1023) further includes: A rejection subunit for comparing the received frame with the signal frames in the sending queue, and when there is no consistent signal frame, discarding the received frame, and when there is a consistent signal frame, deleting the consistent signal frame.
15. The electronic device according to claim 10, wherein The transmission control module further includes: A receiving queue; and A second buffer unit for caching the received frame received from the judging unit (1023) in the receiving queue and sending the received frame to the application module (101) through the receiving queue; The judging unit (1023) sends the received frame to the application module (101) through the second buffer unit.
16. The electronic device according to claim 10, wherein The transmission control module (102) further includes: An interrupt unit for judging whether the number of transmissions or the transmission time of the sent frame exceeds a threshold, and when it exceeds the threshold, removing the sent frame from the sending queue and reporting transmission failure to the application module (101).
17. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions for implementing the method according to any one of claims 1 to 8.