A communication method and system

By constructing a communication network based on LAN and CAN, and utilizing the SMU communication protocol to convert and parse data packets between the LAN and CAN networks, the problems of low communication speed and high cost between PC and MCU are solved, and efficient and reliable multi-device communication is achieved.

CN117041370BActive Publication Date: 2026-05-29BEIJING HUAFENG TEST & CONTROL TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING HUAFENG TEST & CONTROL TECH CO LTD
Filing Date
2023-08-22
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

In existing technologies, communication methods between PCs and MCUs are costly and have low cost-effectiveness. Furthermore, ordinary PCs do not have CAN interfaces, making it difficult to efficiently access the CAN bus, resulting in low communication speeds and limited scalability.

Method used

By constructing a communication network based on LAN and CAN, and designing the SMU communication protocol, the conversion and parsing of data packets between the LAN and CAN networks are realized. The data is encapsulated and parsed using UDP or TCP/IP protocols to ensure high-speed and high-reliability transmission of data between different networks.

Benefits of technology

It enables high-speed, high-reliability communication between LAN and CAN networks, is easy to expand, reduces communication costs, and eliminates the need for switches, simplifying the wiring process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117041370B_ABST
    Figure CN117041370B_ABST
Patent Text Reader

Abstract

The application provides a communication method and system, the method comprises the following steps: receiving a first data packet from a LAN network through a first protocol; the first data packet comprises a frame header, a frame tail identifier and a first data frame between the frame header and the frame tail identifier, the first protocol comprises a UDP protocol or a TCP / IP protocol; parsing the first data packet based on the first protocol, and obtaining the first data frame based on the frame header and the frame tail identifier, the first data frame is packaged in an SMU communication protocol format; parsing the first data frame using the SMU communication protocol, and determining a target address recorded in the first data frame; when the target address is located in a CAN network, packaging and encapsulating the first data frame using a CAN protocol to form each CAN data packet, and sending the CAN data packet to the CAN network, wherein each CAN data packet comprises a flag bit indicating a frame type, and a sub data frame formed by the first data frame being packaged and processed. The application can realize multi-device communication based on the LAN network and the CAN network, and has the characteristics of high speed, high reliability, easy expansion and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of basic electronic circuit technology, and in particular to a communication method and system. Background Technology

[0002] A microcontroller unit (MCU), also known as a single-chip microcomputer, integrates a CPU, memory, counter, A / D converter, universal asynchronous transceiver (UART), controller area network bus (CAN), direct memory access (DMA), and other peripheral interfaces onto a single chip, forming a chip-level computer.

[0003] A Local Area Network (LAN) is a network that interconnects various communication devices within a small area. It is characterized by short distances, low latency, and high data rates.

[0004] If the PC communicates with each MCU via a local area network, each MCU must have the corresponding hardware resources (PHY chip, Ethernet peripherals, RAM required to run the protocol suite, etc.), and a switch is also needed for networking. This communication method is costly and has low cost-effectiveness.

[0005] A more common method for PC-MCU communication is through serial ports, including RS-232, RS-485, and USB-to-serial adapters. RS-232 is an older asynchronous serial protocol with shorter transmission distances and lower data rates. Furthermore, its end-to-end data transmission makes it unsuitable for bus expansion. RS-485, compared to RS-232, offers higher data rates, longer transmission distances, and better noise immunity. It is also suitable for multi-point systems and bus expansion. A typical PC-MCU serial communication model is as follows: Figure 1 As shown, this method is simple to connect and low in cost, but it is limited by the MCU hardware and the field environment. Its serial port baud rate is usually up to 115200, which is relatively low.

[0006] CAN is a serial communication protocol bus used in real-time applications. Nodes on its network are not hierarchical; any node can actively send information to other nodes at any time. It features high performance, high reliability, and high speed. Standard CAN has a maximum speed of 1 Mbps. When the serial port baud rate is 115200, the CAN transmission rate is more than eight times that of the serial port. However, since ordinary PCs do not provide external CAN interfaces, a method must be designed to allow the PC to connect to the CAN bus, and the connection speed should not be lower than the CAN bus speed. Summary of the Invention

[0007] In view of this, this application proposes a communication method and system, computing device and medium that can realize multi-device communication based on LAN network and CAN network. Any two devices in the network can communicate with each other, and it has the characteristics of high speed, high reliability and easy expansion.

[0008] In a first aspect, this application provides a communication method, including:

[0009] A first data packet is received from a LAN network via a first protocol; the first data packet includes a frame header, a frame trailer identifier, and a first data frame between the frame header and the frame trailer identifier, wherein the first protocol includes UDP protocol or TCP / IP protocol;

[0010] The first data packet is parsed based on the first protocol, and the first data frame is obtained based on the frame header and frame tail identifiers. The first data frame is encapsulated using the SMU communication protocol format.

[0011] The first data frame is parsed using the SMU communication protocol to determine the target address recorded in the first data frame;

