CN116488953A - CAN communication method, electronic equipment and CAN communication system - Google Patents

CAN communication method, electronic equipment and CAN communication system Download PDF

Info

Publication number
CN116488953A
CN116488953A CN202210046889.1A CN202210046889A CN116488953A CN 116488953 A CN116488953 A CN 116488953A CN 202210046889 A CN202210046889 A CN 202210046889A CN 116488953 A CN116488953 A CN 116488953A
Authority
CN
China
Prior art keywords
data
node
bus
message identifier
communication matrix
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210046889.1A
Other languages
Chinese (zh)
Inventor
周艳
邱建
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN202210046889.1A priority Critical patent/CN116488953A/en
Priority to PCT/CN2022/141599 priority patent/WO2023134428A1/en
Publication of CN116488953A publication Critical patent/CN116488953A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40006Architecture of a communication node
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40208Bus networks characterized by the use of a particular bus standard
    • H04L2012/40215Controller Area Network CAN
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Small-Scale Networks (AREA)

Abstract

The application is applicable to the technical field of communication, and particularly relates to a CAN communication method, electronic equipment and a CAN communication system. According to the method, when the first equipment needs to be added to the CAN bus, the first equipment CAN be connected with a first CAN node in the CAN communication system through a communication network, and an original communication matrix of the CAN communication system is expanded according to the first equipment to obtain a virtual communication matrix, so that the first equipment CAN be dynamically added to the CAN communication system according to the virtual communication matrix, the first equipment CAN communicate with other CAN nodes on the CAN bus through the first CAN node, namely, the first equipment CAN send first data to the CAN bus through the first CAN node, interaction CAN be carried out with other equipment on the CAN bus according to the first data, the application range of the CAN communication system is greatly expanded, and user experience is improved.

Description

