CAN communication method, electronic device, and CAN communication system
By introducing a virtual communication matrix into the CAN communication system, the problem of new devices being unable to access the CAN bus is solved, communication expansion and secure data transmission between devices are achieved, and user experience and system security are improved.
Patent Information
- Application Number
- CN202210046889.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-14
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2042-01-14
AI Technical Summary
In the existing CAN communication system, newly added hardware devices cannot access the CAN bus and cannot communicate with other ECUs/MCUs on the CAN bus.
By setting up a virtual communication matrix in the CAN communication system, expanding the original communication matrix according to the newly added devices, defining the allowed message identifiers and reserved data, the secure transmission and reception of data on the CAN bus is achieved.
It expands the application scope of the CAN communication system, improves user experience, and enhances system security to prevent malicious data transmission and leakage.
Smart Images

Figure CN116488953B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of communication technology, and in particular relates to a CAN communication method, an electronic device, and a CAN communication system. Background Art
[0002] The controller area network (CAN) communication system is widely used for internal automotive communications and other industrial scenarios. A CAN communication system can include a CAN bus and at least two electronic control units (ECUs) or microcontroller units (MCUs) connected to the CAN bus. Currently, in CAN communication systems, each ECU / MCU transmits and receives data on the CAN bus according to a predefined communication matrix. Newly added hardware devices cannot access the CAN bus and cannot communicate with other ECUs / MCUs on the CAN bus. Summary of the Invention
[0003] The embodiments of the present application provide a CAN communication method, electronic device and CAN communication system, which can solve the problem in the existing CAN communication system that the newly added hardware device cannot access the CAN bus and cannot communicate with other ECUs / MCUs on the CAN bus.
[0004] In a first aspect, an embodiment of the present application provides a CAN communication method, which is applied to a controller area network (CAN) communication system, wherein the CAN communication system includes a first device, a second device, a CAN bus, and at least two CAN nodes connected to the CAN bus, wherein the at least two CAN nodes include a first CAN node and a second CAN node, the first device is connected to the first CAN node via a communication network, and the second CAN node is used to control the second device. A virtual communication matrix is provided in the CAN communication system, and the virtual communication matrix is obtained by expanding an original communication matrix of the CAN communication system according to the first device. The method may include:
[0005] The first CAN node acquires first data, where the first data is sent by the first device and is used to instruct the second device to perform a corresponding interactive operation;
[0006] The first CAN node determines, according to the virtual communication matrix, whether the first data is data allowed to be sent on the CAN bus;
[0007] When the first data is data allowed to be sent on the CAN bus, the first CAN node sends the first data to the CAN bus, so that the second CAN node obtains the first data from the CAN bus and controls the second device to perform corresponding interactive operations according to the first data.
[0008] In the above-mentioned CAN communication method, when it is necessary to add a first device to the CAN bus, the first device can be connected to the first CAN node in the CAN communication system through the communication network, and the original communication matrix of the CAN communication system can be expanded according to the first device to obtain a virtual communication matrix, so that the first device can be dynamically added to the CAN communication system according to the virtual communication matrix, so that the first device can communicate with other CAN nodes on the CAN bus through the first CAN node, so that the first device can send first data to the CAN bus through the first CAN node, so that the second CAN node can obtain the first data sent by the first device from the CAN bus, and can control the corresponding second device to perform interactive operations according to the first data, thereby achieving the purpose of interaction between the first device and other devices on the CAN bus, expanding the application scope of the CAN communication system, and improving user experience.
[0009] In a possible implementation, the at least two CAN nodes further include a third CAN node, and the method may further include:
[0010] The first CAN node obtains second data from the CAN bus, where the second data is sent by the third CAN node, and the second data is used to instruct the first device to perform a corresponding interactive operation;
[0011] The first CAN node determines, based on the virtual communication matrix, whether the second data is data allowed to be received by the first device;
[0012] When the second data is data that the first device is allowed to receive, the first CAN node sends the second data to the first device, so that the first device performs a corresponding interactive operation according to the second data.
[0013] It should be understood that the third CAN node and the second CAN node may be the same CAN node or different CAN nodes.
[0014] In the CAN communication method provided by this implementation, a first CAN node can obtain second data sent by other CAN nodes from the CAN bus, and can send the second data to the first device according to the virtual communication matrix, so that the first device can perform corresponding interactive operations according to the second data, thereby achieving the purpose of interaction between other devices on the CAN bus and the first device, expanding the application scope of the CAN communication system, and improving the user experience.
[0015] In a possible implementation, the virtual communication matrix is based on the original communication matrix, with the addition of a definition of a first message identifier and the addition of the first message identifier to the message identifiers of data received by the first interactive device, and / or based on the original communication matrix, with the addition of a definition of a second message identifier and the addition of the first CAN node to the CAN nodes at which data sent by the second interactive device is received.
[0016] The first message identifier is a message identifier for data allowed to be sent by the first device, the second message identifier is a message identifier for data allowed to be received by the first device, the first interactive device and the second interactive device are devices that interact with the first device in the CAN communication system, the first interactive device includes the second device, and / or the second interactive device includes the second device.
[0017] Exemplarily, the virtual communication matrix further defines first reserved data and / or second reserved data, wherein the first reserved data is data that the first device is allowed to send on the CAN bus through the first CAN node, and the second reserved data is data that the first device is allowed to obtain from the CAN bus through the first CAN node.
[0018] In the CAN communication method provided by this implementation, to prevent the first device from illegally using the CAN bus and to ensure the security of the CAN communication system, when the first device is added to the CAN communication system, restrictions can be placed on the data that the first device is allowed to receive and / or the data that it is allowed to send. Specifically, the virtual communication matrix can be used to restrict the MsgID of the data that the first device is allowed to send and / or the specific content of the data that it is allowed to send, and / or the MsgID of the data that the first device is allowed to receive and / or the specific content of the data that it is allowed to receive. This restricts the data that the first device is allowed to send to the CAN bus and / or the data that the first device is allowed to obtain from the CAN bus, thereby preventing the first device from sending malicious data to the CAN bus, reducing the security threat posed by malicious data to the CAN communication system, preventing data transmitted on the CAN bus from being leaked or illegally tampered with, and improving the security of the CAN communication system.
[0019] In one example, the first CAN node determining, according to the virtual communication matrix, whether the first data is data allowed to be sent on the CAN bus may include:
[0020] The first CAN node obtains a message identifier of the first data;
[0021] Determining, by the first CAN node, whether a message identifier of the first data is a first message identifier defined in the virtual communication matrix;
[0022] When the message identifier of the first data is the first message identifier, the first CAN node determines that the first data is data allowed to be sent on the CAN bus.
[0023] In the CAN communication method provided by this implementation, after receiving the first data, the first CAN node can perform a security protection check based on the first MsgID defined in the virtual communication matrix, that is, it can obtain the MsgID in the first data and determine whether the MsgID of the first data is the first MsgID defined in the virtual communication matrix. When the MsgID of the first data is the first MsgID defined in the virtual communication matrix, the first CAN node can determine that the first data is data allowed to be sent on the CAN bus and send the first data to the CAN bus. When the MsgID of the first data is not the first MsgID defined in the virtual communication matrix, the first CAN node will not send the first data to the CAN bus to avoid forwarding malicious data sent by the first device to the CAN bus, reducing security threats to the CAN communication system and improving the security of the CAN communication system.
[0024] In another example, the first CAN node determining, according to the virtual communication matrix, whether the first data is data allowed to be sent on the CAN bus may include:
[0025] The first CAN node obtains a message identifier of the first data;
[0026] The first CAN node determines whether a message identifier of the first data is a first message identifier defined in the virtual communication matrix, and determines whether the first data is first reserved data defined in the virtual communication matrix;
[0027] When the message identifier of the first data is the first message identifier, and the first data is the first reserved data, the first CAN node determines that the first data is data allowed to be sent on the CAN bus.
[0028] In the CAN communication method provided by this implementation, after receiving the first data, the first CAN node can perform a security check based on the first MsgID and first reserved data defined in the virtual communication matrix. Specifically, the node can obtain the MsgID and specific content in the first data and determine whether the MsgID of the first data is the first MsgID defined in the virtual communication matrix and whether the specific content is the first reserved data defined in the virtual communication matrix. When the MsgID of the first data is the first MsgID defined in the virtual communication matrix and the specific content is the first reserved data defined in the virtual communication matrix, the first CAN node can determine that the first data is data allowed to be sent on the CAN bus and send the first data to the CAN bus. If the MsgID of the first data is not the first MsgID defined in the virtual communication matrix, the first CAN node will not send the first data to the CAN bus, thereby avoiding forwarding malicious data sent by the first device to the CAN bus, reducing security threats to the CAN communication system, and improving the security of the CAN communication system.
[0029] Exemplarily, the first CAN node sending the first data to the CAN bus may include:
[0030] The first CAN node encapsulates the first data according to a data structure corresponding to the CAN bus to obtain third data;
[0031] The first CAN node sends the third data to the CAN bus.
[0032] In the CAN communication method provided in this implementation, the transmission protocol between the first device and the first CAN node can be modified. Specifically, the MsgID and data segment contents corresponding to the CAN data frame can be added to the first data transmitted over the communication network. Therefore, when the first data sent by the first device needs to be sent to the CAN bus, the MsgID and data segment contents in the first data can be obtained and then encapsulated according to the data structure corresponding to the CAN bus to obtain third data that can be broadcast on the CAN bus. This allows the data sent by the first device to be broadcast on the CAN bus.
[0033] In one example, the first CAN node determining, according to the virtual communication matrix, whether the second data is data allowed to be received by the first device may include:
[0034] The first CAN node obtains a message identifier of the second data;
[0035] Determining, by the first CAN node, whether a message identifier of the second data is a second message identifier defined in the virtual communication matrix;
[0036] When the message identifier of the second data is the second message identifier, the first CAN node determines that the second data is data allowed to be received by the first device.
[0037] In the CAN communication method provided by this implementation, after the first CAN node receives the second data, it can perform a security protection check based on the second MsgID defined in the virtual communication matrix to prevent the data transmitted in the CAN bus from being leaked or illegally tampered with, thereby improving the security of the CAN communication system.
[0038] In another example, the first CAN node determining, according to the virtual communication matrix, whether the second data is data allowed to be received by the first device may include:
[0039] The first CAN node obtains a message identifier of the second data;
[0040] The first CAN node determines whether a message identifier of the second data is a second message identifier defined in the virtual communication matrix, and determines whether the second data is second reserved data defined in the virtual communication matrix;
[0041] When the message identifier of the second data is the second message identifier, and the second data is the second reserved data, the first CAN node determines that the second data is data allowed to be received by the first device.
[0042] In the CAN communication method provided by this implementation, after the first CAN node receives the second data, it can perform a security protection check based on the second MsgID and the second reserved data defined in the virtual communication matrix to prevent the data transmitted in the CAN bus from being leaked or illegally tampered with, thereby improving the security of the CAN communication system.
[0043] Exemplarily, the first CAN node sending the second data to the first device may include:
[0044] The first CAN node encapsulates the second data according to a data structure corresponding to the communication network to obtain fourth data;
[0045] The first CAN node sends the fourth data to the first device.
[0046] In the CAN communication method provided by this implementation, in order to enable the second data sent by the second CAN node to be received by the first device, the MsgID and the content of the data segment (data) in the second data can be obtained, and the content of the MsgID and the data segment (data) can be encapsulated according to the data structure corresponding to the communication network between the first device and the first CAN node to obtain data that can be transmitted to the first device through the communication network.
[0047] In a second aspect, an embodiment of the present application provides a CAN communication method, which is applied to a controller area network (CAN) communication system, wherein the CAN communication system includes a first device, a second device, a CAN bus, and at least two CAN nodes connected to the CAN bus, wherein the at least two CAN nodes include a first CAN node and a second CAN node, the first device is connected to the first CAN node via a communication network, and the second CAN node is used to control the second device. A virtual communication matrix is provided in the CAN communication system, and the virtual communication matrix is obtained by expanding the original communication matrix of the CAN communication system according to the first device. The method may include:
[0048] The first CAN node obtains second data from the CAN bus, where the second data is sent by the second CAN node and is used to instruct the first device to perform a corresponding interactive operation;
[0049] The first CAN node determines, based on the virtual communication matrix, whether the second data is data allowed to be received by the first device;
[0050] When the second data is data that the first device is allowed to receive, the first CAN node sends the second data to the first device, so that the first device performs a corresponding interactive operation according to the second data.
[0051] In a possible implementation, the at least two CAN nodes further include a third CAN node, and the method may further include:
[0052] The first CAN node acquires first data, where the first data is sent by the first device and is used to instruct the second device to perform a corresponding interactive operation;
[0053] The first CAN node determines, according to the virtual communication matrix, whether the first data is data allowed to be sent on the CAN bus;
[0054] When the first data is data allowed to be sent on the CAN bus, the first CAN node sends the first data to the CAN bus, so that the third CAN node obtains the first data from the CAN bus and controls the second device to perform corresponding interactive operations according to the first data.
[0055] In a possible implementation, the virtual communication matrix is based on the original communication matrix, with the addition of a definition of a first message identifier and the addition of the first message identifier to the message identifiers of data received by the first interactive device, and / or based on the original communication matrix, with the addition of a definition of a second message identifier and the addition of the first CAN node to the CAN nodes at which data sent by the second interactive device is received.
[0056] The first message identifier is a message identifier for data allowed to be sent by the first device, the second message identifier is a message identifier for data allowed to be received by the first device, the first interactive device and the second interactive device are devices that interact with the first device in the CAN communication system, the first interactive device includes the second device, and / or the second interactive device includes the second device.
[0057] In another possible implementation, the virtual communication matrix further defines first reserved data and / or second reserved data, wherein the first reserved data is data that the first device is allowed to send on the CAN bus through the first CAN node, and the second reserved data is data that the first device is allowed to obtain from the CAN bus through the first CAN node.
[0058] In one example, the first CAN node determining, according to the virtual communication matrix, whether the first data is data allowed to be sent on the CAN bus may include:
[0059] The first CAN node obtains a message identifier of the first data;
[0060] Determining, by the first CAN node, whether a message identifier of the first data is a first message identifier defined in the virtual communication matrix;
[0061] When the message identifier of the first data is the first message identifier, the first CAN node determines that the first data is data allowed to be sent on the CAN bus.
[0062] In another example, the first CAN node determining, according to the virtual communication matrix, whether the first data is data allowed to be sent on the CAN bus may include:
[0063] The first CAN node obtains a message identifier of the first data;
[0064] The first CAN node determines whether a message identifier of the first data is a first message identifier defined in the virtual communication matrix, and determines whether the first data is first reserved data defined in the virtual communication matrix;
[0065] When the message identifier of the first data is the first message identifier, and the first data is the first reserved data, the first CAN node determines that the first data is data allowed to be sent on the CAN bus.
[0066] Exemplarily, the first CAN node sending the first data to the CAN bus may include:
[0067] The first CAN node encapsulates the first data according to a data structure corresponding to the CAN bus to obtain third data;
[0068] The first CAN node sends the third data to the CAN bus.
[0069] In one example, the first CAN node determining, according to the virtual communication matrix, whether the second data is data allowed to be received by the first device may include:
[0070] The first CAN node obtains a message identifier of the second data;
[0071] Determining, by the first CAN node, whether a message identifier of the second data is a second message identifier defined in the virtual communication matrix;
[0072] When the message identifier of the second data is the second message identifier, the first CAN node determines that the second data is data allowed to be received by the first device.
[0073] In another example, the first CAN node determining, according to the virtual communication matrix, whether the second data is data allowed to be received by the first device may include:
[0074] The first CAN node obtains a message identifier of the second data;
[0075] The first CAN node determines whether a message identifier of the second data is a second message identifier defined in the virtual communication matrix, and determines whether the second data is second reserved data defined in the virtual communication matrix;
[0076] When the message identifier of the second data is the second message identifier, and the second data is the second reserved data, the first CAN node determines that the second data is data allowed to be received by the first device.
[0077] Exemplarily, the first CAN node sending the second data to the first device may include:
[0078] The first CAN node encapsulates the second data according to a data structure corresponding to the communication network to obtain fourth data;
[0079] The first CAN node sends the fourth data to the first device.
[0080] In a third aspect, an embodiment of the present application provides a CAN communication device, which is applied to a controller area network (CAN) communication system. The CAN communication system includes a first device, a second device, a CAN bus, and at least two CAN nodes connected to the CAN bus. The at least two CAN nodes include a first CAN node and a second CAN node. The first device is connected to the first CAN node via a communication network. The second CAN node is used to control the second device. A virtual communication matrix is provided in the CAN communication system. The virtual communication matrix is obtained by expanding the original communication matrix of the CAN communication system according to the first device. The device may include:
[0081] a first data acquisition module, configured to acquire first data, where the first data is sent by the first device and is used to instruct the second device to perform a corresponding interactive operation;
[0082] a first data determining module, configured to determine, based on the virtual communication matrix, whether the first data is data allowed to be sent on the CAN bus;
[0083] The first data sending module is used to send the first data to the CAN bus when the first data is data allowed to be sent on the CAN bus, so that the second CAN node obtains the first data from the CAN bus and controls the second device to perform corresponding interactive operations according to the first data.
[0084] In a possible implementation, the at least two CAN nodes further include a third CAN node, and the apparatus may further include:
[0085] a second data acquisition module, configured to acquire second data from the CAN bus, where the second data is sent by the third CAN node and is used to instruct the first device to perform a corresponding interactive operation;
[0086] a second data determining module, configured to determine, based on the virtual communication matrix, whether the second data is data that the first device is allowed to receive;
[0087] The second data sending module is configured to send the second data to the first device when the second data is data allowed to be received by the first device, so that the first device performs a corresponding interactive operation according to the second data.
[0088] In a possible implementation, the virtual communication matrix is based on the original communication matrix, with the addition of a definition of a first message identifier and the addition of the first message identifier to the message identifiers of data received by the first interactive device, and / or based on the original communication matrix, with the addition of a definition of a second message identifier and the addition of the first CAN node to the CAN nodes at which data sent by the second interactive device is received.
[0089] The first message identifier is a message identifier for data allowed to be sent by the first device, the second message identifier is a message identifier for data allowed to be received by the first device, the first interactive device and the second interactive device are devices that interact with the first device in the CAN communication system, the first interactive device includes the second device, and / or the second interactive device includes the second device.
[0090] In another possible implementation, the virtual communication matrix further defines first reserved data and / or second reserved data, wherein the first reserved data is data that the first device is allowed to send on the CAN bus through the first CAN node, and the second reserved data is data that the first device is allowed to obtain from the CAN bus through the first CAN node.
[0091] In one example, the first data determination module may include:
[0092] a first identifier obtaining unit, configured to obtain a message identifier of the first data;
[0093] a first identifier determining unit, configured to determine whether a message identifier of the first data is a first message identifier defined in the virtual communication matrix;
[0094] The first data determining unit is configured to determine, when the message identifier of the first data is the first message identifier, that the first data is data allowed to be sent on the CAN bus.
[0095] In another example, the first data determination module may further include:
[0096] a second identifier obtaining unit, configured to obtain a message identifier of the first data;
[0097] a second identifier determining unit, configured to determine whether a message identifier of the first data is a first message identifier defined in the virtual communication matrix, and to determine whether the first data is first reserved data defined in the virtual communication matrix;
[0098] The second data determining unit is configured to determine that the first data is data allowed to be sent on the CAN bus when the message identifier of the first data is the first message identifier and the first data is the first reserved data.
[0099] Exemplarily, the first data sending module may include:
[0100] a first data encapsulation unit, configured to encapsulate the first data according to a data structure corresponding to the CAN bus to obtain third data;
[0101] The first sending unit is configured to send the third data to the CAN bus.
[0102] In one example, the second data determination module may include:
[0103] a third identifier obtaining unit, configured to obtain a message identifier of the second data;
[0104] a third identifier determining unit, configured to determine whether the message identifier of the second data is a second message identifier defined in the virtual communication matrix;
[0105] The third data determining unit is configured to determine, when the message identifier of the second data is the second message identifier, that the second data is data allowed to be received by the first device.
[0106] In another example, the second data determination module may include:
[0107] a fourth identifier obtaining unit, configured to obtain a message identifier of the second data;
[0108] a fourth identifier determining unit, configured to determine whether the message identifier of the second data is a second message identifier defined in the virtual communication matrix, and determine whether the second data is second reserved data defined in the virtual communication matrix;
[0109] The fourth data determining unit is configured to determine, when the message identifier of the second data is the second message identifier and the second data is the second reserved data, that the second data is data that the first device is allowed to receive.
[0110] Exemplarily, the second data sending module may include:
[0111] a second data encapsulation unit, configured to encapsulate the second data according to a data structure corresponding to the communication network to obtain fourth data;
[0112] The second sending unit is configured to send the fourth data to the first device.
[0113] In a fourth aspect, an embodiment of the present application provides a CAN communication device, which is applied to a controller area network (CAN) communication system. The CAN communication system includes a first device, a second device, a CAN bus, and at least two CAN nodes connected to the CAN bus, wherein the at least two CAN nodes include a first CAN node and a second CAN node. The first device is connected to the first CAN node via a communication network, and the second CAN node is used to control the second device. A virtual communication matrix is provided in the CAN communication system, and the virtual communication matrix is obtained by expanding the original communication matrix of the CAN communication system according to the first device. The device may include:
[0114] a second data acquisition module, configured to acquire second data from the CAN bus, where the second data is sent by the second CAN node and is used to instruct the first device to perform a corresponding interactive operation;
[0115] a second data determining module, configured to determine, based on the virtual communication matrix, whether the second data is data that the first device is allowed to receive;
[0116] The second data sending module is configured to send the second data to the first device when the second data is data allowed to be received by the first device, so that the first device performs a corresponding interactive operation according to the second data.
[0117] In a possible implementation, the at least two CAN nodes further include a third CAN node, and the apparatus further includes:
[0118] a first data acquisition module, configured to acquire first data, where the first data is sent by the first device and is used to instruct the second device to perform a corresponding interactive operation;
[0119] a first data determining module, configured to determine, based on the virtual communication matrix, whether the first data is data allowed to be sent on the CAN bus;
[0120] The first data sending module is used to send the first data to the CAN bus when the first data is data allowed to be sent on the CAN bus, so that the third CAN node obtains the first data from the CAN bus and controls the second device to perform corresponding interactive operations according to the first data.
[0121] In a possible implementation, the virtual communication matrix is based on the original communication matrix, with the addition of a definition of a first message identifier and the addition of the first message identifier to the message identifiers of data received by the first interactive device, and / or based on the original communication matrix, with the addition of a definition of a second message identifier and the addition of the first CAN node to the CAN nodes at which data sent by the second interactive device is received.
[0122] The first message identifier is a message identifier for data allowed to be sent by the first device, the second message identifier is a message identifier for data allowed to be received by the first device, the first interactive device and the second interactive device are devices that interact with the first device in the CAN communication system, the first interactive device includes the second device, and / or the second interactive device includes the second device.
[0123] In another possible implementation, the virtual communication matrix further defines first reserved data and / or second reserved data, wherein the first reserved data is data that the first device is allowed to send on the CAN bus through the first CAN node, and the second reserved data is data that the first device is allowed to obtain from the CAN bus through the first CAN node.
[0124] In one example, the first data determination module may include:
[0125] a first identifier obtaining unit, configured to obtain a message identifier of the first data;
[0126] a first identifier determining unit, configured to determine whether a message identifier of the first data is a first message identifier defined in the virtual communication matrix;
[0127] The first data determining unit is configured to determine, when the message identifier of the first data is the first message identifier, that the first data is data allowed to be sent on the CAN bus.
[0128] In another example, the first data determination module may further include:
[0129] a second identifier obtaining unit, configured to obtain a message identifier of the first data;
[0130] a second identifier determining unit, configured to determine whether a message identifier of the first data is a first message identifier defined in the virtual communication matrix, and to determine whether the first data is first reserved data defined in the virtual communication matrix;
[0131] The second data determining unit is configured to determine that the first data is data allowed to be sent on the CAN bus when the message identifier of the first data is the first message identifier and the first data is the first reserved data.
[0132] Exemplarily, the first data sending module may include:
[0133] a first data encapsulation unit, configured to encapsulate the first data according to a data structure corresponding to the CAN bus to obtain third data;
[0134] The first sending unit is configured to send the third data to the CAN bus.
[0135] In one example, the second data determination module may include:
[0136] a third identifier obtaining unit, configured to obtain a message identifier of the second data;
[0137] a third identifier determining unit, configured to determine whether the message identifier of the second data is a second message identifier defined in the virtual communication matrix;
[0138] The third data determining unit is configured to determine, when the message identifier of the second data is the second message identifier, that the second data is data allowed to be received by the first device.
[0139] In another example, the second data determination module may include:
[0140] a fourth identifier obtaining unit, configured to obtain a message identifier of the second data;
[0141] a fourth identifier determining unit, configured to determine whether the message identifier of the second data is a second message identifier defined in the virtual communication matrix, and determine whether the second data is second reserved data defined in the virtual communication matrix;
[0142] The fourth data determining unit is configured to determine, when the message identifier of the second data is the second message identifier and the second data is the second reserved data, that the second data is data that the first device is allowed to receive.
[0143] Exemplarily, the second data sending module may include:
[0144] a second data encapsulation unit, configured to encapsulate the second data according to a data structure corresponding to the communication network to obtain fourth data;
[0145] The second sending unit is configured to send the fourth data to the first device.
[0146] In a fifth aspect, an embodiment of the present application provides a CAN communication system, comprising a first device, a second device, a CAN bus, and at least two CAN nodes connected to the CAN bus, wherein the at least two CAN nodes include a first CAN node and a second CAN node, the first device being connected to the first CAN node via a communication network, the second CAN node being used to control the second device, and a virtual communication matrix being provided in the CAN communication system, the virtual communication matrix being obtained by expanding an original communication matrix of the CAN communication system according to the first device;
[0147] The first device is used to send first data to the first CAN node, where the first data is used to instruct the second device to perform a corresponding interactive operation;
[0148] The first CAN node is used to obtain first data and determine whether the first data is data allowed to be sent on the CAN bus according to the virtual communication matrix;
[0149] When the first data is data allowed to be sent on the CAN bus, the first CAN node is further configured to send the first data to the CAN bus;
[0150] The second CAN node is used to obtain the first data from the CAN bus and control the second device to perform corresponding interactive operations according to the first data.
[0151] In a possible implementation, the at least two CAN nodes further include a third CAN node;
[0152] The third CAN node is used to send second data to the CAN bus, where the second data is used to instruct the first device to perform a corresponding interactive operation;
[0153] The first CAN node is further configured to obtain the second data from the CAN bus and determine, based on the virtual communication matrix, whether the second data is data that the first device is allowed to receive;
[0154] When the second data is data allowed to be received by the first device, the first CAN node is further configured to send the second data to the first device;
[0155] The first device is used to receive the second data and perform corresponding interactive operations according to the second data.
[0156] In a possible implementation, the virtual communication matrix is based on the original communication matrix, with the addition of a definition of a first message identifier and the addition of the first message identifier to the message identifiers of data received by the first interactive device, and / or based on the original communication matrix, with the addition of a definition of a second message identifier and the addition of the first CAN node to the CAN nodes at which data sent by the second interactive device is received.
[0157] The first message identifier is a message identifier for data allowed to be sent by the first device, the second message identifier is a message identifier for data allowed to be received by the first device, the first interactive device and the second interactive device are devices that interact with the first device in the CAN communication system, the first interactive device includes the second device, and / or the second interactive device includes the second device.
[0158] In another possible implementation, the virtual communication matrix further defines first reserved data and / or second reserved data, wherein the first reserved data is data that the first device is allowed to send on the CAN bus through the first CAN node, and the second reserved data is data that the first device is allowed to obtain from the CAN bus through the first CAN node.
[0159] In one example, the first CAN node is further configured to obtain a message identifier of the first data, and determine whether the message identifier of the first data is a first message identifier defined in the virtual communication matrix;
[0160] When the message identifier of the first data is the first message identifier, the first CAN node is further configured to determine that the first data is data allowed to be sent on the CAN bus.
[0161] In another example, the first CAN node is further used to obtain a message identifier of the first data, and determine whether the message identifier of the first data is a first message identifier defined in the virtual communication matrix, and determine whether the first data is first reserved data defined in the virtual communication matrix;
[0162] When the message identifier of the first data is the first message identifier, and the first data is the first reserved data, the first CAN node is further configured to determine that the first data is data allowed to be sent on the CAN bus.
[0163] Exemplarily, the first CAN node is further configured to encapsulate the first data according to a data structure corresponding to the CAN bus to obtain third data, and send the third data to the CAN bus.
[0164] In one example, the first CAN node is further configured to obtain a message identifier of the second data; determine whether the message identifier of the second data is a second message identifier defined in the virtual communication matrix;
[0165] When the message identifier of the second data is the second message identifier, the first CAN node is further configured to determine that the second data is data allowed to be received by the first device.
[0166] In another example, the first CAN node is further used to obtain a message identifier of the second data; determine whether the message identifier of the second data is a second message identifier defined in the virtual communication matrix, and determine whether the second data is second reserved data defined in the virtual communication matrix;
[0167] When the message identifier of the second data is the second message identifier, and the second data is the second reserved data, the first CAN node is further configured to determine that the second data is data that the first device is allowed to receive.
[0168] Exemplarily, the first CAN node is further used to encapsulate the second data according to the data structure corresponding to the communication network to obtain fourth data, and send the fourth data to the first device.
[0169] Optionally, the first device and the first CAN node are connected via a multi-connection mode.
[0170] Optionally, a rate adjustment buffer is provided in the first CAN node, and the rate adjustment buffer is used to store the first data acquired by the first CAN node.
[0171] In a sixth aspect, an embodiment of the present application provides a CAN communication system, comprising a first device, a second device, a CAN bus, and at least two CAN nodes connected to the CAN bus, wherein the at least two CAN nodes include a first CAN node and a second CAN node, the first device being connected to the first CAN node via a communication network, the second CAN node being used to control the second device, and a virtual communication matrix being provided in the CAN communication system, the virtual communication matrix being obtained by expanding an original communication matrix of the CAN communication system according to the first device;
[0172] The second CAN node is used to send second data to the CAN bus, where the second data is used to instruct the first device to perform a corresponding interactive operation;
[0173] The first CAN node is used to obtain the second data from the CAN bus and determine, based on the virtual communication matrix, whether the second data is data allowed to be received by the first device;
[0174] When the second data is data allowed to be received by the first device, the first CAN node is further configured to send the second data to the first device;
[0175] The first device is used to receive the second data and perform corresponding interactive operations according to the second data.
[0176] In a possible implementation, the at least two CAN nodes further include a third CAN node;
[0177] The first device is used to send first data to the first CAN node, where the first data is used to instruct the second device to perform a corresponding interactive operation;
[0178] The first CAN node is used to obtain first data and determine whether the first data is data allowed to be sent on the CAN bus according to the virtual communication matrix;
[0179] When the first data is data allowed to be sent on the CAN bus, the first CAN node is further configured to send the first data to the CAN bus;
[0180] The third CAN node is used to obtain the first data from the CAN bus and control the second device to perform corresponding interactive operations according to the first data.
[0181] In a possible implementation, the virtual communication matrix is based on the original communication matrix, with the addition of a definition of a first message identifier and the addition of the first message identifier to the message identifiers of data received by the first interactive device, and / or based on the original communication matrix, with the addition of a definition of a second message identifier and the addition of the first CAN node to the CAN nodes at which data sent by the second interactive device is received.
[0182] The first message identifier is a message identifier for data allowed to be sent by the first device, the second message identifier is a message identifier for data allowed to be received by the first device, the first interactive device and the second interactive device are devices that interact with the first device in the CAN communication system, the first interactive device includes the second device, and / or the second interactive device includes the second device.
[0183] In another possible implementation, the virtual communication matrix further defines first reserved data and / or second reserved data, wherein the first reserved data is data that the first device is allowed to send on the CAN bus through the first CAN node, and the second reserved data is data that the first device is allowed to obtain from the CAN bus through the first CAN node.
[0184] In one example, the first CAN node is further configured to obtain a message identifier of the first data, and determine whether the message identifier of the first data is a first message identifier defined in the virtual communication matrix;
[0185] When the message identifier of the first data is the first message identifier, the first CAN node is further configured to determine that the first data is data allowed to be sent on the CAN bus.
[0186] In another example, the first CAN node is further used to obtain a message identifier of the first data, and determine whether the message identifier of the first data is a first message identifier defined in the virtual communication matrix, and determine whether the first data is first reserved data defined in the virtual communication matrix;
[0187] When the message identifier of the first data is the first message identifier, and the first data is the first reserved data, the first CAN node is further configured to determine that the first data is data allowed to be sent on the CAN bus.
[0188] Exemplarily, the first CAN node is further configured to encapsulate the first data according to a data structure corresponding to the CAN bus to obtain third data, and send the third data to the CAN bus.
[0189] In one example, the first CAN node is further configured to obtain a message identifier of the second data; determine whether the message identifier of the second data is a second message identifier defined in the virtual communication matrix;
[0190] When the message identifier of the second data is the second message identifier, the first CAN node is further configured to determine that the second data is data allowed to be received by the first device.
[0191] In another example, the first CAN node is further used to obtain a message identifier of the second data; determine whether the message identifier of the second data is a second message identifier defined in the virtual communication matrix, and determine whether the second data is second reserved data defined in the virtual communication matrix;
[0192] When the message identifier of the second data is the second message identifier, and the second data is the second reserved data, the first CAN node is further configured to determine that the second data is data that the first device is allowed to receive.
[0193] Exemplarily, the first CAN node is further used to encapsulate the second data according to the data structure corresponding to the communication network to obtain fourth data, and send the fourth data to the first device.
[0194] Optionally, the first device and the first CAN node are connected via a multi-connection mode.
[0195] Optionally, a rate adjustment buffer is provided in the first CAN node, and the rate adjustment buffer is used to store the first data acquired by the first CAN node.
[0196] In the seventh aspect, an embodiment of the present application provides an electronic device, wherein a CAN communication system is provided in the electronic device, the CAN communication system includes a first device, a second device, a CAN bus and at least two CAN nodes connected to the CAN bus, the at least two CAN nodes include a first CAN node and a second CAN node, the first device is connected to the first CAN node through a communication network, the second CAN node is used to control the second device, a virtual communication matrix is provided in the CAN communication system, the virtual communication matrix is obtained by expanding the original communication matrix of the CAN communication system according to the first device, and the first CAN node is used to execute the CAN communication method described in any one of the first or second aspects above.
[0197] Among them, electronic devices can be automobiles, industrial equipment, artificial intelligence equipment, etc.
[0198] In the eighth aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, a controller and a transceiver, wherein the controller is used to control the transceiver to receive data on a CAN bus, and store the received data in the memory or send it to the processor. The controller is also used to obtain data from the processor or the memory, and control the transceiver to send the obtained data to the CAN bus. The memory stores a computer program that can be run on the processor. When the processor executes the computer program, the electronic device implements the CAN communication method described in any one of the first or second aspects above.
[0199] In the ninth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a computer, the computer implements the CAN communication method described in any one of the first or second aspects above.
[0200] In the tenth aspect, an embodiment of the present application provides a computer program product, which, when running on an electronic device, enables the electronic device to execute the CAN communication method described in any one of the first or second aspects above.
[0201] It can be understood that the beneficial effects of the second to tenth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0202] Figure 1 This is a schematic diagram of the structure of the data broadcast by the CAN bus;
[0203] Figure 2 This is a schematic diagram of the structure of a CAN communication system provided by an embodiment of the present application;
[0204] Figure 3 This is a schematic diagram of the structure of data transmitted based on the UDP protocol provided in an embodiment of the present application;
[0205] Figure 4 is a schematic flow chart of a CAN communication method provided in one embodiment of the present application;
[0206] Figure 5 is a structural diagram of a CAN communication system provided by another embodiment of the present application;
[0207] Figure 6 is a schematic flow chart of a CAN communication method provided in another embodiment of the present application;
[0208] Figure 7 It is a structural diagram of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0209] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.
[0210] It will also be understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0211] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0212] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0213] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0214] In addition, the “plurality” mentioned in the embodiments of the present application should be interpreted as two or more.
[0215] The steps involved in the CAN communication method provided in the embodiments of the present application are merely examples. Not all steps are mandatory, nor are all information or messages required. These steps can be added or removed as needed during use. The same step or steps or messages with the same function in different embodiments of the present application can be referenced and learned from each other.
[0216] The business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Ordinary technicians in this field will know that with the evolution of network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0217] The CAN communication system can be widely used in internal automotive communications and other industrial scenarios. The CAN communication system may include a CAN bus, and at least two ECUs / MCUs connected to the CAN bus, that is, each ECU / MCU can be connected to the CAN bus when working to become a CAN node of the CAN bus. Among them, each CAN node can send data on the CAN bus, and other CAN nodes can receive data broadcast on the CAN bus. It should be understood that the data broadcast on the CAN bus is the data sent by the CAN node on the CAN bus. The above-mentioned ECU / MCU connected to the CAN bus is only an exemplary explanation and should not be understood as a display of the embodiments of the present application. In the embodiments of the present application, other physical devices such as microprocessing units may also be connected to the CAN bus.
[0218] See also Figure 1 , Figure 1 Figure 2 shows a schematic diagram of the structure of the data broadcast by the CAN bus. Figure 1 As shown in the figure, each data frame broadcast on the CAN bus (hereinafter referred to as a CAN data frame) can include a start of frame (SOF) segment, an arbitration field (AF) segment, a control segment, a data segment, a cyclic redundancy check (CRC) segment, an acknowledgement (ACK) segment, and an end of frame (EOF) segment. The AF segment mainly contains the message identifier (MsgID) corresponding to the CAN data frame. The MsgID determines the priority of the CAN data frame and whether other CAN nodes will receive the CAN data frame.
[0219] When electronic devices such as automobiles leave the factory, the manufacturer typically defines a communication matrix corresponding to the CAN communication system (hereinafter referred to as the original communication matrix). Each device within the electronic device (i.e., the ECU / MCU corresponding to each device) must adhere to the original communication matrix to send and receive data and interact with other devices. In other words, the original communication matrix defines which CAN data frames with MsgIDs each ECU / MCU in the electronic device can receive and / or send. In other words, each ECU / MCU must adhere to the definition of the original communication matrix to send and receive data.
[0220] Among them, when a new device needs to be added to the CAN communication system, since the new device is not defined in the original communication matrix, that is, the original communication matrix does not define which CAN data frames with MsgIDs the new device can receive, and / or which CAN data frames with MsgIDs it can send, etc., and the new device generally does not have a CAN bus interface, resulting in the new device being unable to access the CAN bus and unable to communicate with the CAN nodes (i.e., ECU / MCU) on the CAN bus, thereby making the new device unable to interact with other devices on the CAN bus, etc., which greatly affects the user experience.
[0221] In order to solve the above problems, an embodiment of the present application provides a CAN communication method, an electronic device and a CAN communication system. In this method, when a new device (hereinafter referred to as a first device) needs to be added to the CAN bus, the first device can be connected to a CAN node (hereinafter referred to as the first CAN node) in the CAN communication system through a communication network, and the original communication matrix of the CAN communication system can be expanded according to the first device to obtain a virtual communication matrix. Among them, the definition of the first device can be added to the virtual communication matrix, that is, the definition of the MsgID of the data that can be sent by the first device (hereinafter the MsgID of the data that can be sent by the first device is referred to as the first message identifier, i.e. the first MsgID) and / or the MsgID of the data that can be received (hereinafter the MsgID of the data that can be received by the first device is referred to as the second message identifier, i.e. the second MsgID) can be added, and the MsgID of the data that can be received by the interactive device can be modified according to the first MsgID and / or the second MsgID, and / or the CAN node at which the data sent by the interactive device can be received can be modified (i.e. the first CAN node connected to the first device is added), etc. The interactive device is a device in the CAN communication system that needs to interact with the first device, so that the first device can be dynamically added to the CAN communication system according to the virtual communication matrix, so that the first device can communicate with other CAN nodes on the CAN bus, thereby enabling the first device to interact with other devices on the CAN bus, expanding the application scope of the CAN communication system, improving user experience, and having strong ease of use and practicality.
[0222] It should be noted that the CAN communication method provided in the embodiments of the present application can be applied to automobiles, industrial equipment, artificial intelligence equipment, etc. The following uses the application of the CAN communication method to automobiles as an example to illustrate the relevant concepts involved in the embodiments of the present application.
[0223] The original communication matrix is defined by the manufacturer based on the devices present in the vehicle at the time of manufacture. Specifically, it defines the MsgIDs of the CAN data frames that each ECU / MCU corresponding to the devices present at the time of manufacture can receive and / or send, enabling communication between the various devices within the vehicle via the CAN bus. It should be understood that a single ECU / MCU can manage one or more devices; therefore, a single ECU / MCU can receive and / or send CAN data frames with multiple different MsgIDs.
[0224] The virtual communication matrix is a communication matrix obtained by expanding the original communication matrix according to the newly added first device in the embodiment of the present application, that is, the virtual communication matrix can be based on the original communication matrix, adding the definition of the first MsgID and / or the second MsgID, and modifying the MsgID of the data that can be received by the interactive device according to the first MsgID and / or the second MsgID, and / or modifying the CAN node at which the data sent by the interactive device can be received, etc., wherein the interactive device is a device in the CAN communication system that needs to interact with the first device, so that the first device can be added to the CAN communication system according to the virtual communication matrix, so that it can interact with the original devices in the CAN bus.
[0225] Among them, adding the definition of the first MsgID means adding a MsgID for data that can be sent by the first device, or adding a MsgID for data that can be sent by the first device and adding relevant content of the signal that can be sent by the first device to the corresponding MsgID based on the data that can be sent by the first device, so that the first device can send the data of the first MsgID to the CAN bus. Adding the definition of the second MsgID means that based on the data that the first device needs to obtain, the first CAN node corresponding to the first device can be added to the CAN nodes that can receive the data, or based on the data that the first device needs to obtain, the relevant content of the signal corresponding to the first device can be added to the MsgID corresponding to the data (for example, adding relevant content of the signal that the first device can receive to the MsgID), so that the first device can obtain the data of the second MsgID from the CAN bus.
[0226] Since the first device is often a device that does not have a CAN bus interface, the first device can be connected to a first CAN node in the CAN communication system via a communication network to add the first device to the CAN communication system via the first CAN node. For example, the first device can send a registration request to the first CAN node via the communication network to register the first MsgID and / or second MsgID corresponding to the first device, so that the first device can send data to the CAN bus via the first CAN node, so that other CAN nodes can obtain the data sent by the first device from the CAN bus, or the first device can obtain data sent by other CAN nodes from the CAN bus via the first CAN node, thereby enabling the first device to interact with other devices in the CAN communication system.
[0227] It should be understood that the first MsgID corresponding to the first device can be determined based on the MsgIDs reserved and available in the CAN communication system when the first device is connected to the first CAN node. For example, any one or more of the MsgIDs reserved and available in the CAN communication system can be determined as the first MsgID of the first device. The second MsgID corresponding to the first device can be determined based on the MsgID of data that can be sent to the first device by a device that the first device needs to interact with (i.e., data that the first device can receive).
[0228] For example, when it is necessary to add an aromatherapy device to the CAN communication system, the aromatherapy device can be connected to the vehicle ECU via the communication network so that the aromatherapy device can be added to the CAN communication system via the vehicle ECU. At this time, the first MsgID (e.g., 0x0A4) corresponding to the aromatherapy device can be determined based on the available MsgIDs reserved in the CAN communication system, and / or the second MsgID corresponding to the aromatherapy device can be determined based on the MsgID of the data that can be sent to the aromatherapy device by the interactive device corresponding to the aromatherapy device (e.g., the air conditioner, ECU1, etc. described in Table 1). In addition, the MsgID of the data that can be received by the air conditioner, ECU1, etc. can be modified based on the first MsgID and / or the second MsgID, and / or the CAN node at which the data sent by the air conditioner, ECU1, etc. can be received can be modified, so as to expand the original communication matrix and obtain the virtual communication matrix shown in Table 1.
[0229] Among them, the signal corresponding to each MsgID in Table 1 can be used to limit the data allowed to be sent by the MsgID. Table 1 only provides an exemplary introduction to the message name, message identifier (i.e., MsgID), message length (in bytes), signal name, signal description, signal length (in bits), CAN nodes that can send the CAN data frame, and CAN nodes that can receive the CAN data frame of the CAN data frame. It should not be understood as limiting the embodiments of the present application. The CAN data frame may also include message type, message transmission type, message cycle time, signal arrangement format, etc. The specific content can refer to the description of the existing communication matrix.
[0230] Table 1
[0231]
[0232] The CAN communication method provided in the embodiment of the present application will be described in detail below with reference to the accompanying drawings and specific application scenarios.
[0233] See also Figure 2 , Figure 2 FIG. 1 shows a schematic diagram of the structure of a CAN communication system provided by an embodiment of the present application. Figure 2As shown, the CAN communication system may include a CAN bus and at least two CAN nodes connected to the CAN bus ( Figure 2 CAN node 1, CAN node 2, CAN node 3, and CAN node 4 are used as examples for illustration. It is understandable that each CAN node may be a microprocessor unit such as an ECU or an MCU.
[0234] When a first device is to be added to the CAN communication system, the first device can be connected to a first CAN node ( Figure 2 (In the example, CAN node 3 is used as the first CAN node for exemplary description). It should be understood that in a CAN communication system, a virtual communication matrix can be configured based on the first MsgID and / or second MsgID corresponding to the first device, so that data can be sent and received based on the virtual communication matrix. The specific details of the virtual communication matrix can be found in the previous description and will not be repeated here.
[0235] When a third device needs to be added to the CAN communication system, the third device can also be connected to a CAN node among the at least two CAN nodes through the communication network. At this time, in the CAN communication system, a virtual communication matrix can be set according to the first MsgID and / or second MsgID corresponding to the first device, and the first MsgID and / or second MsgID corresponding to the third device, so as to send and receive data according to the virtual communication matrix. It should be understood that the CAN node connected to the third device can be the same as or different from the first CAN node connected to the first device. Among them, the process of adding a first device to the CAN communication system is similar to the process of adding a third device to the CAN communication system. The following will be exemplified by taking the example of adding a first device to the CAN communication system.
[0236] It should be noted that the first device can be connected to the first CAN node through a wired communication network such as a universal serial bus (USB) interface or Ethernet, or can be connected to the first CAN node through a wireless local area network (WLAN) (such as a wireless fidelity (Wi-Fi) network), Bluetooth (BT), near field communication technology (NFC), infrared technology (IR) or 2G / 3G / 4G / 5G and other wireless communication networks.
[0237] In the embodiment of the present application, the first CAN node can be specifically configured by a technician according to an actual scenario. For example, the technician can configure the first CAN node according to the communication network supported by the first device and the communication network supported by each CAN node.
[0238] For example, when the communication network supported by the first device is Ethernet, the CAN node that supports Ethernet connection among the at least two CAN nodes can be set as the first CAN node.
[0239] For example, when the communication network supported by the first device is Bluetooth, a CAN node that supports Bluetooth connection among the at least two CAN nodes may be set as the first CAN node.
[0240] For example, when the communication network supported by the first device is WiFi, the CAN node that supports WiFi connection among the at least two CAN nodes can be set as the first CAN node.
[0241] In an embodiment of the present application, after a first device is connected to a first CAN node via a communication network, it may send a registration request to the first CAN node to register a first MsgID and / or a second MsgID corresponding to the first device, so that data sent by the first device can be forwarded to the CAN bus via the first CAN node, and / or data required by the first device can be obtained from the CAN bus via the first CAN node and forwarded to the first device. In other words, the first CAN node may record a dynamic communication matrix corresponding to the first device, and the dynamic communication matrix recorded by the first CAN node may be combined with the original communication matrix of the CAN bus system to form a dynamic virtual communication matrix for distributed information synchronization.
[0242] Exemplarily, the first CAN node may carry a security protection check to determine whether data sent by the first device can be sent to the CAN bus, and / or determine whether the data broadcast on the CAN bus is data that the first device is allowed to obtain.
[0243] It should be understood that in order to enable data transmitted through the communication network to be broadcast on the CAN bus, or to enable data broadcast on the CAN bus to be transmitted to the first device through the communication network, the transmission protocol between the first device and the first CAN node can be modified, that is, the MsgID and data segment (data) corresponding to the CAN data frame can be added to the data transmitted based on the communication network. Therefore, when it is necessary to send the data sent by the first device to the CAN bus, the MsgID and data segment (data) in the data can be obtained, and according to Figure 1The structure shown encapsulates the contents of the MsgID and data segment to obtain a CAN data frame. Alternatively, when data broadcast on the CAN bus needs to be sent to a first device, the contents of the MsgID and data segment in the CAN data frame can be obtained and encapsulated according to the transmission protocol corresponding to the communication network to obtain data that can be transmitted through the communication network, thereby sending the data to the first device via the communication network.
[0244] Exemplarily, when the first device is connected to the first CAN node via a communication network such as Ethernet or WiFi, data can be sent and received between the first device and the first CAN node via a user datagram protocol (UDP).
[0245] See also Figure 3 , Figure 3 The following is a schematic diagram showing the structure of data transmitted based on the UDP protocol provided in the embodiment of the present application. Figure 3 As shown, each frame of data of the UDP protocol (hereinafter referred to as UDP data frame) may include a source port, a destination port, a message length, a message type, a data segment, and a check segment. The data segment of the UDP data frame may include a UDP header and a UDP datagram.
[0246] Since the data broadcast on the CAN bus needs to be Figure 1 Therefore, in order to enable the first CAN node to forward data sent by the first device to the CAN bus and / or forward data broadcast on the CAN bus to the first device, the UDP protocol between the first device and the first CAN node can be modified. That is, the MsgID and data segment content in the CAN data frame can be added to the UDP data frame.
[0247] Exemplarily, the first device can divide the UDP datagram of the UDP data frame into three fields, the first field can be used to store the content of the MsgID in the CAN data frame, the second field can be used to store the content of the data segment (data) in the CAN data frame, and the third field can be a padding segment.
[0248] Therefore, after the first CAN node receives the UDP data frame sent by the first device through a communication network such as Ethernet or WiFi, the first CAN node can obtain the MsgID and data segment (data) in the UDP data frame and Figure 1The structure shown encapsulates the MsgID and data segment (data) in the UDP data frame into a CAN data frame. The first CAN node can then forward the encapsulated CAN data frame to the CAN bus.
[0249] Similarly, after the first CAN node obtains the CAN data frame from the CAN bus, the first CAN node can obtain the MsgID and data segment (data) in the CAN data frame and send the data according to Figure 3 The structure shown encapsulates the MsgID and data segment in the CAN data frame into a UDP data frame. The first CAN node can then forward the encapsulated UDP data frame to the first device via a communication network such as Ethernet or WiFi.
[0250] The following describes the CAN communication method provided in the embodiment of the present application by taking the connection between the first device and the first CAN node via Ethernet as an example.
[0251] See also Figure 4 , Figure 4 FIG1 shows a schematic flow chart of a CAN communication method provided by an embodiment of the present application. Figure 4 As shown, the method may include:
[0252] S401: A first device sends first data to a first CAN node. The first data is used by a second device to perform an interactive operation. The second device is a device in a CAN communication system.
[0253] S402: The first CAN node determines, according to the virtual communication matrix, that the first data is data that can be sent on the CAN bus.
[0254] S403: The first CAN node sends the first data to the CAN bus.
[0255] S404: Broadcast the first data on the CAN bus.
[0256] S405 : The second CAN node obtains the first data broadcast on the CAN bus, where the second CAN node is a CAN node corresponding to the second device.
[0257] S406: The second CAN node controls the second device to perform an interactive operation according to the first data.
[0258] In the embodiment of the present application, when the first device needs to interact with the second device in the CAN communication system, the first device can send a datagram to the first CAN node via Ethernet. Figure 3 The data of the structure shown (in the embodiment of the present application, the data sent by the first device is referred to as the first data), that is, the first data can be a UDP data frame.
[0259] After receiving the first data, the first CAN node may perform a security check. For example, the first CAN node may obtain the MsgID and data in the first data and, based on the MsgID in the first data and the virtual communication matrix, determine whether the first data is transmittable on the CAN bus. Specifically, the node may determine whether the MsgID of the first data is the MsgID defined in the virtual communication matrix.
[0260] When the MsgID of the first data is not the MsgID defined in the virtual communication matrix, the first CAN node will not send the first data to the CAN bus to avoid forwarding malicious data sent by the first device to the CAN bus, which poses a security threat to the CAN communication system and reduces the security of the CAN communication system.
[0261] When the MsgID of the first data is the MsgID defined in the virtual communication matrix, the first CAN node can Figure 1 The structure shown encapsulates the MsgID and data in the first data to obtain the encapsulated third data. This third data can be the CAN data frame corresponding to the first data. In other words, the first and third data have the same content but different formats. The first CAN node can then send the third data to the CAN bus for broadcasting on the CAN bus.
[0262] When the third data is broadcast on the CAN bus, the second CAN node in the CAN communication system (for example, the ECU / MCU corresponding to the second device) can obtain the third data from the CAN bus, and can control the second device to perform corresponding interactive operations based on the third data, so that the first device can interact with the second device.
[0263] For example, in Figure 2 In the illustrated application scenario, CAN node 1 can be used to manage device A. The MsgIDs of data that CAN node 1 can receive include a first MsgID. When the first device needs to interact with device A, it can send the first data to CAN node 3 via the communication network. After receiving the first data, CAN node 3 obtains the MsgID and data in the first data and, based on the virtual communication matrix and the MsgID in the first data, determines that the first data is data that can be sent on the CAN bus. Therefore, CAN node 3 can encapsulate the MsgID and data in the first data to obtain third data, namely, a CAN data frame, and send the third data to the CAN bus.
[0264] When broadcasting the third data on the CAN bus, CAN node 1 determines that the first data is data that it can receive based on the virtual communication matrix (i.e., the MsgID of the data that CAN node 1 can receive). At this time, CAN node 1 can obtain the third data from the CAN bus and can control device A to perform corresponding interactive operations based on the third data, thereby realizing interaction between the first device and device A.
[0265] Similarly, when the second device in the CAN communication system needs to interact with the first device, the second CAN node corresponding to the second device can send data to the CAN bus (hereinafter referred to as the data sent by the second CAN node as the second data) to broadcast the second data on the CAN bus. At this time, the first CAN node can determine whether the second data is data that can be received by the first device based on the second MsgID corresponding to the first device. It should be understood that after the first device is connected to the first CAN node through the communication network, the first MsgID and / or second MsgID corresponding to the first device can be registered with the first CAN node. Therefore, the dynamic communication matrix corresponding to the first device can be recorded in the first CAN node, that is, the first MsgID and / or second MsgID corresponding to the first device can be recorded, so that it can be determined whether the second data is data that can be received by the first device based on the second MsgID.
[0266] When the second data is data that can be received by the first device, that is, when the second MsgID corresponding to the first device contains the MsgID of the second data, the first CAN node can obtain the second data from the CAN bus and can obtain the MsgID and data in the second data. Then, the first CAN node can Figure 3 The structure shown encapsulates the MsgID and data in the second data to obtain the fourth data encapsulated from the second data. This fourth data can be a UDP data frame corresponding to the second data. In other words, the second and fourth data have the same content but different formats. The first CAN node can then forward the fourth data to the first device, allowing the first device to perform the corresponding interaction operation based on the fourth data, thereby enabling interaction between the second and first devices.
[0267] For example, in Figure 2 In the illustrated application scenario, CAN node 2 can be used to manage device B. The second MsgID corresponding to the first device can include the MsgID of the second data. When device B needs to interact with the first device, CAN node 2 can send the second data to the CAN bus to broadcast the second data on the CAN bus.
[0268] When broadcasting the second data on the CAN bus, CAN node 3 determines, based on the second MsgID corresponding to the first device, that the second data is receivable by the first device. At this point, CAN node 3 can retrieve the second data from the CAN bus and obtain the MsgID and data contained in the second data. CAN node 3 can then encapsulate the MsgID and data contained in the second data to obtain encapsulated fourth data, and send the fourth data to the first device via the communication network. This allows the first device to perform the corresponding interactive operation based on the fourth data, thereby enabling interaction between device B and the first device.
[0269] See also Figure 5 , Figure 5 FIG. 1 shows a schematic diagram of the structure of a CAN communication system provided by another embodiment of the present application. Figure 5 As shown, the CAN communication system may include at least two CAN buses ( Figure 5 CAN bus 1 and CAN bus 2 are used as examples for illustration), at least two CAN nodes ( Figure 5 CAN nodes 1, 2, 3, 4, and 5 are used as examples for exemplary description. CAN nodes 1, 2, and 3 are connected to CAN bus 1, while CAN nodes 4 and 5 are connected to CAN bus 2. CAN bus 1 and CAN bus 2 are each connected to a gateway. It is understood that each CAN node can be a microprocessor unit such as an ECU or MCU.
[0270] The gateway can forward data on different CAN buses. For example, the gateway can forward data broadcast on CAN bus 1 to CAN bus 2, or it can forward data broadcast on CAN bus 2 to CAN bus 1. It should be understood that the gateway can also communicate with the cloud server. For example, the gateway can send data to the cloud server, or can receive data from the cloud server, etc.
[0271] When a first device is to be added to the CAN communication system, the first device can be connected to a first CAN node ( Figure 5 It should be understood that in the CAN communication system, a virtual communication matrix can be set according to the first MsgID and / or the second MsgID corresponding to the first device, so that data can be sent and received according to the virtual communication matrix.
[0272] See also Figure 6 , Figure 6 FIG1 shows a schematic flow chart of a CAN communication method provided by another embodiment of the present application. Figure 6As shown, the method may include:
[0273] S601: A first device sends first data to a first CAN node. The first data is used by a second device to perform an interactive operation. The second device is a device in a CAN communication system.
[0274] S602: The first CAN node determines, according to the virtual communication matrix, that the first data is data that can be sent on the CAN bus.
[0275] S603: The first CAN node sends the first data to the first CAN bus.
[0276] S604: The first CAN bus broadcasts first data.
[0277] S605: The gateway obtains the first data and forwards the first data to the second CAN bus.
[0278] S606: The second CAN bus broadcasts the first data.
[0279] S607 : The second CAN node obtains the first data broadcasted on the second CAN bus, where the second CAN node is a CAN node corresponding to the second device.
[0280] S608: The second CAN node controls the second device to perform an interactive operation according to the first data.
[0281] In the embodiment of the present application, when the first device needs to interact with the second device in the CAN communication system, and the second device and the first CAN node are mounted on different CAN buses, for example, when the first CAN node is mounted on the first CAN bus and the second device is mounted on the second CAN bus, the first device can send a datagram to the first CAN node via Ethernet. Figure 3 The first data of the structure shown, that is, the first data may be a UDP data frame.
[0282] After receiving the first data, the first CAN node may perform a security check. For example, the first CAN node may obtain the MsgID and data in the first data and, based on the MsgID in the first data and the virtual communication matrix, determine whether the first data is data that can be sent on the first CAN bus. Specifically, the node may determine whether the MsgID of the first data is the MsgID defined in the virtual communication matrix.
[0283] When the MsgID of the first data is not the MsgID defined in the virtual communication matrix, the first CAN node will not send the first data to the first CAN bus to avoid forwarding malicious data sent by the first device to the first CAN bus, which poses a security threat to the CAN communication system and reduces the security of the CAN communication system.
[0284] When the MsgID of the first data is the MsgID defined in the virtual communication matrix, the first CAN node can Figure 1 The structure shown encapsulates the MsgID and data in the first data to obtain encapsulated third data, which can be a CAN data frame. The first CAN node then sends the third data to the first CAN bus, broadcasting the third data on the first CAN bus. At this point, the gateway can forward the third data broadcast on the first CAN bus to the second CAN bus, broadcasting the third data on the second CAN bus.
[0285] When the third data is broadcast on the second CAN bus, the second CAN node in the CAN communication system (for example, the second ECU corresponding to the second device) can obtain the third data from the second CAN bus and control the second device to perform corresponding interactive operations based on the third data, so that the first device can interact with the second device.
[0286] For example, in Figure 5 In the application scenario shown, CAN node 4 can be used to manage device D, and the MsgID of the data that CAN node 4 can receive can include a first MsgID. When the first device needs to interact with device D, the first device can send the first data to CAN node 3 via the communication network. After receiving the first data, CAN node 3 obtains the MsgID and data in the first data and determines, based on the virtual communication matrix and the MsgID in the first data, that the first data is data that can be sent on CAN bus 1. Therefore, CAN node 3 can encapsulate the MsgID and data in the first data to obtain the encapsulated third data, that is, obtain a CAN data frame, and send the third data to CAN bus 1. At this time, the gateway can forward the third data broadcast on CAN bus 1 to CAN bus 2 to broadcast the third data on CAN bus 2.
[0287] When broadcasting the third data on the CAN bus 2, the CAN node 4 determines that the first data is the data that it can receive based on the virtual communication matrix (i.e., the MsgID of the data that the CAN node 4 can receive). At this time, the CAN node 4 can obtain the third data from the CAN bus 2, and can control the device D to perform corresponding interactive operations based on the third data, thereby realizing the interaction between the first device and the device D.
[0288] Similarly, when the second device in the CAN communication system needs to interact with the first device, and the second device and the first CAN node are connected to different CAN buses, for example, the first CAN node is connected to the first CAN bus and the second device is connected to the second CAN bus, the second CAN node corresponding to the second device can send second data to the second CAN bus to broadcast the second data on the second CAN bus.
[0289] At this time, the gateway can forward the second data broadcast on the second CAN bus to the first CAN bus to broadcast the second data on the first CAN bus. The first CAN node can determine whether the second data is data that can be received by the first device based on the second MsgID corresponding to the first device.
[0290] When the second data is data that can be received by the first device, that is, when the second MsgID corresponding to the first device contains the MsgID of the second data, the first CAN node can obtain the second data from the first CAN bus and obtain the MsgID and data of the second data. Then, the first CAN node can Figure 3 The structure shown encapsulates the MsgID and data in the second data to obtain encapsulated fourth data, which can be a UDP data frame. The first CAN node can then forward the fourth data to the first device, allowing the first device to perform corresponding interactive operations based on the fourth data, thereby enabling interaction between the second device and the first device.
[0291] In one example, to prevent the first device from illegally using the CAN bus and to ensure the security of the CAN communication system, when the first device is added to the CAN communication system, restrictions may be placed on the specific data that the first device is allowed to receive and / or send. For example, the first CAN node may perform a security check to restrict the specific data that the first device is allowed to receive and / or send.
[0292] For example, as shown in Table 1, the signals that the first MsgID can send can be defined in the virtual communication matrix to limit the data that the first MsgID is allowed to send (hereinafter referred to as the first reserved data), thereby limiting the data that the first device is allowed to send. Similarly, the signals that the first device can receive can be restricted in the virtual communication matrix to limit the data that the first device is allowed to receive (hereinafter referred to as the second reserved data). Therefore, the first device can only send the first reserved data to the CAN bus and / or can only obtain the second reserved data from the CAN bus, so as to prevent the first device from sending malicious data to the CAN bus and / or prevent the first device from leaking or tampering with the data broadcast on the CAN bus, thereby improving the security of the CAN communication system.
[0293] That is, when the first CAN node receives the first data sent by the first device, the first CAN node can perform a security protection check. Exemplarily, the first CAN node can determine whether the MsgID of the first data is the MsgID defined in the virtual communication matrix, and determine whether the first data is the first reserved data in the virtual communication matrix. For example, the message header and message content of the first data can be analyzed to determine the signal corresponding to the first data, thereby determining whether the first data is the first reserved data in the virtual communication matrix. When it is determined that the MsgID of the first data is not the MsgID defined in the virtual communication matrix, or the first data is not the first reserved data in the virtual communication matrix, the first CAN node may not send the first data to the CAN bus, that is, may not broadcast the first data on the CAN bus, so as to avoid the first device sending malicious data to the CAN bus, posing a security threat to the CAN communication system, thereby reducing the security of the CAN communication system.
[0294] When it is determined that the MsgID of the first data is the MsgID defined in the virtual communication matrix, and the first data is the first reserved data in the virtual communication matrix, the first CAN node can Figure 1 The structure shown encapsulates the MsgID and data in the first data to obtain the encapsulated third data, and then sends the third data to the CAN bus. Therefore, other CAN nodes in the CAN communication system can obtain the third data from the CAN bus based on the virtual communication matrix and control corresponding devices to perform corresponding interactive operations based on the third data.
[0295] Similarly, when the first CAN node determines that the second data broadcast on the CAN bus is data required by the first device, the first CAN node may perform a security check. For example, the first CAN node may determine whether the second data is second reserved data in the virtual communication matrix, that is, whether the second data broadcast on the CAN bus is data that the first device can obtain from the CAN bus. If the second data is not the second reserved data in the virtual communication matrix, that is, the second data is not data that the first device can obtain, the first CAN node may not send the second data to the first device to prevent the data transmitted on the CAN bus from being leaked or illegally tampered with, thereby reducing the security of the CAN communication system.
[0296] When the second data is the second reserved data in the virtual communication matrix, the first CAN node can obtain the second data from the CAN bus and can Figure 3 The structure shown encapsulates MsgID and data in the second data to obtain fourth data, and sends the fourth data to the first device through the communication network, so that the first device can perform corresponding interactive operations according to the fourth data.
[0297] In one possible implementation, since the first device is connected to the first CAN node through a communication network such as Ethernet, Bluetooth or WiFi, so as to join the CAN communication system through the first CAN node, and since the real-time reliability of the communication network is often not as high as the real-time reliability of the shielded twisted pair cable of the CAN bus, in an embodiment of the present application, the communication layer of the first device and the communication layer of the first CAN node can be modified to improve the real-time reliability between the first device and the first CAN node, and / or enhance the fault tolerance of delay jitter.
[0298] In one example, the connection mode between the first device and the first CAN node in the communication layer can be modified. For example, the connection mode between the first device and the first CAN node can be modified to a multi-connection mode to improve the real-time reliability between the first device and the first CAN node through multiple connections.
[0299] For example, the connection between the first device and the first CAN node may be performed using a multi-connection protocol such as the media redundancy protocol (MRP), the parallel redundancy protocol (PRP), or the high-availability seamless redundancy (HSR).
[0300] In another example, redundant information, error correction code, fountain code, etc. may be added to the starting segment of the first data sent by the first device, and / or redundant information, error correction code, fountain code, etc. may be added to the ending segment of the first data to improve the real-time reliability between the first device and the first CAN node through redundancy, error correction, recovery, etc.
[0301] In another example, a rate adjustment buffer can be constructed in the communication layer of the first CAN node to obtain the first data sent by the first device through the rate adjustment buffer, and after determining that the correct first data has arrived, the first data is sent to the CAN bus to reduce the delay that may be caused by retransmission and enhance the tolerance to delay jitter.
[0302] For example, due to the high speed of a communication network such as Ethernet, Bluetooth, or WiFi, to prevent the faster transmitted first data from impacting and / or interfering with other data being broadcast on the CAN bus, the first CAN node may reduce the rate at which the first data is transmitted to the CAN bus. For example, the first data may be cached in a rate adjustment buffer and then transmitted to the CAN bus at a lower rate. The rate at which the first CAN node transmits the first data to the CAN bus may be determined based on actual scenarios and is not specifically limited in this embodiment of the present application.
[0303] It should be understood that the virtual communication matrix in the CAN communication system can be upgraded and updated according to actual application scenarios. For example, some of the contents defined in the virtual communication matrix can be added or deleted, and / or some of the contents defined in the virtual communication matrix can be modified according to actual application scenarios that may arise in the future, so as to meet the usage requirements of application scenarios that may arise in the future, which can effectively improve the user experience.
[0304] The CAN communication method provided in the embodiment of the present application is exemplarily described below in combination with some possible application scenarios.
[0305] For example, when it is necessary to add a driving recorder to the CAN communication system of a car, the driving recorder can be connected to a CAN node in the CAN communication system (such as the vehicle ECU) through a communication network (such as vehicle Ethernet or USB), so that the driving recorder can interact with the body control domain ECU in the CAN communication system through the vehicle ECU, so that in the event of an emergency collision, the body control domain ECU can send a photo request to the driving recorder to start the driving recorder to take photos, or when the driving recorder detects that a pedestrian or vehicle is close, it can send a danger reminder to the body control domain ECU so that the body control domain ECU can perform corresponding operations to avoid accidents.
[0306] In this case, in a CAN communication system, a virtual communication matrix can refer to a vehicle's original communication matrix, with a first MsgID corresponding to the dashcam (i.e., the MsgID for data the dashcam can send). Simultaneously, based on the interaction between the dashcam and the body control domain ECU, the virtual communication matrix also defines a second MsgID corresponding to the dashcam (i.e., the MsgID for data the dashcam can receive, which can include, for example, the MsgID for data sent by the body control domain ECU), as well as modified MsgIDs for data the body control domain ECU can receive (e.g., modifying the MsgID for data the body control domain ECU can receive so that it can receive the "hazard alert" MsgID), and the CAN nodes that can receive the transmitted data (e.g., modifying the CAN nodes that can receive "photo request" so that they include the dashcam). Furthermore, the virtual communication matrix can also define data the dashcam can receive (e.g., photo request, etc.) and data it can send (e.g., hazard alert, etc.).
[0307] Among them, after the driving recorder is connected to the vehicle ECU through a communication network such as on-board Ethernet or USB, the driving recorder can send a registration request to the vehicle ECU to register the first MsgID and second MsgID corresponding to the driving recorder with the vehicle ECU, that is, through registration, the vehicle ECU is informed of the MsgID of the data that the driving recorder can send and the MsgID of the data that it can receive.
[0308] When a collision occurs, the body control domain ECU can send data (such as a photo request) to the CAN bus to inform the driving recorder to take a photo. At this time, the vehicle ECU determines that the data is receivable by the driving recorder based on the second MsgID corresponding to the driving recorder and the MsgID of the data, and determines that the data is receivable by the driving recorder based on the virtual communication matrix (that is, the data that the driving recorder can receive as defined in the virtual communication matrix). Therefore, the vehicle ECU can obtain the data from the CAN bus and send it to the driving recorder according to the data. Figure 3 The structure shown converts this data into a UDP data frame. The vehicle ECU can then send this UDP data frame to the dashcam via a communication network such as the vehicle's Ethernet or USB. After receiving the UDP data frame, the dashcam can take a photo.
[0309] Alternatively, when the dashcam detects a pedestrian or vehicle in close proximity, it can send data (such as a danger alert) to the vehicle ECU via a communication network such as the on-board Ethernet or USB to inform the body control domain ECU of the perceived danger. At this point, the vehicle ECU determines that the data is broadcast on the CAN bus based on the MsgID of the data and the virtual communication matrix (i.e., the data that the dashcam can send, as defined in the virtual communication matrix). Therefore, the vehicle ECU can send the data to the CAN bus to broadcast the data on the CAN bus. The body control domain ECU obtains the data from the CAN bus based on the MsgID of the data it can receive, and performs corresponding interactive operations based on the data, such as actively increasing the braking force to prevent accidents.
[0310] For example, when a robot needs to be added to the CAN communication system of a car to read the conditions inside the car (such as the window status, sunshade status or temperature inside the car, etc., the specific data that can be read can be defined in the virtual communication matrix) to assist in warning and / or prompt the temperature according to the conditions inside the car, the robot can be connected to a CAN node in the CAN communication system (such as the vehicle ECU) through a communication network (such as WiFi), so that the robot can interact with the body control domain ECU in the CAN communication system through the vehicle ECU.
[0311] At this time, in the CAN communication system, according to the interaction between the robot and the body control domain ECU, etc., the virtual communication matrix can define a second MsgID corresponding to the robot (that is, the MsgID of the data that the robot can receive, for example, it can include the MsgID of the data sent by the body control domain ECU), and at the same time, the CAN node that can receive the data sent by the body control domain ECU, etc. is modified, that is, the vehicle ECU corresponding to the robot is added, so that the robot can obtain the data sent by the body control domain ECU, etc. through the vehicle ECU.
[0312] Among them, after the robot is connected to the vehicle ECU through a communication network such as WiFi, the robot can send a registration request to the vehicle ECU to register the second MsgID corresponding to the robot with the vehicle ECU, that is, through registration, the robot informs the vehicle ECU of the MsgID of the data that the robot can receive.
[0313] Therefore, when the data broadcast on the CAN bus is the window status, sunshade status or vehicle temperature, the vehicle ECU determines that the data is the data that the robot needs to receive based on the second MsgID corresponding to the robot and the MsgID of the data, and determines that the data is the data that the robot can receive based on the virtual communication matrix (that is, the data that the robot can receive defined in the virtual communication matrix). Therefore, the vehicle ECU can obtain the data from the CAN bus and determine the data based on the second MsgID corresponding to the robot and the MsgID of the data. Figure 3 The structure shown converts this data into a UDP data frame. The vehicle's ECU then sends this UDP data frame to the robot via a communication network such as WiFi. Upon receiving this UDP data frame, the robot can announce information such as the window status or the interior temperature, or issue an alarm if a window is not closed or the temperature is too high or too low.
[0314] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0315] Corresponding to the CAN communication method described in the above embodiment, the embodiment of the present application further provides a CAN communication device, and each module of the device can correspond to implement each step of the CAN communication method.
[0316] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of this application. Their specific functions and technical effects can be found in the method embodiment section and will not be repeated here.
[0317] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0318] See also Figure 7 , Figure 7 FIG. 1 shows a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 7 As shown, the electronic device 7 may include at least one processor 70, at least one memory 71, a controller 72 (also referred to as a CAN controller), and a transceiver 73. The transceiver may include a receiver and / or a transmitter. The processor 70 may be connected to the controller 72 and the memory 71, respectively. The controller 72 may also be connected to the memory 71 and the transceiver 73, respectively.
[0319] Among them, the memory 71 can store application data, computer programs and other data. The processor 70 refers to a device with computing capabilities. For example, the processor can be a microcontroller unit (MCU), a central processing unit (CPU), etc. The processor 70 can read and execute computer programs from the memory 71 to enable the electronic device 7 to implement the steps in any of the above-mentioned method embodiments. The processor 70 can also process the application data in the memory 71. The controller 72 can control the receiver to receive data on the CAN bus and store the received data in the memory 71 or send it to the processor 70. The controller 72 can also obtain data from the processor 70 or the memory 71 and control the transmitter to send the data on the CAN bus.
[0320] Optionally, the controller 72 may be disposed inside the processor 70 or outside the processor 70 ( Figure 7 Similarly, the memory 71 may be provided inside the processor 70 or outside the processor 70 ( Figure 7 The example of setting outside the processor 70 is used for exemplary description).
[0321] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program. When the computer program is executed by a computer, the computer is enabled to implement the steps of any of the above method embodiments.
[0322] An embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device implements the steps of any of the above method embodiments.
[0323] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program, when executed by the processor, can implement the steps of the above-mentioned various method embodiments. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include at least: any entity or device that can carry the computer program code to the device / electronic device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electric carrier signal, a telecommunication signal and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, a computer-readable storage medium cannot be an electric carrier signal or a telecommunication signal.
[0324] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0325] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0326] In the embodiments provided in the present application, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0327] The units described as separate components may or may not be physically separate, and the components shown as units 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 these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0328] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.
Claims
1. A CAN communication method, characterized in that: The method is applied to a controller area network (CAN) communication system, the CAN communication system including a first device, a second device, a CAN bus, and at least two CAN nodes connected to the CAN bus, the at least two CAN nodes including a first CAN node and a second CAN node, the first device being connected to the first CAN node via a communication network, the second CAN node being used to control the second device, the CAN communication system being provided with a virtual communication matrix, the virtual communication matrix being obtained by expanding an original communication matrix of the CAN communication system according to the first device, and the method comprising: The first CAN node acquires first data, where the first data is sent by the first device and is used to instruct the second device to perform a corresponding interactive operation; The first CAN node determines, according to the virtual communication matrix, whether the first data is data allowed to be sent on the CAN bus; When the first data is data allowed to be sent on the CAN bus, the first CAN node sends the first data to the CAN bus, so that the second CAN node obtains the first data from the CAN bus and controls the second device to perform corresponding interactive operations according to the first data.
2. The method according to claim 1, characterized in that The at least two CAN nodes further include a third CAN node, and the method further includes: The first CAN node obtains second data from the CAN bus, where the second data is sent by the third CAN node, and the second data is used to instruct the first device to perform a corresponding interactive operation; The first CAN node determines, based on the virtual communication matrix, whether the second data is data allowed to be received by the first device; When the second data is data that the first device is allowed to receive, the first CAN node sends the second data to the first device, so that the first device performs a corresponding interactive operation according to the second data.
3. The method according to claim 1 or 2, characterized in that The virtual communication matrix is based on the original communication matrix, with the addition of a definition of a first message identifier and the addition of the first message identifier to the message identifiers of data received by the first interactive device, and / or based on the original communication matrix, with the addition of a definition of a second message identifier and the addition of the first CAN node to the CAN nodes at which data sent by the second interactive device is received; The first message identifier is a message identifier for data allowed to be sent by the first device, the second message identifier is a message identifier for data allowed to be received by the first device, the first interactive device and the second interactive device are devices that interact with the first device in the CAN communication system, the first interactive device includes the second device, and / or the second interactive device includes the second device.
4. The method according to claim 3, characterized in that The virtual communication matrix also defines first reserved data and / or second reserved data, wherein the first reserved data is data that the first device is allowed to send on the CAN bus through the first CAN node, and the second reserved data is data that the first device is allowed to obtain from the CAN bus through the first CAN node.
5. The method according to any one of claims 1 to 4, characterized in that The first CAN node determines, according to the virtual communication matrix, whether the first data is data allowed to be sent on the CAN bus, including: The first CAN node obtains a message identifier of the first data; Determining, by the first CAN node, whether a message identifier of the first data is a first message identifier defined in the virtual communication matrix; When the message identifier of the first data is the first message identifier, the first CAN node determines that the first data is data allowed to be sent on the CAN bus.
6. The method according to any one of claims 1 to 4, characterized in that The first CAN node determines, according to the virtual communication matrix, whether the first data is data allowed to be sent on the CAN bus, including: The first CAN node obtains a message identifier of the first data; The first CAN node determines whether a message identifier of the first data is a first message identifier defined in the virtual communication matrix, and determines whether the first data is first reserved data defined in the virtual communication matrix; When the message identifier of the first data is the first message identifier, and the first data is the first reserved data, the first CAN node determines that the first data is data allowed to be sent on the CAN bus.
7. The method according to any one of claims 1 to 6, characterized in that The first CAN node sending the first data to the CAN bus includes: The first CAN node encapsulates the first data according to a data structure corresponding to the CAN bus to obtain third data; The first CAN node sends the third data to the CAN bus.
8. The method according to claim 2, characterized in that The first CAN node determines, according to the virtual communication matrix, whether the second data is data allowed to be received by the first device, including: The first CAN node obtains a message identifier of the second data; Determining, by the first CAN node, whether a message identifier of the second data is a second message identifier defined in the virtual communication matrix; When the message identifier of the second data is the second message identifier, the first CAN node determines that the second data is data allowed to be received by the first device.
9. The method according to claim 2, characterized in that The first CAN node determines, according to the virtual communication matrix, whether the second data is data allowed to be received by the first device, including: The first CAN node obtains a message identifier of the second data; The first CAN node determines whether a message identifier of the second data is a second message identifier defined in the virtual communication matrix, and determines whether the second data is second reserved data defined in the virtual communication matrix; When the message identifier of the second data is the second message identifier, and the second data is the second reserved data, the first CAN node determines that the second data is data allowed to be received by the first device.
10. The method according to any one of claims 2, 8 to 9, characterized in that The first CAN node sending the second data to the first device includes: The first CAN node encapsulates the second data according to a data structure corresponding to the communication network to obtain fourth data; The first CAN node sends the fourth data to the first device.
11. A CAN communication system, characterized in that: The system comprises a first device, a second device, a CAN bus, and at least two CAN nodes connected to the CAN bus, wherein the at least two CAN nodes include a first CAN node and a second CAN node, the first device is connected to the first CAN node via a communication network, the second CAN node is used to control the second device, and a virtual communication matrix is provided in the CAN communication system, wherein the virtual communication matrix is obtained by expanding an original communication matrix of the CAN communication system according to the first device; The first device is used to send first data to the first CAN node, where the first data is used to instruct the second device to perform a corresponding interactive operation; The first CAN node is used to obtain first data and determine whether the first data is data allowed to be sent on the CAN bus according to the virtual communication matrix; When the first data is data allowed to be sent on the CAN bus, the first CAN node is further configured to send the first data to the CAN bus; The second CAN node is used to obtain the first data from the CAN bus and control the second device to perform corresponding interactive operations according to the first data.
12. The system according to claim 11, wherein: The at least two CAN nodes further include a third CAN node; The third CAN node is used to send second data to the CAN bus, where the second data is used to instruct the first device to perform a corresponding interactive operation; The first CAN node is further configured to obtain the second data from the CAN bus and determine, based on the virtual communication matrix, whether the second data is data that the first device is allowed to receive; When the second data is data allowed to be received by the first device, the first CAN node is further configured to send the second data to the first device; The first device is used to receive the second data and perform corresponding interactive operations according to the second data.
13. The system according to claim 11 or 12, characterized in that The virtual communication matrix is based on the original communication matrix, with the addition of a definition of a first message identifier and the addition of the first message identifier to the message identifiers of data received by the first interactive device, and / or based on the original communication matrix, with the addition of a definition of a second message identifier and the addition of the first CAN node to the CAN nodes at which data sent by the second interactive device is received; The first message identifier is a message identifier for data allowed to be sent by the first device, the second message identifier is a message identifier for data allowed to be received by the first device, the first interactive device and the second interactive device are devices that interact with the first device in the CAN communication system, the first interactive device includes the second device, and / or the second interactive device includes the second device.
14. The system according to claim 13, wherein: The virtual communication matrix also defines first reserved data and / or second reserved data. The first reserved data is data that the first device is allowed to send on the CAN bus through the first CAN node, and the second reserved data is data that the first device is allowed to obtain from the CAN bus through the first CAN node.
15. The system according to any one of claims 11 to 14, characterized in that The first CAN node is further configured to obtain a message identifier of the first data and determine whether the message identifier of the first data is a first message identifier defined in the virtual communication matrix; When the message identifier of the first data is the first message identifier, the first CAN node is further configured to determine that the first data is data allowed to be sent on the CAN bus.
16. The system according to any one of claims 11 to 14, characterized in that The first CAN node is further configured to obtain a message identifier of the first data, determine whether the message identifier of the first data is a first message identifier defined in the virtual communication matrix, and determine whether the first data is first reserved data defined in the virtual communication matrix; When the message identifier of the first data is the first message identifier, and the first data is the first reserved data, the first CAN node is further configured to determine that the first data is data allowed to be sent on the CAN bus.
17. The system according to any one of claims 11 to 16, characterized in that The first CAN node is further configured to encapsulate the first data according to a data structure corresponding to the CAN bus to obtain third data, and send the third data to the CAN bus.
18. The system according to claim 12, wherein: The first CAN node is further configured to obtain a message identifier of the second data; and determine whether the message identifier of the second data is a second message identifier defined in the virtual communication matrix; When the message identifier of the second data is the second message identifier, the first CAN node is further configured to determine that the second data is data allowed to be received by the first device.
19. The system according to claim 12, wherein: The first CAN node is further configured to obtain a message identifier of the second data; determine whether the message identifier of the second data is a second message identifier defined in the virtual communication matrix, and determine whether the second data is second reserved data defined in the virtual communication matrix; When the message identifier of the second data is the second message identifier, and the second data is the second reserved data, the first CAN node is further configured to determine that the second data is data that the first device is allowed to receive.
20. The system according to any one of claims 12, 18 to 19, characterized in that The first CAN node is further configured to encapsulate the second data according to a data structure corresponding to the communication network to obtain fourth data, and send the fourth data to the first device.
21. The system according to any one of claims 11 to 20, characterized in that The first device is connected to the first CAN node via a multi-connection mode.
22. The system according to any one of claims 11 to 21, characterized in that A rate adjustment buffer is provided in the first CAN node, and the rate adjustment buffer is used to store the first data acquired by the first CAN node.
23. An electronic device, characterized in that: A CAN communication system is provided in the electronic device, and the CAN communication system includes a first device, a second device, a CAN bus, and at least two CAN nodes connected to the CAN bus, the at least two CAN nodes include a first CAN node and a second CAN node, the first device is connected to the first CAN node via a communication network, and the second CAN node is used to control the second device. A virtual communication matrix is provided in the CAN communication system, and the virtual communication matrix is obtained by expanding the original communication matrix of the CAN communication system according to the first device, and the first CAN node is used to execute the CAN communication method described in any one of claims 1 to 10.
24. An electronic device comprising a memory, a processor, a controller and a transceiver, characterized in that: The controller is used to control the transceiver to receive data on the CAN bus and store the received data in the memory or send it to the processor. The controller is also used to obtain data from the processor or the memory and control the transceiver to send the obtained data to the CAN bus. The memory stores a computer program that can be run on the processor. When the processor executes the computer program, the electronic device implements the CAN communication method according to any one of claims 1 to 10.
25. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a computer, the computer is caused to implement the CAN communication method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Open systems and the corresponding interfaces for automotive electronics (OSEK) network management-based controller area network (CAN) management method
CN102801551A
Application message notification method and system based on network matrix, and storage medium
CN112468600A