[0012] When the target address is located within the CAN network, the first data frame is encapsulated using the CAN protocol to form various CAN data packets, which are then sent to the CAN network. Each CAN data packet includes a flag indicating the frame type and a sub-data frame formed by the first data frame being processed by packetization.

[0013] As described above, this application constructs a communication network based on LAN and CAN, and then designs an SMU communication protocol to parse the first data packet transmitted through the first protocol. The parsed data packet is then processed into a corresponding data packet, such as a CAN data packet, according to the target address obtained from the parsing, and forwarded to the corresponding CAN network. This enables data transmission from the LAN network to the CAN network. Any two devices in this communication network can communicate with each other, and it features high speed, high reliability, and easy expansion.

[0014] Secondly, this application provides a communication method, including:

[0015] The first data frame is generated using the SMU communication protocol format;

[0016] The first data frame is encapsulated using a first protocol to form a first data packet, the first data packet including a frame header, a frame trailer identifier and the first data frame between the frame header and the frame trailer identifier, wherein the first protocol includes UDP protocol or TCP / IP protocol;

[0017] The first data packet is sent using the first protocol.

[0018] Therefore, before generating the first data packet, a first data frame can be generated according to the self-designed SMU communication protocol format. Then, a first data packet is generated by adding a frame header and a frame trailer to the first data frame, so as to send the generated UDP data packet through the first protocol. The first protocol can be the UDP protocol or the TCP / IP protocol.

[0019] Thirdly, this application provides a communication method, including:

[0020] At least one CAN data packet is received via the CAN protocol. The CAN data packet includes a flag bit indicating the frame type and a sub-data frame formed by the first data frame being packetized. The first data frame is encapsulated using the SMU communication protocol format.

[0021] The at least one CAN data packet is parsed using the CAN protocol, and each sub-data frame is obtained according to the flag bit indicating the frame type to form the complete first data frame;

[0022] The first data frame is parsed using the SMU communication protocol.

[0023] Therefore, when a device in a CAN network receives a CAN data packet via the CAN protocol, it can parse the first data frame in the CAN data packet according to the CAN protocol, and then parse the first data frame through the self-designed SMU communication protocol to obtain the data content and hand it over to the application layer for processing.

[0024] Fourthly, this application provides a communication method, including:

[0025] At least one CAN data packet is received from the CAN network via the CAN protocol. The CAN data packet includes a flag bit indicating the frame type and a sub-data frame formed by the packetization of a second data frame. The second data frame is encapsulated using the SMU communication protocol format.

[0026] The at least one CAN data packet is parsed using the CAN protocol, and each sub-data frame is obtained according to the flag bit indicating the frame type to form a complete second data frame;

[0027] The second data frame is parsed using the SMU communication protocol to determine the target address recorded in the second data frame;

[0028] When the target address is located within a LAN network, the second data frame is encapsulated using a first protocol to form a second data packet, which is then sent to the LAN network. The second data packet includes a frame header, a frame trailer identifier, and the second data frame between the frame header and the frame trailer identifier. The first protocol includes either the UDP protocol or the TCP / IP protocol.

[0029] Therefore, in the LAN and CAN-based communication network of this application, when transmitting data from the CAN network to the LAN network, the CAN data packets transmitted by the CAN network are parsed using the CAN protocol to obtain the second data frame in the CAN data packet. Then, the second data frame is parsed using the self-designed SMU communication protocol, and processed into the corresponding data packet, such as a UDP data packet, according to the parsed target address. The data packet is then forwarded to the corresponding LAN network to realize the data transmission from the CAN network to the LAN network.

[0030] Fifthly, this application provides a communication method, including:

[0031] The second data packet is received through a first protocol, the second data packet including a frame header, a frame tail identifier and a second data frame between the frame header and the frame tail identifier, wherein the first protocol includes UDP protocol or TCP / IP protocol;

[0032] The second data packet is parsed using the first protocol to obtain the second data frame between the frame header and frame trailer identifiers;

[0033] The second data frame is parsed using the SMU communication protocol.

[0034] Therefore, when a device in a LAN network receives a second data packet through the first protocol, it can parse the second data frame in the second data packet according to the first protocol, and then parse the second data frame through the self-designed SMU communication protocol to obtain the data content and hand it over to the application layer for processing.

[0035] Sixthly, this application provides a communication method, including:

[0036] The second data frame is generated using the SMU communication protocol format;

[0037] The second data frame is packetized and encapsulated using the CAN protocol to form various CAN data packets. Each CAN data packet includes a flag indicating the frame type and a sub-data frame formed by the packetization of the second data frame.

[0038] The CAN data packets are sent using the CAN protocol.

[0039] Therefore, before generating CAN data packets, a second data frame can be generated according to the self-designed SMU communication protocol format. Then, a CAN data packet is generated by adding a frame header and a frame tail to the beginning and end of the second data frame, so that the generated CAN data packet can be sent through the CAN protocol.

[0040] Seventhly, this application provides a communication method, including:

[0041] The communication method described in the second aspect is executed via a first device, the communication method described in the first aspect is executed via a second device, and the communication method described in the third aspect is executed via a third device; or