CAN communication method, electronic equipment and CAN communication system
Technical Field
The application belongs to the technical field of communication, and particularly relates to a CAN communication method, electronic equipment and a CAN communication system.
Background
The controller area network (controller area network, CAN) communication system CAN be widely applied to the field of automobile internal communication and other industries. The CAN communication system may comprise a CAN bus and at least two electronic control units (electronic control unit, ECU) or micro control units (micro controller unit, MCU) or the like connected to the CAN bus. At present, in a CAN communication system, each ECU/MCU carries out data transmission and reception on a CAN bus according to a predefined communication matrix, and newly-added hardware equipment cannot access the CAN bus and cannot communicate with other ECUs/MCUs on the CAN bus.
Disclosure of Invention
The embodiment of the application provides a CAN communication method, electronic equipment and a CAN communication system, which CAN solve the problems that newly-added hardware equipment cannot access a CAN bus and cannot communicate with other ECU/MCU on the CAN bus in the existing CAN communication system.
In a first aspect, an embodiment of the present application provides a CAN communication method, applied to a controller area network CAN communication system, where 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, where 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, and a virtual communication matrix is provided in the CAN communication system, where the virtual communication matrix is obtained by expanding an original communication matrix of the CAN communication system according to the first device, and the method may include:
the first CAN node acquires first data, wherein the first data is sent by the first equipment and is used for indicating the second equipment to execute corresponding interactive operation;
The first CAN node determines whether the first data is allowed to be sent on the CAN bus or not according to the virtual communication matrix;
when the first data is the 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 equipment to execute corresponding interaction operation according to the first data.
In the above CAN communication method, when the first device needs to be added to the CAN bus, the first device CAN be connected with a 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 the virtual communication matrix, so that the first device CAN be dynamically added to the CAN communication system according to the virtual communication matrix, 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 acquire the first data sent by the first device from the CAN bus, and CAN control the corresponding second device to execute interactive operation according to the first data, thereby realizing the purpose of interaction between the first device and the other devices on the CAN bus, expanding the application range of the CAN communication system, and improving the user experience.
In one possible implementation, the at least two CAN nodes further include a third CAN node, and the method may further include:
the first CAN node acquires second data from the CAN bus, wherein the second data is sent by the third CAN node, and the second data is used for indicating the first equipment to execute corresponding interactive operation;
the first CAN node determines whether the second data is data which allows the first equipment to receive according to the virtual communication matrix;
and when the second data is the data which is allowed to be received by the first equipment, the first CAN node sends the second data to the first equipment so that the first equipment executes corresponding interactive operation according to the second data.
It should be appreciated that the third CAN node and the second CAN node may be the same CAN node or may be different CAN nodes.
In the CAN communication method provided by the implementation mode, the first CAN node CAN acquire the 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 execute corresponding interaction operation according to the second data, the purpose of interaction between other devices on the CAN bus and the first device is achieved, the application range of the CAN communication system is expanded, and the user experience is improved.
In a possible implementation manner, the virtual communication matrix is to add a definition of a first message identifier to a message identifier of data received by a first interaction device based on the original communication matrix and/or add a definition of a second message identifier to a CAN node of the data received by a second interaction device based on the original communication matrix and add the first CAN node;
the first message identifier is a message identifier of data allowed to be sent by the first device, the second message identifier is a message identifier of data allowed to be received by the first device, the first interaction device and the second interaction device are devices which interact with the first device in the CAN communication system, the first interaction device comprises the second device, and/or the second interaction device comprises the second device.
In an exemplary embodiment, the virtual communication matrix further defines first reserved data and/or second reserved data, where the first reserved data is data that allows the first device to send on the CAN bus through the first CAN node, and the second reserved data is data that allows the first device to obtain from the CAN bus through the first CAN node.
In the CAN communication method provided by this implementation manner, in order to avoid illegal use of the CAN bus by the first device to ensure security of the CAN communication system, when the first device is added to the CAN communication system, data that the first device is allowed to receive and/or data that is allowed to transmit may be limited. The virtual communication matrix CAN limit the MsgID of the data allowed to be sent by the first device and/or the specific content of the data allowed to be sent by the first device, and/or limit the MsgID of the data allowed to be received by the first device and/or the specific content of the data allowed to be received by the first device, so that the data allowed to be sent to the CAN bus by the first device is limited, and/or the data allowed to be acquired from the CAN bus by the first device is limited, the first device is prevented from sending malicious data to the CAN bus, the security threat brought by the malicious data to the CAN communication system is reduced, the data transmitted in the CAN bus is prevented from being leaked or illegally tampered, and the security of the CAN communication system is improved.
In one example, the determining, by the first CAN node, whether the first data is data allowed to be sent on the CAN bus according to the virtual communication matrix may include:
The first CAN node acquires a message identifier of the first data;
the first CAN node determines whether the message identifier of the first data is a first message identifier defined in the virtual communication matrix;
and when the message identifier of the first data is the first message identifier, the first CAN node determines that the first data is allowed to be sent on the CAN bus.
In the CAN communication method provided by this implementation manner, after the first CAN node receives the first data, a security protection check may be performed according to the first MsgID defined in the virtual communication matrix, that is, the MsgID in the first data may be obtained, and it is determined 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 may determine the first data as data allowed to be transmitted on the CAN bus and transmit the first data to the CAN bus. And when the MsgID of the first data is not the first MsgID defined in the virtual communication matrix, the first CAN node does not send the first data to the CAN bus, so that malicious data sent by the first equipment is prevented from being forwarded to the CAN bus, the safety threat to the CAN communication system is reduced, and the safety of the CAN communication system is improved.
In another example, the determining, by the first CAN node, whether the first data is data allowed to be sent on the CAN bus according to the virtual communication matrix may include:
the first CAN node acquires a message identifier of the first data;
the first CAN node determines whether the 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.
In the CAN communication method provided by this implementation manner, after the first CAN node receives the first data, security protection inspection may be performed according to the first MsgID and the first reserved data defined in the virtual communication matrix, that is, the MsgID and specific content in the first data may be obtained, and it is determined 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 may determine that the first data is data allowed to be transmitted on the CAN bus and transmit the first data to the CAN bus. And when the MsgID of the first data is not the first MsgID defined in the virtual communication matrix, the first CAN node does not send the first data to the CAN bus, so that malicious data sent by the first equipment is prevented from being forwarded to the CAN bus, the security threat to the CAN communication system is reduced, and the security of the CAN communication system is improved.
Illustratively, the first CAN node sending the first data to the CAN bus may include:
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.
In the CAN communication method provided by this implementation manner, a transmission protocol between the first device and the first CAN node may be modified, that is, the MsgID and the content of the data segment (data) corresponding to the CAN data frame may be added to the first data transmitted based on the communication network. Therefore, when the first data sent by the first device is required to be sent to the CAN bus, the content of the MsgID and the data segment (data) in the first data CAN be obtained, and the content of the MsgID and the data segment (data) CAN be packaged according to the data structure corresponding to the CAN bus, so that third data which CAN be broadcast on the CAN bus CAN be obtained, and the data sent by the first device CAN be broadcast on the CAN bus.
In one example, the first CAN node determining whether the second data is data that allows the first device to receive according to the virtual communication matrix may include:
The first CAN node acquires a message identifier of the second data;
the first CAN node determines whether the message identifier of the second data is a second message identifier defined in the virtual communication matrix;
and when the message identifier of the second data is the second message identifier, the first CAN node determines that the second data is the data which allows the first equipment to receive.
In the CAN communication method provided by the implementation manner, after the first CAN node receives the second data, the safety protection check CAN be performed according to the second MsgID defined in the virtual communication matrix, so that the data transmitted in the CAN bus is prevented from being leaked or illegally tampered, and the safety of the CAN communication system is improved.
In another example, the first CAN node determining whether the second data is data that allows the first device to receive according to the virtual communication matrix may include:
the first CAN node acquires a message identifier of the second data;
the first CAN node determines whether the 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 which allows the first device to receive.
In the CAN communication method provided by the implementation manner, after the first CAN node receives the second data, safety protection inspection CAN be performed according to the second MsgID and the second reserved data defined in the virtual communication matrix, so that the data transmitted in the CAN bus is prevented from being leaked or illegally tampered, and the safety of the CAN communication system is improved.
For example, the first CAN node sending the second data to the first device may include:
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.
In the CAN communication method provided in this implementation manner, 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 may be obtained, and the MsgID and the content of the data segment (data) are encapsulated according to the data structure corresponding to the communication network between the first device and the first CAN node, so as to obtain data that may be transmitted to the first device through the communication network.
In a second aspect, an embodiment of the present application provides a CAN communication method, applied to a controller area network CAN communication system, where 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, where 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, and 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, where the method may include:
the first CAN node acquires second data from the CAN bus, wherein the second data is sent by the second CAN node and is used for indicating the first equipment to execute corresponding interactive operation;
the first CAN node determines whether the second data is data which allows the first equipment to receive according to the virtual communication matrix;
and when the second data is the data which is allowed to be received by the first equipment, the first CAN node sends the second data to the first equipment so that the first equipment executes corresponding interactive operation according to the second data.
In one possible implementation, the at least two CAN nodes further include a third CAN node, and the method may further include:
the first CAN node acquires first data, wherein the first data is sent by the first equipment and is used for indicating the second equipment to execute corresponding interactive operation;
the first CAN node determines whether the first data is allowed to be sent on the CAN bus or not according to the virtual communication matrix;
when the first data is the 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 equipment to execute corresponding interaction operation according to the first data.
In a possible implementation manner, the virtual communication matrix is to add a definition of a first message identifier to a message identifier of data received by a first interaction device based on the original communication matrix and/or add a definition of a second message identifier to a CAN node of the data received by a second interaction device based on the original communication matrix and add the first CAN node;
The first message identifier is a message identifier of data allowed to be sent by the first device, the second message identifier is a message identifier of data allowed to be received by the first device, the first interaction device and the second interaction device are devices which interact with the first device in the CAN communication system, the first interaction device comprises the second device, and/or the second interaction device comprises the second device.
In another possible implementation manner, first reserved data and/or second reserved data are/is further defined in the virtual communication matrix, where the first reserved data are data that allow the first device to send on the CAN bus through the first CAN node, and the second reserved data are data that allow the first device to obtain from the CAN bus through the first CAN node.
In one example, the determining, by the first CAN node, whether the first data is data allowed to be sent on the CAN bus according to the virtual communication matrix may include:
the first CAN node acquires a message identifier of the first data;
the first CAN node determines whether the message identifier of the first data is a first message identifier defined in the virtual communication matrix;
And when the message identifier of the first data is the first message identifier, the first CAN node determines that the first data is allowed to be sent on the CAN bus.
In another example, the determining, by the first CAN node, whether the first data is data allowed to be sent on the CAN bus according to the virtual communication matrix may include:
the first CAN node acquires a message identifier of the first data;
the first CAN node determines whether the 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.
Illustratively, the first CAN node sending the first data to the CAN bus may include:
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.
In one example, the first CAN node determining whether the second data is data that allows the first device to receive according to the virtual communication matrix may include:
the first CAN node acquires a message identifier of the second data;
the first CAN node determines whether the message identifier of the second data is a second message identifier defined in the virtual communication matrix;
and when the message identifier of the second data is the second message identifier, the first CAN node determines that the second data is the data which allows the first equipment to receive.
In another example, the first CAN node determining whether the second data is data that allows the first device to receive according to the virtual communication matrix may include:
the first CAN node acquires a message identifier of the second data;
the first CAN node determines whether the 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 which allows the first device to receive.
For example, the first CAN node sending the second data to the first device may include:
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.
In a third aspect, an embodiment of the present application provides a CAN communication apparatus, which is applied to a controller area network CAN communication system, where 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, where 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, and the second CAN node is used to control the second device, and a virtual communication matrix is provided in the CAN communication system, where the virtual communication matrix is obtained by expanding an original communication matrix of the CAN communication system according to the first device, and the apparatus may include:
The first data acquisition module is used for acquiring first data, wherein the first data are sent by the first equipment, and the first data are used for indicating the second equipment to execute corresponding interactive operation;
a first data determining module, configured to determine, according to the virtual communication matrix, whether the first data is data allowed to be sent on the CAN bus;
and the first data sending module is used for sending the first data to the CAN bus when the first data is the 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 equipment to execute corresponding interactive operation according to the first data.
In one possible implementation manner, the at least two CAN nodes further include a third CAN node, and the apparatus may further include:
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 the second data is used to instruct the first device to perform a corresponding interaction operation;
a second data determining module, configured to determine, according to the virtual communication matrix, whether the second data is data that allows the first device to receive;
And the second data sending module is used for sending the second data to the first equipment when the second data is the data which allows the first equipment to receive, so that the first equipment executes corresponding interactive operation according to the second data.
In a possible implementation manner, the virtual communication matrix is to add a definition of a first message identifier to a message identifier of data received by a first interaction device based on the original communication matrix and/or add a definition of a second message identifier to a CAN node of the data received by a second interaction device based on the original communication matrix and add the first CAN node;
the first message identifier is a message identifier of data allowed to be sent by the first device, the second message identifier is a message identifier of data allowed to be received by the first device, the first interaction device and the second interaction device are devices which interact with the first device in the CAN communication system, the first interaction device comprises the second device, and/or the second interaction device comprises the second device.
In another possible implementation manner, first reserved data and/or second reserved data are/is further defined in the virtual communication matrix, where the first reserved data are data that allow the first device to send on the CAN bus through the first CAN node, and the second reserved data are data that allow the first device to obtain from the CAN bus through the first CAN node.
In one example, the first data determination module may include:
a first identifier obtaining unit, configured to obtain a message identifier of the first data;
a first identifier determining unit, configured to determine whether a packet identifier of the first data is a first packet identifier defined in the virtual communication matrix;
and the first data determining unit is used for determining that the first data is allowed to be sent on the CAN bus when the message identifier of the first data is the first message identifier.
In another example, the first data determining module may further include:
a second identifier obtaining unit, configured to obtain a message identifier of the first data;
a second identifier determining unit, configured to determine whether a packet identifier of the first data is a first packet identifier defined in the virtual communication matrix, and determine whether the first data is first reserved data defined in the virtual communication matrix;
And the second data determining unit is used for determining that the first data is 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.
The first data transmission module may include:
the first data packaging unit is used for packaging the first data according to the data structure corresponding to the CAN bus to obtain third data;
and the first sending unit is used for sending the third data to the CAN bus.
In one example, the second data determination module may include:
a third identifier obtaining unit, configured to obtain a message identifier of the second data;
a third identifier determining unit, configured to determine whether a packet identifier of the second data is a second packet identifier defined in the virtual communication matrix;
and the third data determining unit is used for determining the second data as the data which is allowed to be received by the first equipment when the message identifier of the second data is the second message identifier.
In another example, the second data determination module may include:
A fourth identifier obtaining unit, configured to obtain a message identifier of the second data;
a fourth identifier determining unit configured to determine whether a packet identifier of the second data is a second packet identifier defined in the virtual communication matrix, and determine whether the second data is second reserved data defined in the virtual communication matrix;
and the fourth data determining unit is used for determining that the second data is data which allows the first equipment to receive when the message identifier of the second data is the second message identifier and the second data is the second reserved data.
Illustratively, the second data transmitting module may include:
the second data encapsulation unit is used for encapsulating the second data according to the data structure corresponding to the communication network to obtain fourth data;
and the second sending unit is used for sending the fourth data to the first equipment.
In a fourth aspect, an embodiment of the present application provides a CAN communication apparatus, applied to a controller area network CAN communication system, where 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, where 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, and the second CAN node is used to control the second device, and a virtual communication matrix is provided in the CAN communication system, where the virtual communication matrix is obtained by expanding an original communication matrix of the CAN communication system according to the first device, and the apparatus may include:
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 the second data is used to instruct the first device to perform a corresponding interaction operation;
a second data determining module, configured to determine, according to the virtual communication matrix, whether the second data is data that allows the first device to receive;
and the second data sending module is used for sending the second data to the first equipment when the second data is the data which allows the first equipment to receive, so that the first equipment executes corresponding interactive operation according to the second data.
In one possible implementation, the at least two CAN nodes further include a third CAN node, and the apparatus further includes:
the first data acquisition module is used for acquiring first data, wherein the first data are sent by the first equipment, and the first data are used for indicating the second equipment to execute corresponding interactive operation;
a first data determining module, configured to determine, according to the virtual communication matrix, whether the first data is data allowed to be sent on the CAN bus;
And the first data sending module is used for sending the first data to the CAN bus when the first data is the 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 equipment to execute corresponding interaction operation according to the first data.
In a possible implementation manner, the virtual communication matrix is to add a definition of a first message identifier to a message identifier of data received by a first interaction device based on the original communication matrix and/or add a definition of a second message identifier to a CAN node of the data received by a second interaction device based on the original communication matrix and add the first CAN node;
the first message identifier is a message identifier of data allowed to be sent by the first device, the second message identifier is a message identifier of data allowed to be received by the first device, the first interaction device and the second interaction device are devices which interact with the first device in the CAN communication system, the first interaction device comprises the second device, and/or the second interaction device comprises the second device.
In another possible implementation manner, first reserved data and/or second reserved data are/is further defined in the virtual communication matrix, where the first reserved data are data that allow the first device to send on the CAN bus through the first CAN node, and the second reserved data are data that allow the first device to obtain from the CAN bus through the first CAN node.
In one example, the first data determination module may include:
a first identifier obtaining unit, configured to obtain a message identifier of the first data;
a first identifier determining unit, configured to determine whether a packet identifier of the first data is a first packet identifier defined in the virtual communication matrix;
and the first data determining unit is used for determining that the first data is allowed to be sent on the CAN bus when the message identifier of the first data is the first message identifier.
In another example, the first data determining module may further include:
a second identifier obtaining unit, configured to obtain a message identifier of the first data;
a second identifier determining unit, configured to determine whether a packet identifier of the first data is a first packet identifier defined in the virtual communication matrix, and determine whether the first data is first reserved data defined in the virtual communication matrix;
And the second data determining unit is used for determining that the first data is 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.
The first data transmission module may include:
the first data packaging unit is used for packaging the first data according to the data structure corresponding to the CAN bus to obtain third data;
and the first sending unit is used for sending the third data to the CAN bus.
In one example, the second data determination module may include:
a third identifier obtaining unit, configured to obtain a message identifier of the second data;
a third identifier determining unit, configured to determine whether a packet identifier of the second data is a second packet identifier defined in the virtual communication matrix;
and the third data determining unit is used for determining the second data as the data which is allowed to be received by the first equipment when the message identifier of the second data is the second message identifier.
In another example, the second data determination module may include:
A fourth identifier obtaining unit, configured to obtain a message identifier of the second data;
a fourth identifier determining unit configured to determine whether a packet identifier of the second data is a second packet identifier defined in the virtual communication matrix, and determine whether the second data is second reserved data defined in the virtual communication matrix;
and the fourth data determining unit is used for determining that the second data is data which allows the first equipment to receive when the message identifier of the second data is the second message identifier and the second data is the second reserved data.
Illustratively, the second data transmitting module may include:
the second data encapsulation unit is used for encapsulating the second data according to the data structure corresponding to the communication network to obtain fourth data;
and the second sending unit is used for sending the fourth data to the first equipment.
In a fifth aspect, an embodiment of the present application provides a CAN communication system, including a first device, a second device, a CAN bus, and at least two CAN nodes connected to the CAN bus, where 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, and 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 configured to send first data to the first CAN node, where the first data is configured to instruct the second device to perform a corresponding interaction operation;
the first CAN node is used for acquiring first data and determining whether the first data is allowed to be sent on the CAN bus or not 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 used for sending the first data to the CAN bus;
the second CAN node is used for acquiring the first data from the CAN bus and controlling the second equipment to execute corresponding interactive operation according to the first data.
In one possible implementation, the at least two CAN nodes further comprise a third CAN node;
the third CAN node is used for sending second data to the CAN bus, and the second data is used for indicating the first equipment to execute corresponding interaction operation;
the first CAN node is further used for acquiring the second data from the CAN bus and determining whether the second data is data which allows the first device to receive according to the virtual communication matrix;
When the second data is the data which allows the first equipment to receive, the first CAN node is further used for sending the second data to the first equipment;
the first device is configured to receive the second data, and perform a corresponding interaction operation according to the second data.
In a possible implementation manner, the virtual communication matrix is to add a definition of a first message identifier to a message identifier of data received by a first interaction device based on the original communication matrix and/or add a definition of a second message identifier to a CAN node of the data received by a second interaction device based on the original communication matrix and add the first CAN node;
the first message identifier is a message identifier of data allowed to be sent by the first device, the second message identifier is a message identifier of data allowed to be received by the first device, the first interaction device and the second interaction device are devices which interact with the first device in the CAN communication system, the first interaction device comprises the second device, and/or the second interaction device comprises the second device.
In another possible implementation manner, first reserved data and/or second reserved data are/is further defined in the virtual communication matrix, where the first reserved data are data that allow the first device to send on a CAN bus through the first CAN node, and the second reserved data are data that allow the first device to obtain from the CAN bus through the first CAN node.
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;
and when the message identifier of the first data is the first message identifier, the first CAN node is further used for determining that the first data is the data allowed to be sent on the CAN bus.
In another example, the first CAN node is further configured to obtain a packet identifier of the first data, determine whether the packet identifier of the first data is a first packet 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.
The first CAN node is further configured to encapsulate the first data according to a data structure corresponding to the CAN bus, obtain third data, and send the third data to the CAN bus.
In one example, the first CAN node is further configured to obtain a message identifier of the second data; determining whether the message identifier of the second data is a second message identifier defined in the virtual communication matrix;
and when the message identifier of the second data is the second message identifier, the first CAN node is further used for determining that the second data is the data which allows the first device to receive.
In another example, the first CAN node is further configured to obtain a message identifier of the second data; determining whether a message identifier of the second data is a second message identifier defined in the virtual communication matrix, and determining 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 allows the first device to receive the second data.
The first CAN node is further configured to encapsulate the second data according to a data structure corresponding to the communication network, obtain fourth data, and send the fourth data to the first device.
Optionally, the first device is connected with the first CAN node through a multiple connection mode.
Optionally, a rate adjustment buffer is provided in the first CAN node, where the rate adjustment buffer is used to store the first data acquired by the first CAN node.
In a sixth aspect, an embodiment of the present application provides a CAN communication system, including a first device, a second device, a CAN bus, and at least two CAN nodes connected to the CAN bus, where 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, and the virtual communication matrix is obtained by expanding an original communication matrix of the CAN communication system according to the first device;
The second CAN node is used for sending second data to the CAN bus, and the second data is used for indicating the first equipment to execute corresponding interaction operation;
the first CAN node is used for acquiring the second data from the CAN bus and determining whether the second data is data which allows the first equipment to receive according to the virtual communication matrix;
when the second data is the data which allows the first equipment to receive, the first CAN node is further used for sending the second data to the first equipment;
the first device is configured to receive the second data, and perform a corresponding interaction operation according to the second data.
In one possible implementation, the at least two CAN nodes further comprise a third CAN node;
the first device is configured to send first data to the first CAN node, where the first data is configured to instruct the second device to perform a corresponding interaction operation;
the first CAN node is used for acquiring first data and determining whether the first data is allowed to be sent on the CAN bus or not 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 used for sending the first data to the CAN bus;
The third CAN node is used for acquiring the first data from the CAN bus and controlling the second equipment to execute corresponding interaction operation according to the first data.
In a possible implementation manner, the virtual communication matrix is to add a definition of a first message identifier to a message identifier of data received by a first interaction device based on the original communication matrix and/or add a definition of a second message identifier to a CAN node of the data received by a second interaction device based on the original communication matrix and add the first CAN node;
the first message identifier is a message identifier of data allowed to be sent by the first device, the second message identifier is a message identifier of data allowed to be received by the first device, the first interaction device and the second interaction device are devices which interact with the first device in the CAN communication system, the first interaction device comprises the second device, and/or the second interaction device comprises the second device.
In another possible implementation manner, first reserved data and/or second reserved data are/is further defined in the virtual communication matrix, where the first reserved data are data that allow the first device to send on a CAN bus through the first CAN node, and the second reserved data are data that allow the first device to obtain from the CAN bus through the first CAN node.
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;
and when the message identifier of the first data is the first message identifier, the first CAN node is further used for determining that the first data is the data allowed to be sent on the CAN bus.
In another example, the first CAN node is further configured to obtain a packet identifier of the first data, determine whether the packet identifier of the first data is a first packet 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.
The first CAN node is further configured to encapsulate the first data according to a data structure corresponding to the CAN bus, obtain third data, and send the third data to the CAN bus.
In one example, the first CAN node is further configured to obtain a message identifier of the second data; determining whether the message identifier of the second data is a second message identifier defined in the virtual communication matrix;
and when the message identifier of the second data is the second message identifier, the first CAN node is further used for determining that the second data is the data which allows the first device to receive.
In another example, the first CAN node is further configured to obtain a message identifier of the second data; determining whether a message identifier of the second data is a second message identifier defined in the virtual communication matrix, and determining 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 allows the first device to receive the second data.
The first CAN node is further configured to encapsulate the second data according to a data structure corresponding to the communication network, obtain fourth data, and send the fourth data to the first device.
Optionally, the first device is connected with the first CAN node through a multiple connection mode.
Optionally, a rate adjustment buffer is provided in the first CAN node, where the rate adjustment buffer is used to store the first data acquired by the first CAN node.
In a seventh aspect, an embodiment of the present application provides an electronic device, in which a CAN communication system is provided, where 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, where 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, where the virtual communication matrix is obtained by expanding an 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 in any one of the first aspect or the second aspect.
The electronic equipment can be automobiles, industrial equipment, artificial intelligent equipment and the like.
In an eighth aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, a controller, and a transceiver, where the controller is configured to control the transceiver to receive data on a CAN bus, and store the received data to the memory or send the received data to the processor, and is further configured to obtain data from the processor or the memory, and control the transceiver to send the obtained data to the CAN bus, where the memory stores a computer program that CAN run on the processor, and when the processor executes the computer program, cause the electronic device to implement the CAN communication method in any one of the first aspect or the second aspect.
In a ninth aspect, embodiments of the present application provide a computer-readable storage medium storing a computer program, which when executed by a computer, causes the computer to implement the CAN communication method according to any one of the first or second aspects.
In a tenth aspect, embodiments of the present application provide a computer program product which, when run on an electronic device, causes the electronic device to perform the CAN communication method of any one of the first or second aspects described above.
It will be appreciated that the advantages of the second to tenth aspects may be found in the relevant description of the first aspect and are not described here again.
Drawings
FIG. 1 is a schematic diagram of the structure of data broadcast by a CAN bus;
fig. 2 is a schematic structural diagram of a CAN communication system according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of data propagated based on UDP according to an embodiment of the present application;
FIG. 4 is a schematic flow chart of a CAN communication method provided by an embodiment of the application;
fig. 5 is a schematic structural diagram of a CAN communication system according to another embodiment of the present application;
FIG. 6 is a schematic flow chart of a CAN communication method provided by another embodiment of the application;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
It should be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
As used in this specification and the appended claims, the term "if" may be interpreted as "when..once" or "in response to a determination" or "in response to detection" depending on the context. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
In addition, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used merely to distinguish between descriptions and are not to be construed as indicating or implying relative importance.
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," and the like in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments" unless expressly specified otherwise. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
Furthermore, references to "a plurality of" in the examples of this application should be interpreted as two or more.
The steps involved in the CAN communication method provided in the embodiments of the present application are merely examples, not all steps are necessarily performed, or not all the contents in each information or message are necessarily selected, and may be increased or decreased as needed during use. The same steps or messages having the same function in the embodiments of the present application may be referred to and used by reference between different embodiments.
The service scenario described in the embodiments of the present application is for more clearly describing the technical solution of the embodiments of the present application, and does not constitute a limitation to the technical solution provided in the embodiments of the present application, and as a person of ordinary skill in the art can know that, with the evolution of the network architecture and the appearance of a new service scenario, the technical solution provided in the embodiments of the present application is equally applicable to similar technical problems.
The CAN communication system CAN be widely applied to the field of automobile internal communication and other industrial fields. The CAN communication system CAN comprise a CAN bus, at least two ECUs/MCUs connected with the CAN bus, and the like, namely, each ECU/MCU CAN be hung on the CAN bus to become one CAN node of the CAN bus when working. 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 ECU/MCU connected to the CAN bus is only exemplary, and should not be understood as showing the embodiment of the present application, but may be other entity devices such as a micro processing unit connected to the CAN bus.
Referring to fig. 1, fig. 1 shows a schematic diagram of a data structure broadcasted by a CAN bus. As shown in fig. 1, each data frame (hereinafter referred to as CAN data frame) broadcasted on the CAN bus may include a start of frame (SOF) segment, an arbitration (arbitration field, AF) segment, a control segment, a data (data) segment, a cyclic redundancy check (cyclic redundancy check, CRC) segment, a response (ACK) segment, and an end of frame (EOF) segment. The content of the AF segment is mainly a message identifier (MsgID) corresponding to the CAN data frame, where the MsgID determines the priority of sending the CAN data frame, and also determines whether other CAN nodes will receive the CAN data frame.
When electronic devices such as automobiles leave factories, manufacturers generally need to define a communication matrix (hereinafter referred to as an original communication matrix) corresponding to a CAN communication system, and each device (i.e., an ECU/MCU corresponding to each device) in the electronic devices such as automobiles CAN transmit and receive data only by following the original communication matrix, so as to interact with other devices. That is, the original communication matrix defines which CAN data frames of the MsgID CAN be received by each ECU/MCU in the electronic device such as the automobile, and/or which CAN data frames of the MsgID CAN be transmitted, that is, each ECU/MCU needs to follow the definition of the original communication matrix to transmit and receive data.
When a new device needs to be added to the CAN communication system, the new device is not defined in the original communication matrix, that is, the original communication matrix does not define which MsgID CAN be received by the new device and/or which MsgID CAN be sent by the new device, and the new device generally does not have a CAN bus interface, so that the new device cannot access to the CAN bus and cannot communicate with a CAN node (i.e., ECU/MCU) on the CAN bus, and therefore the new device cannot interact with other devices on the CAN bus, and the user experience is greatly affected.
In order to solve the above-mentioned problems, embodiments of the present application provide a CAN communication method, an electronic device, and a CAN communication system, where in the method, when a new device (hereinafter referred to as a first device) needs to be added to a CAN bus, the first device may be connected to a certain CAN node (hereinafter referred to as a first CAN node) in the CAN communication system through a communication network, and an original communication matrix of the CAN communication system may be extended according to the first device, so as to obtain a virtual communication matrix. The definition of the first device may be added to the virtual communication matrix, that is, the definition of the first device may be added to the MsgID of the data that may be sent by the first device (hereinafter, the MsgID of the data that may be sent by the first device is referred to as a first packet identifier, that is, a first MsgID), and/or the MsgID of the data that may be received by the first device may be referred to as a second packet identifier, that is, a second MsgID, may be added to the virtual communication matrix, and may modify the MsgID of the data that may be received by the interaction device according to the first MsgID and/or the second MsgID, and/or modify an MsgID of the data that may be received by the interaction device (that is, add a first CAN node connected to the first device) and the interaction device in the CAN communication system, so that the first device may be dynamically added to the CAN communication system according to the virtual communication matrix, so that the first device may be easily interacted with the CAN be further, and the CAN be more easily interacted with the CAN node on the CAN bus, thereby enhancing the usability of the CAN be applied to the CAN be more effectively used by other devices than the CAN be applied to the CAN.
It should be noted that the CAN communication method provided by the embodiment of the present application may be applied to automobiles, industrial devices, artificial intelligence devices, and the like. The following will describe related concepts related to the embodiments of the present application by taking an example in which the CAN communication method is applied to an automobile.
The original communication matrix is defined for a producer according to equipment when the automobile leaves the factory, namely the original communication matrix defines the MsgID of CAN data frames which CAN be received by each ECU/MCU corresponding to the equipment when the automobile leaves the factory and/or the MsgID of CAN data frames which CAN be sent, so that communication among all the equipment in the automobile CAN be realized through a CAN bus. It should be appreciated that one ECU/MCU may be used to manage one or more devices, and thus, one ECU/MCU may receive and/or may transmit CAN data frames of a plurality of different msgids.
The virtual communication matrix is 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 may be a communication matrix obtained by adding a definition of the first msgID and/or the second msgID on the basis of the original communication matrix, modifying the msgID of data that CAN be received by the interaction device according to the first msgID and/or the second msgID, and/or modifying a CAN node and the like that CAN be received by the data sent by the interaction device, where the interaction device is a device that needs to interact with the first device in the CAN communication system, so that the first device CAN join the CAN communication system according to the virtual communication matrix, and thus interact with the original device in the CAN bus.
Wherein, adding the definition of the first MsgID refers to adding the MsgID of the data that CAN be sent by the first device, or adding the MsgID of the data that CAN be sent by the first device and adding the related content of the signal that CAN be sent by the first device in the corresponding MsgID according to 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. The adding of the definition of the second msgID refers to adding the first CAN node corresponding to the first device in the CAN nodes capable of receiving the data according to the data required to be acquired by the first device, or adding the related content of the signal corresponding to the first device in the msgID corresponding to the data according to the data required to be acquired by the first device (for example, adding the related content of the signal capable of being received by the first device in the msgID), so that the first device CAN acquire the data of the second msgID from the CAN bus.
Since the first device is often a device that does not have a CAN bus interface, the first device may be connected to a first CAN node in the CAN communication system through a communication network to join the first device to the CAN communication system through the first CAN node. The first device may send a registration request to the first CAN node through the communication network to register the first MsgID and/or the second MsgID corresponding to the first device, so that the first device may send data to the CAN bus through the first CAN node, so that other CAN nodes may obtain data sent by the first device from the CAN bus, or so that the first device may obtain data sent by other CAN nodes from the CAN bus through the first CAN node, so that the first device may interact with other devices in the CAN communication system.
It should be appreciated that the first msguid corresponding to the first device may be determined according to the msguid reserved for use in the CAN communication system when the first device is connected to the first CAN node, e.g. any one or more of the msguids reserved for use in the CAN communication system may be determined as the first msguid of the first device. The second MsgID corresponding to the first device may be determined according to the MsgID of data that the device that the first device needs to interact with may send to the first device (i.e., data that the first device may receive).
For example, when it is required to add a fragrance device to a CAN communication system, the fragrance device may be connected to an in-vehicle ECU through a communication network to add the fragrance device to the CAN communication system through the in-vehicle ECU. At this time, a first MsgID (for example, 0x0 A4) corresponding to the aromatherapy device may be determined according to an available MsgID reserved in the CAN communication system, and/or a second MsgID corresponding to the aromatherapy device may be determined according to an MsgID of data that may be sent to the aromatherapy device by the interaction device corresponding to the aromatherapy device (for example, the air conditioner, the ECU1, etc. described in table 1), and in addition, an MsgID of data that may be received by the air conditioner, the ECU1, etc. may be modified according to the first MsgID and/or the second MsgID, and/or a CAN node or the like that may be received by the data sent by the air conditioner, the ECU1, etc. may be modified to expand the original communication matrix, so as to obtain the virtual communication matrix shown in table 1.
The signals corresponding to each MsgID in table 1 may be used to limit the data allowed to be sent by the MsgID. In table 1, only partial contents such as a message name, a message identifier (i.e., msgID), a message length (in bytes)), a signal name, a signal description, a signal length (in bits)), a CAN node capable of transmitting the CAN data frame, and a CAN node capable of receiving the CAN data frame are described in an exemplary manner, and it should not be understood that the disclosure is limited to the embodiments of the present application, and the CAN data frame may further include contents such as a message type, a message transmission type, a message cycle time, a signal arrangement format, and the specific contents may refer to descriptions of the existing communication matrix.
TABLE 1
The following describes the CAN communication method provided in the embodiment of the present application in detail with reference to the accompanying drawings and specific application scenarios.
Referring to fig. 2, fig. 2 is a schematic structural diagram of a CAN communication system according to an embodiment of the present application. As shown in fig. 2, the CAN communication system may include a CAN bus and at least two CAN nodes (illustrated in fig. 2 as CAN node 1, CAN node 2, CAN node 3, and CAN node 4) connected to the CAN bus. It is understood that each CAN node may be a microprocessor unit such as an ECU or MCU.
When a first device needs to be added to the CAN communication system, the first device may be connected to a first CAN node (CAN node 3 is exemplified as a first CAN node in fig. 2) of the at least two CAN nodes through a communication network. It should be understood that in the CAN communication system, a virtual communication matrix may be provided according to the first MsgID and/or the second MsgID corresponding to the first device, so as to perform data transceiving according to the virtual communication matrix. The specific content of the virtual communication matrix may refer to the foregoing description, and will not be described herein.
When a third device is further added to the CAN communication system, the third device may be connected to one of the at least two CAN nodes through the communication network. At this time, in the CAN communication system, a virtual communication matrix may be set according to the first MsgID and/or the second MsgID corresponding to the first device, and the first MsgID and/or the second MsgID corresponding to the third device, so as to perform data transmission and reception according to the virtual communication matrix. It should be understood that the CAN node to which the third device is connected may be the same as or different from the first CAN node to which the first device is connected. The process of adding the first device to the CAN communication system is similar to the process of adding the third device to the CAN communication system, and the first device to the CAN communication system will be exemplified below.
It should be noted that the first device may be connected to the first CAN node through a wired communication network such as a universal serial bus (universal serial bus, USB) interface or an ethernet (ethernet), or may be connected to the first CAN node through a wireless communication network such as a wireless local area network (wireless local area networks, WLAN) (e.g., a wireless fidelity (wireless fidelity, wi-Fi) network), bluetooth (BT), a near field communication technology (near field communication, NFC), an infrared technology (IR), or a wireless communication network such as 2G/3G/4G/5G.
In this embodiment of the present application, the first CAN node may be specifically set by a technician according to an actual scenario. For example, the technician may set the first CAN node according to the communication network supported by the first device and the communication network supported by each CAN node.
For example, when the communication network supported by the first device is an ethernet network, a CAN node supporting an ethernet connection among the at least two CAN nodes may be set as the first CAN node.
For example, when the communication network supported by the first device is bluetooth, a CAN node supporting bluetooth connection among the at least two CAN nodes may be set as the first CAN node.
For example, when the communication network supported by the first device is WiFi, a CAN node supporting a WiFi connection among the at least two CAN nodes may be set as the first CAN node.
In this embodiment of the present invention, after a first device is connected to a first CAN node through a communication network, a registration request may be sent 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 may be forwarded to a CAN bus through the first CAN node, and/or data required by the first device may be obtained from the CAN bus through the first CAN node and forwarded to the first device. That is, 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 combine with an original communication matrix of the CAN bus system to form a dynamic virtual communication matrix, so as to perform distributed information synchronization.
For example, a security check may be carried in the first CAN node to determine whether data sent by the first device may be sent to the CAN bus and/or whether data broadcast on the CAN bus is data allowed to be acquired by the first device through the security check.
It should be understood that, in order to enable data transmitted through the communication network to be broadcast on the CAN bus, or in order to enable data broadcast on the CAN bus to be transmitted to the first device through the communication network, a transmission protocol between the first device and the first CAN node may be modified, that is, the content of the MsgID and the data segment (data) corresponding to the CAN data frame may be added to the data transmitted based on the communication network, so when the data transmitted by the first device needs to be transmitted to the CAN bus, the content of the MsgID and the data segment (data) in the data may be acquired, and the content of the MsgID and the data segment (data) may be encapsulated according to the structure shown in fig. 1, so as to obtain the CAN data frame. Or when the data broadcasted on the CAN bus needs to be sent to the first device, the content of the MsgID and the data segment (data) in the CAN data frame CAN be obtained, and the content of the MsgID and the data segment (data) CAN be encapsulated according to a transmission protocol corresponding to the communication network, so that the data CAN be obtained and transmitted through the communication network, and the data CAN be sent to the first device through the communication network.
For example, when the first device is connected to the first CAN node through a communication network such as ethernet or WiFi, data may be transmitted and received between the first device and the first CAN node through a user datagram (user datagram protocol, UDP) protocol.
Referring to fig. 3, fig. 3 is a schematic diagram illustrating a structure of data transmitted based on a UDP protocol according to an embodiment of the present application. As shown in fig. 3, each frame data of the UDP protocol (hereinafter, referred to as a UDP data frame) may include a source port, a destination port, a message length, a message type, a data section, and a check section. Wherein the data segment of the UDP data frame may include a UDP header and a UDP datagram.
Since the data broadcast on the CAN bus needs to be the CAN data frame shown in fig. 1, in order for the first CAN node to forward the data sent by the first device to the CAN bus, and/or to forward the data broadcast on the CAN bus to the first device, the UDP protocol between the first device and the first CAN node may be modified. I.e. the content of the MsgID and the data section (data) in the CAN data frame CAN be added to the UDP data frame.
Illustratively, the first device may divide the UDP datagram of the UDP data frame into three fields, the first field may be used to store the contents of the MsgID in the CAN data frame, the second field may be used to store the contents of the data segment (data) in the CAN data frame, and the third field may be a padding segment.
Therefore, after the first CAN node receives the UDP data frame sent by the first device through the communication network such as ethernet or WiFi, the first CAN node may acquire the MsgID and the content of the data segment (data) in the UDP data frame, and encapsulate the MsgID and the content of the data segment (data) in the UDP data frame into the CAN data frame according to the structure shown in fig. 1. The first CAN node may then forward the encapsulated CAN data frame to the CAN bus.
Similarly, after the first CAN node obtains the CAN data frame from the CAN bus, the first CAN node may obtain the MsgID and the content of the data segment (data) in the CAN data frame, and encapsulate the MsgID and the content of the data segment (data) in the CAN data frame into a UDP data frame according to the structure shown in fig. 3. And then, the first CAN node CAN forward the encapsulated UDP data frame to the first device through a communication network such as Ethernet or WiFi.
The following describes a CAN communication method provided in the embodiment of the present application by taking an ethernet connection between a first device and a first CAN node as an example.
Referring to fig. 4, fig. 4 is a schematic flowchart of a CAN communication method according to an embodiment of the present application. As shown in fig. 4, the method may include:
s401, a first device sends first data to a first CAN node, the first data are used for a second device to execute interactive operation, and the second device is a device in a CAN communication system.
S402, the first CAN node determines that the first data are data which CAN be sent on a CAN bus according to the virtual communication matrix.
S403, the first CAN node sends the first data to a CAN bus.
S404, broadcasting first data on the CAN bus.
S405, a second CAN node acquires first data broadcasted on a CAN bus, wherein the second CAN node is a CAN node corresponding to the second equipment.
S406, the second CAN node controls the second equipment to execute interactive operation according to the first data.
In this embodiment of the present application, when the first device needs to interact with the second device in the CAN communication system, the first device may send data with the structure shown in fig. 3 to the first CAN node through ethernet (in this embodiment of the present application, the data sent by the first device is referred to as first data), that is, the first data may be a UDP data frame.
After the first CAN node receives the first data, safety protection check CAN be performed. For example, the first CAN node may acquire the MsgID and data in the first data, and may determine, according to the MsgID and the virtual communication matrix in the first data, whether the first data is data that CAN be sent on the CAN bus, that is, whether the MsgID of the first data is the MsgID defined in the virtual communication matrix.
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, so as to avoid forwarding malicious data sent by the first device to the CAN bus, bring security threat to the CAN communication system and reduce the security of the CAN communication system.
When the MsgID of the first data is the MsgID defined in the virtual communication matrix, the first CAN node may encapsulate the MsgID and the data in the first data according to the structure shown in fig. 1, to obtain third data after the encapsulation of the first data, that is, the third data may be a CAN data frame corresponding to the first data, that is, the content of the first data is the same as the content of the third data, but the format is different. The first CAN node may then send the third data to the CAN bus to broadcast the third data on the CAN bus.
When third data is broadcast on the CAN bus, a second CAN node (for example, an ECU/MCU corresponding to the second device) in the CAN communication system CAN acquire the third data from the CAN bus, and CAN control the second device to execute corresponding interaction operation according to the third data, so that the first device CAN interact with the second device.
For example, in the application scenario shown in fig. 2, CAN node 1 may be used to manage device a, and the MsgID of the data that CAN be received by CAN node 1 includes the first MsgID. When the first device needs to interact with device a, the first device may send first data to the CAN node 3 via the communication network. After the CAN node 3 receives the first data, the MsgID and the data in the first data are obtained, and the first data are determined to be data that CAN be sent on the CAN bus according to the virtual communication matrix and the MsgID in the first data, so that the CAN node 3 CAN package the MsgID and the data in the first data to obtain third data, namely, a CAN data frame, and send the third data to the CAN bus.
When third data is broadcast on the CAN bus, the CAN node 1 determines that the first data is data which CAN be received by itself according to the virtual communication matrix (i.e., the MsgID of the data which CAN be received by the CAN node 1), and at this time, the CAN node 1 CAN acquire the third data from the CAN bus and CAN control the device a to execute corresponding interaction operation according to the third data, thereby realizing interaction between the first device and the device a.
Similarly, when a second device in the CAN communication system needs to interact with the first device, a second CAN node corresponding to the second device may send data to the CAN bus (hereinafter, the data sent by the second CAN node is referred to as second data) to broadcast the second data on the CAN bus. At this time, the first CAN node may determine whether the second data is data that the first device may receive according to 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 the second MsgID corresponding to the first device may be registered with the first CAN node, so that the first CAN node may record a dynamic communication matrix corresponding to the first device, that is, record the first MsgID and/or the second MsgID corresponding to the first device, so as to determine whether the second data is data that CAN be received by the first device according to the second MsgID.
When the second data is the data which 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 acquire the second data from the CAN bus, and CAN acquire the MsgID and the data in the second data. Then, the first CAN node may encapsulate the MsgID and the data in the second data according to the structure shown in fig. 3, to obtain fourth data after the second data is encapsulated, that is, the fourth data may be a UDP data frame corresponding to the second data, that is, the second data and the fourth data have the same content but different formats. Then, the first CAN node may forward the fourth data to the first device, so that the first device may perform a corresponding interaction operation according to the fourth data, thereby implementing interaction between the second device and the first device.
For example, in the application scenario shown in fig. 2, CAN node 2 may be used to manage device B. The second MsgID corresponding to the first device may include an MsgID of the second data. When device B needs to interact with the first device, CAN node 2 may send second data to the CAN bus to broadcast the second data on the CAN bus.
When the second data is broadcast on the CAN bus, the CAN node 3 determines that the second data is the data which CAN be received by the first equipment according to the second MsgID corresponding to the first equipment, and at the moment, the CAN node 3 CAN acquire the second data from the CAN bus and acquire the MsgID and the data in the second data. Then, the CAN node 3 may encapsulate the MsgID and the data in the second data to obtain encapsulated fourth data, and send the fourth data to the first device through the communication network, so that the first device may perform a corresponding interaction operation according to the fourth data, thereby implementing interaction between the device B and the first device.
Referring to fig. 5, fig. 5 shows a schematic structural diagram of a CAN communication system according to another embodiment of the present application. As shown in fig. 5, the CAN communication system may include at least two CAN buses (illustrated in fig. 5 by way of example with CAN bus 1 and CAN bus 2), at least two CAN nodes (illustrated in fig. 5 by way of example with CAN node 1, CAN node 2, CAN node 3, CAN node 4, and CAN node 5), and a gateway. The CAN node 1, the CAN node 2 and the CAN node 3 are connected with the CAN bus 1, the CAN node 4 and the CAN node 5 are connected with the CAN bus 2, and the CAN bus 1 and the CAN bus 2 are respectively connected with the gateway. It is understood that each CAN node may be a microprocessor unit such as an ECU or MCU.
The gateway may forward data on different CAN buses, e.g., the gateway may forward data broadcast on CAN bus 1 to CAN bus 2, or may forward data broadcast on CAN bus 2 to CAN bus 1. It should be appreciated that the gateway may also be in communication with the cloud server, e.g., the gateway may send data to the cloud server, or may receive data from the cloud server, etc.
When a first device needs to be added to the CAN communication system, the first device may be connected to a first CAN node (CAN node 3 is exemplified as a first CAN node in fig. 5) of the at least two CAN nodes through a communication network. It should be understood that in the CAN communication system, a virtual communication matrix may be provided according to the first MsgID and/or the second MsgID corresponding to the first device, so as to perform data transceiving according to the virtual communication matrix.
Referring to fig. 6, fig. 6 is a schematic flowchart of a CAN communication method according to another embodiment of the present application. As shown in fig. 6, the method may include:
s601, a first device sends first data to a first CAN node, the first data are used for a second device to execute interactive operation, and the second device is a device in a CAN communication system.
S602, the first CAN node determines that the first data is data which CAN be sent on a CAN bus according to the virtual communication matrix.
S603, the first CAN node sends the first data to a first CAN bus.
S604, broadcasting first data by the first CAN bus.
S605, the gateway acquires the first data and forwards the first data to the second CAN bus.
S606, broadcasting first data by the second CAN bus.
S607, the second CAN node acquires the first data broadcasted on the second CAN bus, and the second CAN node is the CAN node corresponding to the second equipment.
And S608, the second CAN node controls the second equipment to execute interactive operation according to the first data.
In this embodiment of the present application, when the first device needs to interact with a second device in the CAN communication system, and the second device is hooked to a first CAN node on a different CAN bus, for example, the first CAN node is hooked to the first CAN bus, and when the second device is hooked to the second CAN bus, the first device may send first data with the structure shown in fig. 3 to the first CAN node through ethernet, that is, the first data may be a UDP data frame.
After the first CAN node receives the first data, safety protection check CAN be performed. For example, the first CAN node may obtain the MsgID and data in the first data, and determine, according to the MsgID and the virtual communication matrix in the first data, whether the first data is data that CAN be sent on the first CAN bus, that is, whether the MsgID of the first data is the MsgID defined in the virtual communication matrix.
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, so as to avoid forwarding malicious data sent by the first device to the first CAN bus, bring security threat to the CAN communication system and reduce the security of the CAN communication system.
When the MsgID of the first data is the MsgID defined in the virtual communication matrix, the first CAN node may encapsulate the MsgID and the data in the first data according to the structure shown in fig. 1, to obtain encapsulated third data, that is, the third data may be a CAN data frame. The first CAN node then transmits the third data to the first CAN bus to broadcast the third data on the first CAN bus. At this time, the gateway may forward the third data broadcast on the first CAN bus to the second CAN bus to broadcast the third data on the second CAN bus.
When third data is broadcast on the second CAN bus, a second CAN node (for example, a second ECU corresponding to the second device) in the CAN communication system may acquire the third data from the second CAN bus, and control the second device to perform corresponding interaction operation according to the third data, so that the first device may interact with the second device.
For example, in the application scenario shown in fig. 5, the CAN node 4 may be used to manage the device D, and the MsgID of the data that CAN be received by the CAN node 4 may include the first MsgID. When the first device needs to interact with device D, the first device may send the first data to the CAN node 3 via the communication network. After the CAN node 3 receives the first data, the MsgID and the data in the first data are obtained, and the first data are determined to be data that CAN be sent on the CAN bus 1 according to the virtual communication matrix and the MsgID in the first data, so that the CAN node 3 CAN encapsulate the MsgID and the data in the first data, obtain encapsulated third data, that is, obtain a CAN data frame, and send the third data to the CAN bus 1. At this time, the gateway may forward the third data broadcast on CAN bus 1 to CAN bus 2 to broadcast the third data on CAN bus 2.
When third data is broadcast on the CAN bus 2, the CAN node 4 determines that the first data is data which CAN be received by itself according to the virtual communication matrix (i.e., the MsgID of the data which CAN be received by the CAN node 4), and at this time, the CAN node 4 CAN acquire the third data from the CAN bus 2 and CAN control the device D to execute corresponding interaction operation according to the third data, thereby realizing interaction between the first device and the device D.
Similarly, when a second device in the CAN communication system needs to interact with the first device and the second device is hooked to a different CAN bus with the first CAN node, for example, the first CAN node is hooked to the first CAN bus, and the second device is hooked to the second CAN bus, the second CAN node corresponding to the second device may send second data to the second CAN bus to broadcast the second data on the second CAN bus.
At this time, the gateway may 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, and the first CAN node may determine whether the second data is data that the first device may receive according to the second MsgID corresponding to the first device.
When the second data is the data that the first device CAN receive, that is, when the second MsgID corresponding to the first device includes 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 the data in the second data. Then, the first CAN node may encapsulate the MsgID and the data in the second data according to the structure shown in fig. 3, to obtain encapsulated fourth data, that is, the fourth data may be a UDP data frame. Then, the first CAN node may forward the fourth data to the first device, so that the first device may perform a corresponding interaction operation according to the fourth data, thereby implementing interaction between the second device and the first device.
In one example, to avoid illegal use of the CAN bus by the first device to ensure the security of the CAN communication system, specific data that the first device is allowed to receive and/or specific data that the first device is allowed to transmit may also be restricted when joining the first device to the CAN communication system. The first CAN node may, for example, limit the specific data that the first device is allowed to receive and/or the specific data that the first device is allowed to transmit by means of a security check.
For example, as shown in table 1, a signal that the first MsgID can transmit may be defined in the virtual communication matrix, so that data that the first MsgID allows to transmit (hereinafter, data that allows to transmit will be referred to as first reserved data) is limited, thereby limiting data that the first device is allowed to transmit. Similarly, signals that may be received by the first device may be limited in the virtual communication matrix, thereby limiting the data that the first device is allowed to receive (hereinafter, the data that is allowed to receive will be referred to as second reserved data). Therefore, the first device CAN only send the first reserved data to the CAN bus, and/or CAN only acquire the second reserved data from the CAN bus, so that the first device is prevented from sending malicious data to the CAN bus, and/or the first device is prevented from revealing or tampering with data broadcasted on the CAN bus, and the safety of the CAN communication system is improved.
That is, the first CAN node may perform the safety protection check when the first CAN node receives the first data transmitted by the first device. For example, the first CAN node may 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, may analyze a header, a message content, etc. of the first data, determine a signal corresponding to the first data, and thus determine 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 transmit the first data to the CAN bus, i.e., may not broadcast the first data on the CAN bus, so as to avoid that the first device transmits malicious data to the CAN bus, which causes security threat to the CAN communication system, thereby reducing security of the CAN communication system.
When determining 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 may encapsulate the MsgID and the data in the first data according to the structure shown in fig. 1, obtain encapsulated third data, and send the third data to the CAN bus. Therefore, other CAN nodes in the CAN communication system CAN acquire third data from the CAN bus according to the virtual communication matrix, and CAN control corresponding equipment to execute corresponding interactive operation according to the third data.
Similarly, when the first CAN node determines that the second data broadcast on the CAN bus is the data required to be acquired by the first device, the first CAN node may perform a security protection check. For example, the first CAN node may determine whether the second data is second reserved data in the virtual communication matrix, i.e. whether the second data broadcast on the CAN bus is data that the first device may acquire from the CAN bus. When the second data is not the second reserved data in the virtual communication matrix, that is, the second data is not the data that CAN be acquired by the first device, the first CAN node may not send the second data to the first device, so as to avoid that the data transmitted in the CAN bus is leaked or illegally tampered, and reduce the security of the CAN communication system.
When the second data is the second reserved data in the virtual communication matrix, the first CAN node may acquire the second data from the CAN bus, may encapsulate the MsgID and the data in the second data according to the structure shown in fig. 3, obtain fourth data, and send the fourth data to the first device through the communication network, so that the first device may perform a corresponding interaction operation according to the fourth data.
In one possible implementation manner, 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 of the CAN bus, in this embodiment of the present application, the communication layer of the first device and the communication layer of the first CAN node may be modified, so as to improve the real-time reliability between the first device and the first CAN node and/or enhance the fault tolerance of the delay jitter.
In one example, in the communication layer, a connection manner between the first device and the first CAN node may be modified, for example, the connection manner between the first device and the first CAN node may be modified to be a multiple connection manner, so as to improve real-time reliability between the first device and the first CAN node through multiple connections.
For example, the connection between the first device and the first CAN node may be made by a multi-connection protocol such as a media redundancy protocol (media redundancy protocol, MRP), a parallel redundancy protocol (parallel redundancy protocol, PRP), or a high-reliability seamless redundancy (high-availability seamless redundancy, HSR).
In another example, redundancy information, error correction code, fountain code, or the like may be added to a beginning segment of the first data sent by the first device, and/or redundancy information, error correction code, fountain code, or the like may be added to an ending segment of the first data, so as to improve real-time reliability between the first device and the first CAN node through redundancy implementation, error correction, recovery, or the like.
In another example, a rate adjustment buffer may be constructed at a communication layer of the first CAN node, so as to obtain first data sent by the first device through the rate adjustment buffer, and after determining that the correct first data arrives, send the first data to the CAN bus, so as to reduce delay possibly caused by retransmission, and enhance fault tolerance of delay jitter.
Illustratively, because the rate of the communication network such as ethernet, bluetooth or WiFi is faster, in order to prevent the faster transmitted first data from impacting and/or interfering with other data being broadcast by the CAN bus, the first CAN node may reduce the rate at which the first data is sent to the CAN bus, for example, by buffering the first data by a rate adjustment buffer, and sending the first data to the CAN bus at a lower rate. The rate at which the first CAN node sends the first data to the CAN bus may be specifically determined according to an actual scenario, which is not specifically limited in the embodiment of the present application.
It should be understood that the virtual communication matrix in the CAN communication system may be updated according to an actual application scenario, for example, a portion of content defined in the virtual communication matrix may be added or deleted according to an actual application scenario appearing in the future, and/or a portion of content defined in the virtual communication matrix may be modified, so as to meet a use requirement of an application scenario that may appear in the future, and thus user experience may be effectively improved.
The following describes exemplary CAN communication methods provided in the embodiments of the present application with reference to some possible application scenarios.
For example, when it is required to add the automobile data recorder to the CAN communication system of the automobile, the automobile data recorder may be connected to a certain CAN node (for example, an automobile engine ECU) in the CAN communication system through a communication network (for example, an on-board ethernet or a USB), so that the automobile data recorder may interact with an automobile body control domain ECU in the CAN communication system through the automobile engine ECU, so that when an emergency collision is realized, the automobile body control domain ECU may send a photographing request to the automobile data recorder to start the automobile data recorder to photograph, or when the automobile data recorder detects that a pedestrian or a vehicle is close, a danger prompt may be sent to the automobile body control domain ECU, so that the automobile body control domain ECU performs a corresponding operation to avoid an accident.
At this time, in the CAN communication system, the virtual communication matrix may be defined with a first MsgID corresponding to the automobile recorder (i.e., an MsgID of data that CAN be sent by the automobile recorder) on the basis of the original communication matrix of the automobile. Meanwhile, according to interaction between the automobile data recorder and the automobile body control domain ECU, the virtual communication matrix also defines a second MsgID (namely, msgID of data which CAN be received by the automobile data recorder, such as MsgID of data which CAN be transmitted by the automobile body control domain ECU), and MsgID of data which CAN be received by the automobile body control domain ECU (such as MsgID of data which CAN be received by the automobile body control domain ECU is modified, so that the automobile body control domain ECU CAN receive MsgID of 'danger reminding'), CAN nodes (such as CAN nodes which CAN be received by modifying 'photographing request', including the automobile data recorder) and the like, which correspond to the automobile data recorder. Meanwhile, the virtual communication matrix can be defined with data (such as a photographing request and the like) which can be received by the automobile data recorder and data (such as a danger reminder and the like) which can be sent.
After the driving recorder is connected with the vehicle ECU through a vehicle-mounted Ethernet or a USB (universal serial bus) and other communication networks, the driving recorder can send a registration request to the vehicle ECU so as to register a first MsgID and a second MsgID corresponding to the driving recorder to the vehicle ECU, namely, the vehicle ECU is informed of the MsgID of data which can be sent by the driving recorder and the MsgID of data which can be received through registration.
When a collision occurs, the vehicle body control domain ECU may send data (e.g., a photographing request) to the CAN bus to inform the event data recorder to take a photograph. At this time, the vehicle ECU determines that the data is data that CAN be received by the vehicle recorder according to the second MsgID corresponding to the vehicle recorder and the MsgID of the data, and determines that the data is data that CAN be received by the vehicle recorder according to the virtual communication matrix (that is, the data that CAN be received by the vehicle recorder defined in the virtual communication matrix), so that the vehicle ECU CAN acquire the data from the CAN bus, and convert the data into a UDP data frame according to the structure shown in fig. 3. Then, the vehicle ECU may transmit the UDP data frame to the event data recorder through a communication network such as an on-vehicle ethernet or USB. After the automobile data recorder receives the UDP data frame, photographing can be carried out.
Or when the automobile data recorder detects that the pedestrian or the automobile is close to the automobile data recorder, the automobile data recorder can send data (such as danger reminding) to the automobile ECU through the communication network such as the vehicle-mounted Ethernet or the USB so as to inform the automobile body control domain ECU of the perceived danger condition. At this time, the vehicle ECU determines that the data is data that CAN be broadcast on the CAN bus according to the MsgID of the data and the virtual communication matrix (i.e., data that CAN be transmitted by the vehicle recorder defined in the virtual communication matrix), and therefore, the vehicle ECU CAN transmit the data to the CAN bus to broadcast the data on the CAN bus. The vehicle body control domain ECU acquires the data from the CAN bus according to the MsgID of the data which CAN be received by the vehicle body control domain ECU, and executes corresponding interactive operation according to the data, for example, the braking force and the like CAN be actively increased, so as to prevent accidents.
For example, when a CAN communication system of a robot to an automobile needs to be newly added to read an in-car condition (such as a car window state, a sunshade curtain state or an in-car temperature, etc., and specifically readable data CAN be defined in a virtual communication matrix) so as to assist in alarming and/or prompting the temperature according to the in-car condition, the robot CAN be connected with a certain CAN node (such as an in-car ECU) in the CAN communication system through a communication network (such as WiFi), so that the robot CAN interact with a car body control domain ECU in the CAN communication system through the in-car ECU, etc.
At this time, in the CAN communication system, according to the interaction between the robot and the vehicle body control domain ECU or the like, the virtual communication matrix may define a second MsgID corresponding to the robot (that is, the MsgID of data that the robot may receive, for example, the MsgID of data that may include data sent by the vehicle body control domain ECU), and modify the CAN node that may be received by the data sent by the vehicle body control domain ECU or the like, that is, add the vehicle body ECU corresponding to the robot, so that the robot may acquire the data sent by the vehicle body control domain ECU or the like through the vehicle body ECU.
After the robot is connected to the vehicle ECU through a communication network such as WiFi, the robot may send a registration request to the vehicle ECU to register a second MsgID corresponding to the robot with the vehicle ECU, that is, to notify the vehicle ECU of the MsgID of data that the robot may receive through registration.
Therefore, when the data broadcast on the CAN bus is the data such as the window state, the sunshade curtain state or the temperature in the vehicle, the vehicle ECU determines that the data is the data required to be received by the robot according to the second MsgID corresponding to the robot and the MsgID of the data, and determines that the data is the data receivable by the robot according to the virtual communication matrix (that is, the data receivable by the robot defined in the virtual communication matrix), so that the vehicle ECU CAN acquire the data from the CAN bus and convert the data into the UDP data frame according to the structure shown in fig. 3. Then, the vehicle ECU may transmit the UDP data frame to the robot through a communication network such as WiFi. After receiving the UDP data frame, the robot can report the state of the window or the temperature in the car, or can give an alarm that the window is not closed or the temperature is too high or too low.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic of each process, and should not limit the implementation process of the embodiment of the present application in any way.
Corresponding to the CAN communication method described in the foregoing embodiments, the embodiments of the present application further provide a CAN communication device, where each module of the device may correspondingly implement each step of the CAN communication method.
It should be noted that, because the content of information interaction and execution process between the above devices/units is based on the same concept as the method embodiment of the present application, specific functions and technical effects thereof may be referred to in the method embodiment section, and will not be described herein again.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
Referring to fig. 7, fig. 7 shows a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 7, the electronic device 7 may include at least one processor 70, at least one memory 71, a controller 72 (which may also be referred to as a CAN controller), and a transceiver 73, which may include a receiver and/or a transmitter. The processor 70 may be connected to a controller 72 and a memory 71, respectively, the controller 72 also being connected to the memory 71 and a transceiver 73, respectively.
The memory 71 may store application data, computer programs, and the like. The processor 70 refers to a device having an arithmetic capability, and for example, the processor may be a micro control unit (Microcontroller Unit, MCU), a central processing unit (Central Processing Unit, CPU), or the like. The processor 70 may read and execute a computer program from the memory 71 to cause the electronic device 7 to implement the steps of any of the various method embodiments described above. The processor 70 may also process application data in the memory 71, etc. The controller 72 may control the receiver to receive data on the CAN bus and store the received data to the memory 71 or send the received data to the processor 70. The controller 72 may also obtain data from the processor 70 or the memory 71 and control the transmitter to transmit the data on the CAN bus.
Alternatively, the controller 72 may be disposed within the processor 70 or may be disposed external to the processor 70 (illustrated in fig. 7 as being disposed external to the processor 70). Similarly, the memory 71 may be provided internal to the processor 70 or external to the processor 70 (illustrated in fig. 7 as being external to the processor 70).
Embodiments of the present application also provide a computer-readable storage medium storing a computer program that, when executed by a computer, causes the computer to implement the steps of any of the various method embodiments described above.
Embodiments of the present application provide a computer program product for causing an electronic device to carry out the steps of any of the various method embodiments described above when the computer program product is run on the electronic device.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application implements all or part of the flow of the method of the above embodiments, and may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, where the computer program, when executed by a processor, may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable storage medium may include at least: any entity or device capable of carrying computer program code to an apparatus/electronic device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (random access memory, RAM), an electrical carrier signal, a telecommunications signal, and a software distribution medium. Such as a U-disk, removable hard disk, magnetic or optical disk, etc. In some jurisdictions, computer-readable storage media may not be electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/electronic device and method may be implemented in other manners. For example, the apparatus/electronic device embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical function division, and there may be additional divisions in actual implementation, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (25)