[0042] The communication method described in the sixth aspect is executed by a third device, the communication method described in the fourth aspect is executed by a second device, and the communication method described in the fifth aspect is executed by a first device.

[0043] As described above, the first and second devices are connected via LAN, and the second and third devices are connected via CAN. This application constructs a communication network based on LAN and CAN, and then designs an SMU communication protocol. The first device generates a first data frame using the SMU communication protocol format, and adds a frame header identifier and a frame trailer identifier to the first data frame to form a first data packet, such as a UDP data packet. This data packet is then transmitted to the second device via the UDP protocol. The second device parses the UDP data packet, processes it into a corresponding data packet, such as a CAN data packet, based on the parsed destination address, and forwards it to the corresponding CAN network to the third device. The third device receives and parses the CAN data packet to obtain the first data frame, thereby realizing data transmission from the LAN network to the CAN network. In addition to the above-mentioned transmission from the first device to the third device via the second device, the third device can also send data back to the first device via the second device. This enables multiple devices in the LAN network and CAN network to transmit and receive data across different protocols. Any two devices in this communication network can communicate with each other, and it has the characteristics of high speed, high reliability, and easy expansion.

[0044] Optionally, the SMU communication protocol format includes:

[0045] The target node field is used to record the target address;

[0046] The current node field is used to record the current sender address;

[0047] Data type field is used to record function codes, and the meaning of its value is defined by the application layer;

[0048] The data length field indicates the byte length of the first data frame recorded.

[0049] The data content field is used to record the content of the data packet;

[0050] The check field is used to record the calculated check value.

[0051] As described above, by adopting the SMU communication protocol format, which includes a target node field, a current node field, a data type field, a data length field, a data content field, and a checksum field, it is possible to parse a complete first or second data frame to obtain the target address, sender address, function, byte length, content, and checksum, facilitating subsequent processing. For example, the first device parses the first data frame to obtain its data content and passes it to the application layer for processing; the third device parses the second data frame, processes it into corresponding data packets based on the parsed target address, and forwards them to the corresponding LAN network to realize data transmission from the CAN network to the LAN network, while improving bandwidth utilization and response speed.

[0052] Optionally, a portion of the CAN-ID fields may be used as flag bits in the CAN data packet to indicate the frame type, which includes one of the following:

[0053] The starting frame type is the start marker for the frame;

[0054] End frame type, which is the end marker for the frame;

[0055] Data frame type, indicating the data content transmission;

[0056] Single-packet data frame type, which is a frame flag indicating that command transmission can be completed with a single data packet.

[0057] As described above, the frame type is defined by using some fields from the standard CAN-ID, thereby identifying each CAN data packet including the flag bit indicating the frame type. This enables the rapid identification of a complete frame based on the frame type. In addition to marking the start, end, and content transmission, the frame type also includes a frame flag for single-packet data, making the identification of single-packet data transmission more efficient, thereby improving bandwidth utilization and response speed.

[0058] Eighthly, this application provides a communication system, comprising:

[0059] A first device is used to perform a communication method as described in the second or fifth aspect above;

[0060] The second device is used to perform a communication method as described in the first or fourth aspect above;

[0061] A third device is used to perform a communication method as described in the third or sixth aspect above.

[0062] As described above, this communication system enables the first device to forward data packets to the third device via the second device, and the third device to forward data packets to the first device via the second device. It also enables communication between the second device and either the first or third device individually, as well as communication between multiple third devices. In other words, it enables data transmission from a LAN network to a CAN network. Any two devices in this communication network can communicate with each other, and it features high speed, high reliability, and easy scalability.

[0063] Optionally, the first device is the main control device, the second device and the third device are microcontroller units, the first device and the second device are connected via a LAN network, and the second device and each of the third devices are connected via a CAN network.

[0064] As described above, both the second and third devices are microcontroller units (MCUs). The second device has protocol forwarding and bridging functions, while there can be multiple third devices. In this application, one of the multiple MCUs is configured with Ethernet resources to serve as a second device capable of protocol forwarding and bridging. This second device can be called an SMU. The other third devices can be MCUs with different functions, which can be called BMUs. The SMU is connected to the first device (e.g., a PC) via LAN and to other BMUs via CAN, thus forming a multi-device communication system based on LAN and CAN. Then, by designing an SMU communication protocol, the data packets in the data transmission process between the PC and the SMU via the first protocol are parsed and processed, such as UDP data in the data transmission process via UDP protocol, and CAN data in the data transmission process between the SMU and each BMU via CAN protocol are parsed and processed. This enables communication between the PC, SMU, and BMU based on LAN and CAN. Any two devices in this communication network can communicate with each other, and it has the characteristics of high speed, high reliability, and easy expansion.

[0065] Ninthly, this application provides a computing device, the computing device comprising:

[0066] processor;

[0067] Memory, used to store one or more programs;

[0068] When the processor executes the one or more programs, the processor implements any of the above-described communication methods.

[0069] In a tenth aspect, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a computer, implements any of the above-described communication methods.

[0070] These and other aspects of this application will become more apparent in the description of the following embodiments(s). Attached Figure Description