1. The CAN communication method is characterized by being applied to a Controller Area Network (CAN) communication system, wherein the CAN communication system comprises first equipment, second equipment, a CAN bus and at least two CAN nodes connected with the CAN bus, the at least two CAN nodes comprise a first CAN node and a second CAN node, the first equipment is connected with the first CAN node through a communication network, the second CAN node is used for controlling the second equipment, a virtual communication matrix is arranged 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 equipment, and the method comprises the following steps:
The first CAN node acquires first data, wherein the first data is sent by the first equipment and is used for indicating the second equipment to execute corresponding interactive operation;
the first CAN node determines whether the first data is allowed to be sent on the CAN bus or not according to the virtual communication matrix;
when the first data is the 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 equipment to execute corresponding interaction operation according to the first data.
2. The method of claim 1, wherein the at least two CAN nodes further comprise a third CAN node, the method further comprising:
the first CAN node acquires second data from the CAN bus, wherein the second data is sent by the third CAN node, and the second data is used for indicating the first equipment to execute corresponding interactive operation;
the first CAN node determines whether the second data is data which allows the first equipment to receive according to the virtual communication matrix;
And when the second data is the data which is allowed to be received by the first equipment, the first CAN node sends the second data to the first equipment so that the first equipment executes corresponding interactive operation according to the second data.
3. Method according to claim 1 or 2, characterized in that the virtual communication matrix is based on the original communication matrix adding a definition of a first message identifier and adding the first message identifier to a message identifier of data received by a first interaction device and/or is based on the original communication matrix adding a definition of a second message identifier and adding the first CAN node to a CAN node where data sent by a second interaction device is received;
the first message identifier is a message identifier of data allowed to be sent by the first device, the second message identifier is a message identifier of data allowed to be received by the first device, the first interaction device and the second interaction device are devices which interact with the first device in the CAN communication system, the first interaction device comprises the second device, and/or the second interaction device comprises the second device.
4. A method according to claim 3, characterized in that first reservation data and/or second reservation data are also defined in the virtual communication matrix, the first reservation data being data allowing the first device to transmit over the CAN bus via the first CAN node, the second reservation data being data allowing the first device to acquire from the CAN bus via the first CAN node.
5. The method of any of claims 1 to 4, wherein the first CAN node determining whether the first data is data allowed to be transmitted on the CAN bus according to the virtual communication matrix comprises:
the first CAN node acquires a message identifier of the first data;
the first CAN node determines whether the message identifier of the first data is a first message identifier defined in the virtual communication matrix;
and when the message identifier of the first data is the first message identifier, the first CAN node determines that the first data is allowed to be sent on the CAN bus.
6. The method of any of claims 1 to 4, wherein the first CAN node determining whether the first data is data allowed to be transmitted on the CAN bus according to the virtual communication matrix comprises:
The first CAN node acquires a message identifier of the first data;
the first CAN node determines whether the 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 of any one of claims 1 to 6, wherein the first CAN node sending the first data to the CAN bus comprises:
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 of claim 2, wherein the first CAN node determining whether the second data is data that the first device is permitted to receive based on the virtual communication matrix comprises:
The first CAN node acquires a message identifier of the second data;
the first CAN node determines whether the message identifier of the second data is a second message identifier defined in the virtual communication matrix;
and when the message identifier of the second data is the second message identifier, the first CAN node determines that the second data is the data which allows the first equipment to receive.
9. The method of claim 2, wherein the first CAN node determining whether the second data is data that the first device is permitted to receive based on the virtual communication matrix comprises:
the first CAN node acquires a message identifier of the second data;
the first CAN node determines whether the 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 which allows the first device to receive.
10. The method of any of claims 2, 8 to 9, wherein the first CAN node sending the second data to the first device comprises:
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. The CAN communication system is characterized by comprising first equipment, second equipment, a CAN bus and at least two CAN nodes connected with the CAN bus, wherein the at least two CAN nodes comprise a first CAN node and a second CAN node, the first equipment is connected with the first CAN node through a communication network, the second CAN node is used for controlling the second equipment, a virtual communication matrix is arranged 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 equipment;
the first device is configured to send first data to the first CAN node, where the first data is configured to instruct the second device to perform a corresponding interaction operation;
the first CAN node is used for acquiring first data and determining whether the first data is allowed to be sent on the CAN bus or not 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 used for sending the first data to the CAN bus;
the second CAN node is used for acquiring the first data from the CAN bus and controlling the second equipment to execute corresponding interactive operation according to the first data.
12. The system of claim 11, wherein the at least two CAN nodes further comprise a third CAN node;
the third CAN node is used for sending second data to the CAN bus, and the second data is used for indicating the first equipment to execute corresponding interaction operation;
the first CAN node is further used for acquiring the second data from the CAN bus and determining whether the second data is data which allows the first device to receive according to the virtual communication matrix;
when the second data is the data which allows the first equipment to receive, the first CAN node is further used for sending the second data to the first equipment;
the first device is configured to receive the second data, and perform a corresponding interaction operation 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 by adding a definition of a first message identifier and adding the first message identifier to a message identifier of data received by a first interaction device, and/or is based on the original communication matrix by adding a definition of a second message identifier and adding the first CAN node to a CAN node from which data sent by a second interaction device is received;
The first message identifier is a message identifier of data allowed to be sent by the first device, the second message identifier is a message identifier of data allowed to be received by the first device, the first interaction device and the second interaction device are devices which interact with the first device in the CAN communication system, the first interaction device comprises the second device, and/or the second interaction device comprises the second device.
14. The system of claim 13, wherein first reservation data and/or second reservation data are also defined in the virtual communication matrix, the first reservation data being data that allows the first device to transmit over a CAN bus through the first CAN node, the second reservation data being data that allows the first device to acquire from a CAN bus through the first CAN node.
15. The system of any one of claims 11 to 14, wherein 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;
And when the message identifier of the first data is the first message identifier, the first CAN node is further used for determining that the first data is the data allowed to be sent on the CAN bus.
16. The system of any one of claims 11 to 14, wherein 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, wherein the first CAN node is further configured to encapsulate the first data according to a data structure corresponding to the CAN bus, obtain third data, and send the third data to the CAN bus.
18. The system of claim 12, wherein the first CAN node is further configured to obtain a message identifier of the second data; determining whether the message identifier of the second data is a second message identifier defined in the virtual communication matrix;
and when the message identifier of the second data is the second message identifier, the first CAN node is further used for determining that the second data is the data which allows the first device to receive.
19. The system of claim 12, wherein the first CAN node is further configured to obtain a message identifier of the second data; determining whether a message identifier of the second data is a second message identifier defined in the virtual communication matrix, and determining 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 allows the first device to receive the second data.
20. The system of any one of claims 12, 18 to 19, wherein the first CAN node is further configured to encapsulate the second data according to a data structure corresponding to the communication network, obtain fourth data, and send the fourth data to the first device.
21. The system of any one of claims 11 to 20, wherein the first device and the first CAN node are connected by a multi-connection.
22. The system of any one of claims 11 to 21, wherein a rate adjustment buffer is provided in the first CAN node, the rate adjustment buffer being for storing 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, 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 for controlling the second device, a virtual communication matrix is provided in the CAN communication system, the virtual communication matrix is obtained by expanding an original communication matrix of the CAN communication system according to the first device, and the first CAN node is used for executing the CAN communication method of any one of claims 1 to 10.
24. An electronic device comprising a memory, a processor, a controller and a transceiver, wherein the controller is configured to control the transceiver to receive data on a CAN bus and store the received data to the memory or send the received data to the processor, and to acquire data from the processor or the memory and control the transceiver to send the acquired data on the CAN bus, wherein the memory stores a computer program executable on the processor, and wherein the processor, when executing the computer program, causes the electronic device to implement 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 the computer program, when executed by a computer, causes the computer to implement the CAN communication method according to any one of claims 1 to 10.
CN202210046889.1A 2022-01-14 2022-01-14 CAN communication method, electronic equipment and CAN communication system Pending CN116488953A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202210046889.1A CN116488953A (en) 2022-01-14 2022-01-14 CAN communication method, electronic equipment and CAN communication system
PCT/CN2022/141599 WO2023134428A1 (en) 2022-01-14 2022-12-23 Can communication method, electronic device, and can communication system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210046889.1A CN116488953A (en) 2022-01-14 2022-01-14 CAN communication method, electronic equipment and CAN communication system