[0071] Figure 1 This is a schematic diagram of an existing PC-MCU serial communication method.

[0072] Figure 2 A flowchart illustrating the first communication method provided in this application embodiment;

[0073] Figure 3 A flowchart illustrating the second communication method provided in this application embodiment;

[0074] Figure 4 This is a schematic diagram of a multi-device communication system provided in an embodiment of this application;

[0075] Figure 5 This is a schematic diagram of another multi-device communication system provided in an embodiment of this application;

[0076] Figure 6 A flowchart illustrating how a PC sends data to a BMU, as provided in this application embodiment;

[0077] Figure 7 A flowchart illustrating how a BMU sends data to a PC, as provided in this application embodiment;

[0078] Figure 8 A flowchart illustrating the SMU parsing and processing of UDP packets is provided as an embodiment of this application;

[0079] Figure 9 This is a structural diagram of a computing device provided in an embodiment of this application.

[0080] It should be understood that the dimensions and shapes of the block diagrams in the above structural diagrams are for reference only and should not constitute an exclusive interpretation of the embodiments of this application. The relative positions and inclusion relationships between the block diagrams presented in the structural diagrams are only schematic representations of the structural relationships between the block diagrams, and are not intended to limit the physical connection methods of the embodiments of this application. Detailed Implementation

[0081] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will now be described in further detail with reference to the accompanying drawings.

[0082] This application provides a communication method and system that enables multi-device communication based on LAN and CAN networks. Any two devices in the network can communicate with each other, and it features high speed, high reliability, and easy scalability.

[0083] Example 1

[0084] like Figure 2 As shown, this application provides a first communication method. The corresponding communication system is a multi-device communication system based on LAN and CAN. The communication system includes a first device, a second device, and a third device. The first device and the second device are connected via a LAN network, and the second device and each of the third devices are connected via a CAN network. The second device has protocol relay and bridging functions. The second communication method is applied to the second device. The first communication method includes:

[0085] S101: Receive the first data packet from the LAN network via the first protocol;

[0086] In this step, the first protocol may include UDP or TCP / IP. The first data packet includes a frame header, a frame trailer identifier, and a first data frame between the frame header and the frame trailer identifier. For example, when the first protocol is UDP, the first data packet is a UDP data packet, and the steps for generating and sending the UDP data packet include:

[0087] The first data frame is generated using the SMU communication protocol format;

[0088] The first data frame is encapsulated using the UDP protocol to form a UDP data packet, the UDP data packet including a frame header identifier, a frame trailer identifier, and the first data frame between the frame header identifier and the frame trailer identifier;

[0089] The UDP data packet is sent via the UDP protocol.

[0090] S102: Parse the first data packet based on the first protocol, and obtain the first data frame based on the frame header and frame tail identifiers. The first data frame is encapsulated using the SMU communication protocol format.

[0091] S103: Use the SMU communication protocol to parse the first data frame and determine the target address recorded in the first data frame;

[0092] S104: When the target address is located within the CAN network, the first data frame is encapsulated using the CAN protocol to form various CAN data packets, which are then sent to the CAN network. Each CAN data packet includes a flag indicating the frame type and a sub-data frame formed by the first data frame being processed by packetization.

[0093] In some embodiments, after the CAN data packet generated above is sent to the CAN network via the CAN protocol, the CAN data packet can be parsed and further processed by devices in the CAN network, specifically including:

[0094] At least one CAN data packet is received via the CAN protocol. The CAN data packet includes a flag bit indicating the frame type and a sub-data frame formed by the first data frame being packetized. The first data frame is encapsulated using the SMU communication protocol format.

[0095] The at least one CAN data packet is parsed using the CAN protocol, and each sub-data frame is obtained according to the flag bit indicating the frame type to form the complete first data frame;

[0096] The first data frame is parsed using the SMU communication protocol.

[0097] Example 2

[0098] like Figure 3 As shown, this application provides a second communication method. The corresponding communication system is a multi-device communication system based on LAN and CAN. This communication system includes a first device, a second device, and a third device. The first device and the second device are connected via a LAN network, and the second device and the third device are connected via a CAN network. The second device has protocol relay and bridging functions. The second communication method is applied to the second device and includes:

[0099] S201: Receive at least one CAN data packet from the CAN network via the CAN protocol;

[0100] In this step, the CAN data packet includes a flag indicating the frame type, and sub-data frames formed by packet processing of the second data frame, wherein the second data frame is encapsulated using the SMU communication protocol format; specifically, the steps for generating and sending the CAN data packet include:

[0101] The second data frame is generated using the SMU communication protocol format;

[0102] The second data frame is packetized and encapsulated using the CAN protocol to form various CAN data packets. Each CAN data packet includes a flag indicating the frame type and a sub-data frame formed by the packetization of the second data frame.

[0103] The CAN data packets are sent using the CAN protocol.

[0104] S202: Use the CAN protocol to parse the at least one CAN data packet, and obtain each sub-data frame according to the flag bit indicating the frame type to form a complete second data frame;

[0105] S203: Use the SMU communication protocol to parse the second data frame and determine the target address recorded in the second data frame;

[0106] S204: When the target address is located within a LAN network, the second data frame is encapsulated using a first protocol to form a second data packet, and sent to the LAN network; the second data packet includes a frame header, a frame trailer identifier, and the second data frame between the frame header and the frame trailer identifier, wherein the first protocol includes UDP protocol or TCP / IP protocol.

[0107] In some embodiments, after the second data packet generated above is sent to the LAN network via the first protocol, the second data packet can be parsed and further processed by devices in the LAN network, specifically including:

[0108] The second data packet is received through a first protocol, the second data packet including a frame header, a frame tail identifier and a second data frame between the frame header and the frame tail identifier, wherein the first protocol includes UDP protocol or TCP / IP protocol;

[0109] The second data packet is parsed using the first protocol to obtain the second data frame between the frame header and frame trailer identifiers;

[0110] The second data frame is parsed using the SMU communication protocol.

[0111] Example 3

[0112] like Figure 4 As shown, this application provides a multi-device communication system. One of multiple MCUs is configured with Ethernet hardware resources to function as a bridge for protocol forwarding. This MCU with the bridge function acts as an SMU (System-Defined Unit), corresponding to the second device mentioned above. Other MCUs with specific functions act as BMUs (Browser-Defined Units), corresponding to the third device mentioned above. The SMU is connected to a PC via LAN, and the PC corresponds to the first device mentioned above. It is also connected to the other BMUs via CAN, thus forming a multi-device communication system based on LAN and CAN. An SMU communication protocol is designed to parse and process UDP packets during data transmission between the PC and SMU via UDP, and simultaneously parse and process CAN packets during data transmission between the SMU and each BMU via CAN, thereby enabling communication between the PC, SMU, and BMU based on LAN and CAN. (Refer to...) Figure 4 As shown, the communication system includes PC100, SMU200 and multiple BMU310 and 320. PC100 and SMU200 are connected via LAN, and SMU200 is connected to each BMU310 and 320 via CAN.

[0113] The SMU200 is an MCU for configuring Ethernet hardware resources and is used to implement the bridge function for protocol forwarding. The BMU310 and 320 are MCUs with specific functions and do not require Ethernet hardware resource configuration.

[0114] In some embodiments, such as Figure 5 As shown, in this communication system, PC100 and SMU200 are connected via LAN, SMU200 and BMU310 are connected via CAN, while other BMUs 320, 330, 340 and 350 can be installed on the backplane and uniformly connected to the backplane's transmission line, and then the backplane is connected to the CAN network through the transmission line.

[0115] To achieve the LAN communication between the PC and the SMU, and the CAN communication between the SMU and the BMU, this application embodiment designs an SMU communication protocol. This SMU communication protocol makes the following provisions for LAN link layer communication between the PC and the SMU:

[0116] The PC and SMU are connected via LAN and use the UDP protocol to transmit data.

[0117] To identify and verify a frame, when sending a frame of UDP data, additional frame header and frame trailer identifiers are added. These frame header and frame trailer identifiers can also be called frame header flags and frame trailer flags.

[0118] When a UDP data frame is received, after verifying and removing the frame header and frame trailer flags, it is handed over to the parsing protocol in the SMU communication protocol for parsing processing;

[0119] The frame header is two bytes: 0x55AA, and the frame trailer is two bytes: 0xAA55.

[0120] It should be noted that the lengths and values ​​of the frame header and frame trailer identifiers mentioned above can also be other values, such as: a frame header of 3 bytes with a value of 0x112233; and a frame trailer of 3 bytes with a value of 0x332211. This SMU communication protocol specifies the following for CAN link layer communication between the SMU and BMU:

[0121] The SMU and BMU are connected via CAN and use the CAN protocol to transmit data.

[0122] To identify each packet of data received and transmitted via CAN in a single frame, some bits are extracted from the CAN-ID to indicate the frame type.

[0123] The standard CAN-ID is 11 bits, with bits [0:4] being the original CAN-ID, bits [5:7] being redefined as the CAN frame type, and the rest being retained; the CAN frame type definition is shown below;

[0124] Frame type Frame classification Frame meaning 0×1 start frame Start of frame 0×2 End frame End of frame marker 0×3 Data Frame Data content transmission flag 0×6 Single packet data frame A frame flag indicating that a single data packet can complete the command transmission.

[0125] It should be noted that the above method of "using the [0:4] bit field to represent the original CAN-ID, redefining the [5:7] bit field as the CAN frame type, and retaining the remaining bits" is not the only one. For example, the [0:7] bit field can also be used to represent the original CAN-ID, and the [8:10] bit field can be redefining the CAN frame type. In other words, using a portion of the CAN-ID as a flag bit in the CAN data packet to identify the frame type can be possible. Using "a portion of the CAN-ID" can include two or more bits. Using more bits to represent the original CAN-ID increases the range of allowed CAN-IDs and can be defined according to the actual application.