Publications (1)

Publication Number Publication Date
CN116488953A true CN116488953A (en) 2023-07-25

Family

ID=87212508

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210046889.1A Pending CN116488953A (en) 2022-01-14 2022-01-14 CAN communication method, electronic equipment and CAN communication system

Country Status (2)

Country Link
CN (1) CN116488953A (en)
WO (1) WO2023134428A1 (en)

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180343326A1 (en) * 2017-05-26 2018-11-29 Cisco Technology, Inc. Can to ip internetworking
CN110808890B (en) * 2019-09-26 2021-11-02 浙江欧康电子信息技术有限公司 Communication processing method, communication processing device, storage medium and CAN bus communication system
WO2021168859A1 (en) * 2020-02-29 2021-09-02 华为技术有限公司 Secure communication method for controller area network bus, and device
CN111628920B (en) * 2020-05-28 2022-01-28 上海辰瞻医疗科技有限公司 Intercommunication method between multiple serial interface devices

Also Published As

Publication number Publication date
WO2023134428A1 (en) 2023-07-20

Similar Documents

Publication Publication Date Title
JP7170780B2 (en) Fraud detection rule update method, fraud detection electronic control unit, and in-vehicle network system
US11570184B2 (en) In-vehicle network system, fraud-detection electronic control unit, and fraud-detection method
US11146420B2 (en) Method for transmitting data via a serial communication bus, bus interface, and computer program
US10454957B2 (en) Method for preventing electronic control unit from executing process based on malicious frame transmitted to bus
CN107078938B (en) Gateway device, in-vehicle network system, and communication method
KR101748272B1 (en) Method and apparatus for controlling mass diagnostic communication in vehicle
CN108370343B (en) Network hub, transfer method, and vehicle-mounted network system
US11178013B2 (en) Network monitor, network monitoring method, and recording medium storing program
US11256498B2 (en) Node, a vehicle, an integrated circuit and method for updating at least one rule in a controller area network
CN106453148B (en) Method of operating a communication node in a network
US10623291B2 (en) Operation method of communication node for detecting link errors in network
US10693675B2 (en) Electronic control unit, communication method, and onboard network system
CN108370342A (en) Gateway apparatus, vehicle netbios, forwarding method and program
US10511668B2 (en) Method of transmitting and receiving data in vehicle network and apparatus for the same
JP7192074B2 (en) Network hub, transfer method and in-vehicle network system
JP2017050848A (en) Gateway device, on-vehicle network system and transfer method
JP2015089092A (en) Method of packaging packet, method of unpackaging packet, and apparatuses using the same
CN105388858A (en) Operation method of communication node in network
KR20140124255A (en) Gateway and Method for delivering Message thereof
CN111934994B (en) Gateway device, in-vehicle network system, and communication method
CN105893844A (en) Method and device for sending messages of vehicle bus networks
JP2024023912A (en) Fraud detection rule update method, fraud detection electronic control unit and in-vehicle network system
CN110731089A (en) Data transmission device and data transmission method for vehicle
CN108093028B (en) Method and apparatus for reproducing content based on presentation time in vehicle network
JP6983977B2 (en) Gateway device, in-vehicle network system and transfer method

Legal Events

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