[0126] When receiving or sending CAN data packets, the frame type in the CAN-ID is parsed or processed. When a frame is identified, the complete data is then handed over to the parsing protocol in the SMU communication protocol for parsing and processing.

[0127] In this SMU communication protocol, a parsing protocol was also designed to define the format and meaning of a data frame. The frame format of this parsing protocol is as follows:

[0128] target node Current node Data types Data length Data content Check bit

[0129] The meaning of this parsed protocol frame is as follows:

[0130] name illustrate 1 target node Used to represent the target address 2 Current node Used to indicate the current sender address 3 Data types Used to represent function codes, the meaning of which is defined by the application layer. 4 Data length Indicates the data length from the target node to the check bit. 5 Data content Data packet content 6 Check bit Calculate the checksum from the target address to the data content.

[0131] Based on the above-designed SMU communication protocol, such as Figure 6 As shown in the figure, this application embodiment provides a communication method for a PC to send data to a BMU, including:

[0132] S301: The PC uses the SMU communication protocol to generate the data to be sent into a UDP packet and then sends it to the SMU via the UDP protocol;

[0133] In this step, the PC fills the data to be sent into a UDP data packet according to the parsing protocol frame format in the SMU communication protocol, adds LAN link layer frame header and frame tail flags to the header and tail of the UDP data packet, and then calls the UDP data sending interface to send the UDP data packet to the SMU.

[0134] S302: The SMU uses the SMU communication protocol to parse and process the received UDP data packets, generates CAN data packets, and forwards them to the BMU via CAN protocol packetization.

[0135] In this step, the SMU performs header and trailer checks on the received UDP packets to determine if they conform to the LAN link layer frame header and trailer flags. If they do not conform, the UDP packet is discarded. If they do conform, the frame header and trailer flags are removed, and the UDP packet is parsed using the parsing protocol in the SMU communication protocol. After successful parsing, it is determined whether the destination address in the UDP packet is itself. If so, it is submitted to the application layer for further processing. If the destination address is the BMU of the CAN link layer, the UDP packet is generated into a CAN packet, and the CAN link layer frame header and trailer flags are added to the header and trailer of the CAN packet. The CAN link layer sending interface is called, and the packet is forwarded to the corresponding BMU according to the destination address.

[0136] S303: The BMU receives and buffers CAN data packets via the CAN protocol, parses the CAN data packets using the parsing protocol in the SMU communication protocol, and submits the parsed data content to the application layer for processing;

[0137] In this step, the BMU receives and buffers the CAN data packets sent by the SMU via the CAN protocol. When each CAN data packet is received, the BMU checks the frame type in the CAN-ID to determine if it is the end of a frame and buffers the data packet. When the CAN frame transmission end flag is detected, a complete CAN data frame has been buffered. The BMU can then parse the CAN data frame using the parsing protocol in the SMU communication protocol and determine if the target address is itself. If not, no processing is performed; otherwise, the parsed data content is submitted to the application layer for processing.

[0138] Thus, a complete communication cycle in which the PC sends a frame of data to the designated BMU ends.

[0139] Based on the above-designed SMU communication protocol, such as Figure 7 As shown in the embodiments of this application, a communication method for BMU to send data to PC is also provided, including:

[0140] S401: The BMU generates the data to be sent into a CAN data packet and sends the CAN data packet to the SMU via the CAN protocol;

[0141] In this step, when the BMU finishes processing the data and needs to send the data to the PC, the BMU generates the data to be sent into a CAN data packet, adds CAN link layer frame header and frame tail flags to the header and tail of the CAN data packet, and then calls the CAN link layer transmission interface to send the CAN data packet to the SMU.

[0142] S402: The SMU uses the SMU communication protocol to generate UDP packets from the CAN data packets sent by the BMU and then sends them to the PC via the UDP protocol;

[0143] In this step, the SMU receives CAN data packets sent by the BMU via the CAN protocol and performs header and trailer checks on the received CAN data packets to determine if they conform to the CAN link layer frame header and trailer flags. If they do not conform, the CAN data packet is discarded. If they conform, the frame header and trailer flags are removed, and the CAN data packet is parsed using the parsing protocol in the SMU communication protocol. After successful parsing, it is determined whether the destination address in the CAN data packet is itself. If so, it is submitted to the application layer for further processing. If the destination address is a PC in the LAN link layer, the CAN data packet is generated into a UDP data packet, and the LAN link layer frame header and trailer flags are added to the header and trailer of the UDP data packet. The UDP data sending interface is then called to send the UDP data packet to the PC.

[0144] S403: The PC uses the SMU communication protocol to parse the UDP packets sent by the SMU via the UDP protocol and submits the parsed data to the application layer for processing.

[0145] In this step, the PC performs header and trailer checks on the received UDP packets to determine if they conform to the LAN link layer frame header and trailer flags. If they do not conform, the UDP packet is discarded. If they do conform, the frame header and trailer flags are removed, and the UDP packet is parsed using the parsing protocol in the SMU communication protocol. After successful parsing, the PC determines if the destination address in the UDP packet is itself. If so, the parsed data content is submitted to the application layer for processing.

[0146] Thus, a complete communication process in which a designated BMU sends a data frame to the PC ends.

[0147] It should be noted that when the PC or SMU uses the SMU communication protocol to parse data, if the parsing fails, the data is discarded. If the parsing succeeds, it is determined whether the target address of the data is itself. If so, each segment of data (node ​​address, data type, data length, etc.) is extracted, and the registered application layer callback function is called. The application layer then performs further processing according to the actual functional requirements. If not, the corresponding sending function is called to forward the protocol based on the target address and the link layer.

[0148] like Figure 8As shown, when the SMU receives UDP packets via the UDP protocol, it performs header and trailer checks on the UDP packets based on the UDP protocol to determine if they conform to the LAN link layer frame header and trailer flags. If the parsing fails, the UDP packet is discarded. If the parsing succeeds, the SMU parses the data frames within the UDP packet according to the SMU communication protocol, checking if the frame data verification passes and if the format is correct. If the parsing fails, the data frame is discarded. If the parsing succeeds, it checks if the destination address of the data frame is its own. If so, it submits the data frame to the application layer for processing, executes the corresponding function, generates a response frame based on the execution result, encapsulates the response frame into a UDP packet, and sends it to the LAN network. If the destination address is not its own, it forwards the data frame according to the destination address, for example, encapsulating the data frame into a CAN packet and forwarding it to the CAN network. Thus, the SMU can parse, forward, or process received UDP packets.

[0149] In summary, the multi-device communication method and system based on LAN and CAN provided in this application fully utilize the advantages of LAN and CAN. It only requires a single MCU with the necessary hardware resources to support Ethernet, and eliminates the need for a switch. This ensures high stability and high speed of data transmission, as well as simple wiring, easy bus expansion, and cost-effectiveness.

[0150] Figure 9 This is a structural diagram of a computing device 500 provided in an embodiment of this application. The computing device 500 includes: a processor 510, a memory 520, a communication interface 530, and a bus 540.

[0151] It should be understood that Figure 9 The communication interface 530 in the computing device 500 shown can be used to communicate with other devices.

[0152] The processor 510 can be connected to the memory 520. The memory 520 can be used to store the program code and data. Therefore, the memory 520 can be a storage unit inside the processor 510, an external storage unit independent of the processor 510, or a component that includes both the storage unit inside the processor 510 and the external storage unit independent of the processor 510.

[0153] Optionally, the computing device 500 may also include a bus 540. The memory 520 and communication interface 530 can be connected to the processor 510 via the bus 540. The bus 540 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus 540 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 9 The symbol is represented by only one line, but this does not mean that there is only one bus or one type of bus.

[0154] It should be understood that in the embodiments of this application, the processor 510 may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor. Alternatively, the processor 510 may employ one or more integrated circuits to execute relevant programs to implement the technical solutions provided in the embodiments of this application.

[0155] The memory 520 may include read-only memory and random access memory, and provides instructions and data to the processor 510. A portion of the processor 510 may also include non-volatile random access memory. For example, the processor 510 may also store device type information.

[0156] When the computing device 500 is running, the processor 510 executes the computer execution instructions in the memory 520 to perform the operation steps of the above method.

[0157] It should be understood that the computing device 500 according to the embodiments of this application can correspond to the corresponding subject in executing the methods according to the various embodiments of this application, and the other operations and / or functions of each module in the computing device 500 are respectively for implementing the corresponding processes of the methods of this embodiment. For the sake of brevity, they will not be described in detail here.

[0158] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0159] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0160] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0161] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0162] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0163] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0164] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, is used to perform the above-described method, which includes at least one of the schemes described in the above embodiments.

[0165] The computer storage medium in this application embodiment can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. For example, a computer-readable storage medium can be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0166] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.

[0167] The program code contained on a computer-readable medium may be transmitted using any suitable medium, including, but not limited to, wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0168] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0169] It should be noted that the embodiments described in this application are merely some embodiments, not all embodiments. The components of the embodiments of this application typically described and shown in the accompanying drawings can be arranged and designed in various different configurations. Therefore, the above detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0170] The terms "first, second, third, etc." or similar terms such as module A, module B, module C, etc., used in the specification and claims are only used to distinguish similar objects and do not represent a specific ordering of objects. It is understood that a specific order or sequence may be interchanged where permitted so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0171] In the above description, the labels indicating the steps do not necessarily mean that the steps will be executed. They may include intermediate steps or be replaced by other steps. Where permissible, the order of the steps may be interchanged or executed simultaneously.

[0172] The term "comprising" as used in the specification and claims should not be construed as limiting itself to what follows; it does not exclude other elements or steps. Therefore, it should be interpreted as specifying the presence of the mentioned feature, integral, step, or component, but does not exclude the presence or addition of one or more other features, integrals, steps, or components, or groups thereof. Thus, the statement "device comprising means A and B" should not be limited to a device consisting solely of components A and B.

[0173] The terms "an embodiment" or "an embodiment" as used in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in at least one embodiment of this application. Therefore, the terms "in one embodiment" or "in an embodiment" appearing throughout this specification do not necessarily refer to the same embodiment, but may refer to the same embodiment. Furthermore, in the various embodiments of this application, unless otherwise specified or in case of logical conflict, the terminology and / or descriptions between different embodiments are consistent and can be mutually referenced. Technical features in different embodiments can be combined to form new embodiments based on their inherent logical relationships.

[0174] Note that the above are merely preferred embodiments and the technical principles employed in this application. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present application has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, all of which fall within the scope of protection of the present invention.

Claims

1. A communication method, characterized in that, include: Receive the first data packet from the LAN network using the first protocol; The first data packet includes a frame header, a frame trailer identifier, and a first data frame between the frame header and the frame trailer identifier, wherein the first protocol includes the UDP protocol or the TCP / IP protocol; The first data packet is parsed based on the first protocol, and the first data frame is obtained based on the frame header and frame tail identifiers. The first data frame is encapsulated using the SMU communication protocol format. The first data frame is parsed using the SMU communication protocol to determine the target address recorded in the first data frame; When the target address is located within the CAN network, the first data frame is encapsulated using the CAN protocol to form various CAN data packets, which are then sent to the CAN network. Each CAN data packet includes a flag indicating the frame type and a sub-data frame formed by the first data frame being processed by packetization.

2. A communication method, characterized in that, include: The first data frame is generated using the SMU communication protocol format; The first data frame is encapsulated using a first protocol to form a first data packet, the first data packet including a frame header, a frame trailer identifier and the first data frame between the frame header and the frame trailer identifier, wherein the first protocol includes UDP protocol or TCP / IP protocol; The first data packet is sent using the first protocol.

3. A communication method, characterized in that, include: At least one CAN data packet is received via the CAN protocol. The CAN data packet includes a flag bit indicating the frame type and a sub-data frame formed by the first data frame being packetized. The first data frame is encapsulated using the SMU communication protocol format. The at least one CAN data packet is parsed using the CAN protocol, and each sub-data frame is obtained according to the flag bit indicating the frame type to form the complete first data frame; The first data frame is parsed using the SMU communication protocol.

4. A communication method, characterized in that, include: At least one CAN data packet is received from the CAN network via the CAN protocol. The CAN data packet includes a flag bit indicating the frame type and a sub-data frame formed by the packetization of a second data frame. The second data frame is encapsulated using the SMU communication protocol format. The at least one CAN data packet is parsed using the CAN protocol, and each sub-data frame is obtained according to the flag bit indicating the frame type to form a complete second data frame; The second data frame is parsed using the SMU communication protocol to determine the target address recorded in the second data frame; When the target address is located within a LAN network, the second data frame is encapsulated using a first protocol to form a second data packet, which is then sent to the LAN network. The second data packet includes a frame header, a frame trailer identifier, and the second data frame between the frame header and the frame trailer identifier. The first protocol includes either the UDP protocol or the TCP / IP protocol.

5. A communication method, characterized in that, include: The second data packet is received through a first protocol, the second data packet including a frame header, a frame tail identifier and a second data frame between the frame header and the frame tail identifier, wherein the first protocol includes UDP protocol or TCP / IP protocol; The second data packet is parsed using the first protocol to obtain the second data frame between the frame header and frame trailer identifiers; The second data frame is parsed using the SMU communication protocol.

6. A communication method, characterized in that, include: The second data frame is generated using the SMU communication protocol format; The second data frame is packetized and encapsulated using the CAN protocol to form various CAN data packets. Each CAN data packet includes a flag indicating the frame type and a sub-data frame formed by the packetization of the second data frame. The CAN data packets are sent using the CAN protocol.

7. A communication method, characterized in that, include: The method of claim 2 is performed using a first device, the method of claim 1 is performed using a second device, and the method of claim 3 is performed using a third device; or The method of claim 6 is performed by a third device, the method of claim 4 is performed by a second device, and the method of claim 5 is performed by a first device.

8. The method according to any one of claims 1-7, characterized in that, The SMU communication protocol format includes: The target node field is used to record the target address; The current node field is used to record the current sender address; Data type fields are used to record function codes, and their values ​​are defined by the application layer. The data length field indicates the byte length of the first data frame recorded. The data content field is used to record the content of the data packet; The check field is used to record the calculated check value.

9. The method according to any one of claims 1-7, characterized in that, A portion of the CAN-ID field is used as a flag bit in the CAN data packet to indicate the frame type, which includes one of the following: The starting frame type is the start marker for the frame; End frame type, which is the end marker for the frame; Data frame type, indicating the data content to be transmitted; Single-packet data frame type, which is a frame flag indicating that command transmission can be completed with a single data packet.

10. A communication system, characterized in that, include: A first device for performing the method of claim 2 or 5; A second device is used to perform the method according to claim 1 or 4; A third device is used to perform the method of claim 3 or 6.

11. The communication system according to claim 10, characterized in that, The first device is the main control device, the second device and the third device are microcontroller units, the first device and the second device are connected via a LAN network, and the second device and each of the third devices are connected via a CAN network.