An interactive control method and device based on SPI analog CAN communication and a medium

CN122339888BActive Publication Date: 2026-08-28国网(山东)电动汽车服务有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610787540.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-06-03
Publication Date
2026-08-28
Estimated Expiration
2046-06-03

AI Technical Summary

Technical Problem

[0002]串行外设接口(Serial Peripheral Interface,SPI)作为高速全双工同步通信接口,因占用I/O少、传输速度快、电路设计简洁等优势,广泛应用于微控制器与外围设备的短距离通信,但其本身无内置应答及错误检查机制,在复杂电磁环境、多设备级联场景下数据传输可靠性受限;且传统SPI无数据标识设计,多类型/多设备数据并行传输易出现混淆问题

Benefits of technology

在保留SPI物理层、高速传输、硬件接口简洁等优势的前提下,通过CAN报文格式封装引入CAN总线的帧标识与纠错机制,解决了传统SPI数据无标识、多设备数据传输混淆的问题;CRC校验覆盖“CAN扩展帧ID+有效数据”,校验范围更广,错误检测准确性更高,克服了现有改进方案仅能实现基础错误检测的短板。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122339888B_ABST
    Figure CN122339888B_ABST
Patent Text Reader

Abstract

The application discloses an interactive control method and device based on SPI analog CAN communication and a medium, the method comprises the following steps: based on the SPI data sending device, for the specified data to be sent, the corresponding CAN extended frame ID and CRC check code are spliced, and the data to be sent is obtained by encapsulation; based on the SPI data receiving device, the received data packet is unpacked, and the specified data carried in the data packet is verified and analyzed through the CAN extended frame ID and CRC check code carried in the data packet. Under the premise of retaining the advantages of SPI physical layer, high-speed transmission, simple hardware interface and the like, the frame identification and error correction mechanism of the CAN bus are introduced through CAN message format encapsulation, the problems of no identification of traditional SPI data and confusion of multi-device data transmission are solved, the CRC check covers the CAN extended frame ID and valid data, the check range is wider, the error detection accuracy is higher, and the short board that the existing improvement scheme can only realize basic error detection is overcome.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communications, specifically to an interactive control method, device, and medium based on SPI simulating CAN communication. Background Technology

[0002] The Serial Peripheral Interface (SPI), as a high-speed full-duplex synchronous communication interface, is widely used for short-distance communication between microcontrollers and peripheral devices due to its advantages such as low I / O usage, fast transmission speed, and simple circuit design. However, it lacks built-in acknowledgment and error checking mechanisms, which limits the reliability of data transmission in complex electromagnetic environments and multi-device cascading scenarios. Furthermore, traditional SPI lacks data identifier design, which can easily lead to confusion issues when multiple types / multi-device data are transmitted in parallel.

[0003] Traditional SPI reliability improvement schemes only achieve basic error detection by adding Cyclic Redundancy Check (CRC) width type and CRC checksum. This is insufficient to solve core problems such as unidentified SPI data, data transmission confusion among multiple devices, and a single error correction mechanism. Furthermore, they do not design adaptation technologies for special scenarios such as high electromagnetic interference, multi-slave device cascading, and high-speed, high-frequency, and large-volume data transmission in practical applications such as industrial automation, automotive electronics, and smart hardware. The improvement is limited in scope, and the adaptability and reliability improvement in special scenarios are limited, making it difficult to meet the high transmission requirements of industries such as industry and automotive.

[0004] The Controller Area Network (CAN) bus has excellent error detection, error correction and frame identification mechanisms, and performs well in scenarios with high reliability requirements. However, in short-distance, high-speed microcontroller-peripheral device interaction scenarios, the CAN bus has problems such as low transmission efficiency, complex hardware interfaces and high I / O resource consumption.

[0005] In summary, traditional solutions cannot simultaneously meet the communication requirements of high-speed transmission, high reliability, and adaptation to multiple special scenarios. There is an urgent need for a new communication mechanism that integrates the advantages of SPI and CAN buses and can accurately adapt to the special scenarios of actual applications. Summary of the Invention

[0006] To address the aforementioned issues, this application proposes an interactive control method based on SPI-simulated CAN communication, comprising: Based on the SPI data transmitting device, for the specified data to be transmitted, the corresponding CAN extended frame ID and CRC checksum are concatenated and encapsulated to obtain the data packet to be transmitted, and the data packet is sent to the SPI data receiving device; wherein, the concatenation process includes: for the specified data, concatenating the corresponding CAN extended frame ID to obtain first intermediate data; performing a CRC checksum algorithm on the first intermediate data to obtain a CRC checksum, and concatenating the CRC checksum with the first intermediate data to obtain second intermediate data; encapsulating the second intermediate data to obtain the data packet to be transmitted; Based on the SPI data receiving device, the received data packet is decapsulated, and the specified data carried therein is verified and parsed using the CAN extended frame ID and CRC checksum carried therein.

[0007] In one example, based on an SPI data transmitting device, before concatenating the specified data to be transmitted using the corresponding CAN extended frame ID and CRC checksum, the method further includes: Based on the SPI data transmission device, the specified data to be transmitted is obtained through the transmit buffer.

[0008] In one example, the specified data carried within the CAN extended frame ID and CRC checksum is used for verification and parsing, specifically including: The corresponding CRC checksum is recalculated using the specified data and CAN extended frame ID carried within it. Verification and parsing are performed by comparing the recalculated CRC checksum with the CRC checksum carried within it.

[0009] In one example, the method further includes: Based on the SPI master device, determine the electromagnetic interference signal strength of the communication link between the master device and the SPI slave device; If the electromagnetic interference signal strength exceeds a preset threshold, the CRC checksum will be upgraded by increasing the number of bits in the CRC checksum.

[0010] In one example, the method further includes: Based on the SPI data receiving device, it is determined that the verification parsing failed; By using fixed identifier bits, verifying the error type code that failed the parsing, and the CAN extended frame ID, a corresponding exclusive error frame is generated; The specific error frame is fed back to the SPI data transmission device.

[0011] In one example, the CAN extended frame ID is a three-level hierarchical coding structure, which is obtained by concatenating the device type code, device address code, and data service code. The method further includes: Based on the SPI master device, determine the target SPI slave device corresponding to the current chip select signal; The device address code of the target SPI slave device is embedded into the synchronization bit of the chip select signal; Verification is performed based on the target SPI slave device and the device address code.

[0012] In one example, the method further includes: Based on the SPI master device, determine the data transmission bit error rate of the communication link with the SPI slave device, as well as the clock synchronization deviation with the SPI slave device; The clock baud rate is dynamically adjusted based on the data transmission error rate and the clock synchronization deviation.

[0013] In one example, the method further includes: Based on the SPI data transmission device, it is determined that the specified data exceeds a preset basic length, and based on the basic length, the specified data is fragmented, and each fragment is assigned a master identifier corresponding to the specified data and a fragment sequence number corresponding to each fragment. Based on the SPI data receiving device, the specified data is fragmented and reassembled according to the master identifier and the fragment sequence number.

[0014] On the other hand, this application also proposes an interactive control device based on SPI simulating CAN communication, comprising: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the interactive control method based on SPI-simulated CAN communication as described in any of the above embodiments.

[0015] On the other hand, this application also proposes a non-volatile computer storage medium storing computer-executable instructions configured to implement the interactive control method based on SPI-simulated CAN communication as described in any of the above embodiments.

[0016] The interactive control method based on SPI simulating CAN communication proposed in this application can bring the following benefits: While retaining the advantages of SPI physical layer, high-speed transmission, and simple hardware interface, the frame identification and error correction mechanism of CAN bus is introduced through CAN message format encapsulation, which solves the problems of unidentified data and confusion in multi-device data transmission in traditional SPI; CRC check covers "CAN extended frame ID + valid data", with a wider verification range and higher error detection accuracy, overcoming the shortcomings of existing improvement schemes that can only achieve basic error detection.

[0017] It only encapsulates, decapsulates, and adjusts parameters for the upper-layer data of SPI communication, without changing the SPI hardware circuit or physical layer transmission protocol. It is fully compatible with existing SPI master-slave controllers and peripheral devices, making engineering implementation easier and modification costs lower. At the same time, it can be widely adapted to various scenarios such as industrial automation, automotive electronics, smart hardware, and IoT terminals, and has high prospects for industrial application and commercial value. Attached Figure Description

[0018] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a flowchart illustrating the interactive control method based on SPI simulating CAN communication in the embodiments of this application; Figure 2 This is a schematic diagram of the SPI communication principle in a conventional scheme under one scenario in the embodiments of this application; Figure 3 This is a schematic diagram of the data transmission process in one scenario of an embodiment of this application.

[0019] Figure 4 This is a schematic diagram of an interactive control device based on SPI simulating CAN communication in an embodiment of this application. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0021] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.

[0022] like Figure 1 As shown, this application provides an interactive control method based on SPI simulating CAN communication, including: S101: Based on the SPI data transmitting device, for the specified data to be transmitted, the corresponding CAN extended frame ID and CRC check code are concatenated and encapsulated to obtain the data packet to be transmitted, and the data packet is sent to the SPI data receiving device; wherein, the concatenation process includes: for the specified data, the corresponding CAN extended frame ID is concatenated to obtain first intermediate data; a CRC check algorithm is performed on the first intermediate data to obtain a CRC check code, and the CRC check code is concatenated with the first intermediate data to obtain second intermediate data; the second intermediate data is encapsulated to obtain the data packet to be transmitted.

[0023] SPI is a high-speed, full-duplex, synchronous industry-standard communication interface. This interface is primarily used for short-range communication between microcontrollers and various peripheral devices. It mainly operates in a master-slave mode. Typically, SPI communication requires a master device to control the clock signal (SCLK) and chip select signal (CS), as well as one or more slave devices. The CS signal is used by the master device to select the corresponding slave device.

[0024] like Figure 2 As shown, SPI communication has a four-wire interface, including Master Output Slave Input (MOSI), Master Input Slave Output (MISO), Clock Line (SCLK), and Chip Select Line (CS). In full-duplex mode, SPI requires four wires; in half-duplex mode, it requires only three. SPI offers advantages such as fewer I / O pins, simplified circuit design, reduced chip pin count, reduced printed circuit board (PCB) layout space, and high transmission speed. However, SPI communication also has some limitations, particularly in terms of transmission reliability and error correction mechanisms. The SPI protocol lacks a built-in acknowledgment mechanism, meaning that the master device cannot easily confirm whether the slave device has successfully received the data after sending it. Furthermore, SPI lacks error checking protocols, such as cyclic redundancy check (CRC), making it difficult to detect and correct errors in a timely manner during data transmission. This lack of error correction mechanisms challenges the reliability of SPI data transmission in complex electromagnetic environments or over long distances.

[0025] Controller Area Network (CAN) bus, as a widely used communication protocol, plays a vital role in automotive electronics and industrial automation due to its superior reliability and error correction mechanisms. The CAN bus possesses powerful error detection and handling capabilities. Through various detection methods such as cyclic redundancy check (CRC), bit stuffing, and acknowledgment errors, it can promptly detect and correct errors during transmission. Once an error is detected, the CAN node proactively sends an error frame to notify other nodes and trigger a retransmission mechanism until the data is transmitted correctly. This automatic error correction and retransmission mechanism greatly improves communication reliability, making the CAN bus perform exceptionally well in applications such as automobiles where data accuracy is extremely critical.

[0026] An SPI data transmitting device can be either an SPI master or an SPI slave, while an SPI data receiving device can be either an SPI master or an SPI slave. The CAN Extended Frame ID is a 29-bit message identifier defined in the CAN bus protocol, used to uniquely identify the source, type, and purpose of a data frame. The CRC checksum is a fixed-length check value generated by performing polynomial operations on the data block, used to detect whether bit errors have occurred during transmission or storage.

[0027] Specifically, such as Figure 3 As shown (using the SPI master device as an example for SPI data transmission), based on the SPI data transmission device, the specified data to be transmitted is obtained through the transmission buffer. When the SPI master / slave device transmits data, it first retrieves the amount of data to be transmitted from the transmission buffer. For the specified data, the first intermediate data is obtained by concatenating the corresponding CAN extended frame ID; the corresponding CAN extended frame ID is added to this specified data for identification during subsequent decapsulation.

[0028] A CRC check algorithm is applied to the first intermediate data to obtain a CRC check code. The CRC check code is then concatenated with the first intermediate data to obtain the second intermediate data. A CRC check algorithm is then applied to the concatenated data to calculate the second intermediate data, and the calculated CRC check code is then appended to the last two digits of the data.

[0029] The second intermediate data is encapsulated to obtain the data packet to be sent. The final data packet to be sent is formed, which is a standardized CAN format data packet with the format of [CAN extended frame ID + 8 bytes of data + CRC checksum]. Finally, the encapsulated data packet is transmitted to the corresponding master / slave device through the SPI interface.

[0030] S102: Based on the SPI data receiving device, the received data packet is decapsulated, and the specified data carried therein is verified and parsed using the CAN extended frame ID and CRC check code carried therein.

[0031] Specifically, such as Figure 3 As shown (using an SPI slave device as an example for SPI data receiving), the corresponding CRC checksum is recalculated using the specified data and CAN extended frame ID carried within. When receiving data, the SPI master / slave device retrieves the received data from the receive data buffer, decapsulates the encapsulated data, and separates the CAN extended frame ID, 8 bytes of data, and the CRC checksum. The CRC checksum is then recalculated using the received 8 bytes of data (the specified data length) and the CAN extended frame ID according to the CRC checksum algorithm.

[0032] Verification and parsing are performed by comparing the recalculated CRC checksum with the received CRC checksum. If they match, the data is correctly parsed and can proceed to subsequent processing; otherwise, the SPI master / slave devices will restart to perform data alignment. This process ensures the integrity and correctness of data transmitted between the SPI master / slave devices. While retaining the advantages of SPI physical layer, high-speed transmission, and simple hardware interface, the frame identification and error correction mechanism of CAN bus is introduced through CAN message format encapsulation, which solves the problems of unidentified data and confusion in multi-device data transmission in traditional SPI; CRC check covers "CAN extended frame ID + valid data", with a wider verification range and higher error detection accuracy, overcoming the shortcomings of existing improvement schemes that can only achieve basic error detection.

[0033] In one or more embodiments, the following problems may exist in industrial automation high electromagnetic interference scenarios: industrial production lines have strong electromagnetic interference sources such as frequency converters and motors; SPI communication links are prone to single / multi-bit data flipping; conventional fixed-bit CRC check has insufficient anti-interference capability; and error feedback is delayed, resulting in untimely retransmission.

[0034] Based on this, in the first embodiment, the electromagnetic interference signal strength of the communication link between the SPI master device and the SPI slave device is determined. An electromagnetic interference detection module is added to the SPI master device to collect the electromagnetic interference signal strength of the communication link in real time.

[0035] If the electromagnetic interference signal strength exceeds a preset threshold, the CRC checksum will be upgraded by increasing the number of bits. When the interference strength exceeds the preset threshold, the CRC checksum will automatically upgrade from the basic 16 bits to 32 bits to improve the fault tolerance capability; after the interference is recovered, the number of bits in the checksum will automatically decrease, realizing dynamic adaptation of the checksum strength.

[0036] In the second embodiment, based on the SPI data receiving device, it is determined that the verification parsing failed. A corresponding dedicated error frame is generated using a fixed identifier, the error type code corresponding to the failed verification parsing, and the CAN extended frame ID; this dedicated error frame is then fed back to the SPI data transmitting device. By introducing CAN bus error frame logic, a dedicated SPI error frame (fixed identifier + error type code + corresponding CAN extended frame ID) is designed. When the receiving end detects a CRC check inconsistency, it immediately transmits the error frame in reverse to the SPI data transmitting device via the MISO / MOSI link. Upon receiving the error frame, the SPI data transmitting device immediately triggers a retransmission without waiting for data alignment to complete, achieving real-time error feedback and rapid response.

[0037] In one or more embodiments, for automotive electronics scenarios with multiple slave devices cascaded, the following problems may exist: In the field of automotive electronics, there are multiple slave device cascaded architectures such as body control and lighting control. Conventional SPI selects slave devices only through the chip select signal (CS), which is prone to false wake-up of devices and data transmission errors due to signal interference; single-dimensional identification is prone to data identification conflicts among multiple devices.

[0038] Based on this, in the first embodiment, the CAN extended frame ID is a three-level hierarchical encoding structure, which is obtained by concatenating the device type code, device address code, and data service code. The three-level hierarchical encoding design for the CAN extended frame ID, with the encoding structure being [high 8 bits device type code + middle 8 bits device address code + low 8 bits data service code], achieves a precise and unique identifier for [device type - specific device - transmission service], completely avoiding ID conflicts under multi-device cascading.

[0039] In the second embodiment, based on the SPI master device, the target SPI slave device corresponding to the current chip select signal is determined; the device address code of the target SPI slave device is embedded into the synchronization bit of the chip select signal. A chip select signal and CAN extended frame ID linkage verification module is added (configured for both the SPI master and SPI slave devices). When the SPI sends the CS chip select signal, the address code of the target SPI slave device is embedded into the synchronization bit of the CS signal.

[0040] Verification is performed based on the target SPI slave device and its address code. After receiving the CS signal, the target SPI slave device first verifies the consistency between the synchronization bit address code and its own address code, and then verifies the address code of the CAN extended frame ID in the data packet. Data reception is only initiated after both verifications pass; otherwise, the data is discarded to avoid device malfunctions and data transmission errors caused by CS signal interference.

[0041] In one or more embodiments, for smart hardware interaction scenarios with high speed, high frequency and large data volume, the following problems may exist: smart hardware such as drones and industrial controllers have high speed, high frequency and large data volume interaction requirements. Conventional fixed baud rate transmission is prone to the contradiction of "high baud rate clock asynchrony and low baud rate transmission efficiency"; and when transmitting large data volume in a whole packet, if a single segment is wrong, the whole packet needs to be retransmitted, resulting in a large loss of transmission efficiency.

[0042] Based on this, in the first embodiment, the data transmission error rate of the communication link between the SPI master device and the SPI slave device, as well as the clock synchronization deviation between the two devices, are determined. The SPI master device adds a baud rate adaptive adjustment module to monitor the two core parameters in real time: the data transmission error rate of the communication link and the clock synchronization deviation between the master and slave devices.

[0043] The clock baud rate is dynamically adjusted based on the data transmission error rate and clock synchronization deviation. The SCLK clock baud rate is dynamically adjusted according to the detection results: when the error rate is low and the synchronization deviation is small, it is automatically increased to the maximum baud rate supported by the SPI hardware; when the error rate increases or the deviation increases, the baud rate is reduced in stages to achieve a dynamic balance between transmission rate and stability.

[0044] In the second embodiment, based on the SPI data transmission device, it is determined that the specified data exceeds a preset basic length. Based on the basic length, the specified data is fragmented, and each fragment is assigned a master identifier corresponding to the specified data and a fragment sequence number corresponding to each fragment. A fragmentation and reassembly mechanism based on CAN extended frame ID is designed. When the data to be transmitted exceeds the basic length of 8 bytes, the master device equally fragments the large data packet in 8-byte units, and assigns [same master ID + different fragment sequence number] to each fragment.

[0045] Based on the SPI data receiving device, specified data is fragmented and reassembled according to the master identifier and fragment sequence number. The receiving end identifies all fragments of the same original data packet based on the master ID and completes the reassembly according to the fragment sequence number; if a fragment is transmitted incorrectly, only the incorrect fragment is retransmitted, without retransmitting the entire data packet, which greatly improves transmission efficiency.

[0046] The solutions address three core scenarios: high electromagnetic interference, multi-device cascading, and high-speed, high-frequency, and large-volume data transmission. They solve the transmission problems of traditional solutions in special scenarios and respectively achieve data flipping resistance under electromagnetic interference, prevention of misoperation under multi-device cascading, and balance between rate and efficiency under high speed and high frequency, thereby improving the stability and adaptability of SPI communication in complex scenarios.

[0047] like Figure 4 As shown in the figure, this application embodiment also provides an interactive control device based on SPI simulating CAN communication, including: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the interactive control method based on SPI-simulated CAN communication as described in any of the above embodiments.

[0048] This application also provides a non-volatile computer storage medium storing computer-executable instructions configured to implement the interactive control method based on SPI-simulated CAN communication as described in any of the above embodiments.

[0049] The various embodiments in this application are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device and medium embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the description of the method embodiments.

[0050] The devices and media provided in this application are one-to-one with the methods. Therefore, the devices and media also have similar beneficial technical effects as their corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.

[0051] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0052] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0053] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0054] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0055] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0056] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0057] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0058] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0059] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. An interactive control method based on SPI simulating CAN communication, characterized in that, include: Based on the SPI data transmitting device, for the specified data to be transmitted, the corresponding CAN extended frame ID and CRC checksum are concatenated and encapsulated to obtain the data packet to be transmitted, and the data packet is sent to the SPI data receiving device; wherein, the concatenation process includes: for the specified data, concatenating the corresponding CAN extended frame ID to obtain first intermediate data; performing a CRC checksum algorithm on the first intermediate data to obtain a CRC checksum, and concatenating the CRC checksum with the first intermediate data to obtain second intermediate data; encapsulating the second intermediate data to obtain the data packet to be transmitted; Based on the SPI data receiving device, the received data packet is decapsulated, and the specified data carried therein is verified and parsed using the CAN extended frame ID and CRC check code carried therein. The specified data carried within is verified and parsed using the CAN extended frame ID and CRC checksum, specifically including: The corresponding CRC checksum is recalculated using the specified data and CAN extended frame ID carried within it. Verification and parsing are performed by comparing the recalculated CRC checksum with the CRC checksum carried within it. The method further includes: Based on the SPI master device, determine the data transmission bit error rate of the communication link with the SPI slave device, as well as the clock synchronization deviation with the SPI slave device; Based on the data transmission error rate and the clock synchronization deviation, the clock baud rate is dynamically adjusted. The method further includes: Based on the SPI data transmission device, it is determined that the specified data exceeds a preset basic length, and based on the basic length, the specified data is fragmented, and each fragment is assigned a master identifier corresponding to the specified data and a fragment sequence number corresponding to each fragment. Based on the SPI data receiving device, the specified data is fragmented and reassembled according to the master identifier and the fragment sequence number.

2. The method according to claim 1, characterized in that, Based on the SPI data transmission device, before concatenating the specified data to be transmitted using the corresponding CAN extended frame ID and CRC checksum, the method further includes: Based on the SPI data transmission device, the specified data to be transmitted is obtained through the transmit buffer.

3. The method according to claim 1, characterized in that, The method further includes: Based on the SPI master device, determine the electromagnetic interference signal strength of the communication link between the master device and the SPI slave device; If the electromagnetic interference signal strength exceeds a preset threshold, the CRC checksum will be upgraded by increasing the number of bits in the CRC checksum.

4. The method according to claim 1, characterized in that, The method further includes: Based on the SPI data receiving device, it is determined that the verification parsing failed; By using fixed identifier bits, verifying the error type code that failed the parsing, and the CAN extended frame ID, a corresponding exclusive error frame is generated; The specific error frame is fed back to the SPI data transmission device.

5. The method according to claim 1, characterized in that, The CAN extended frame ID is a three-level hierarchical encoding structure, which is obtained by concatenating the device type code, device address code, and data service code. The method further includes: Based on the SPI master device, determine the target SPI slave device corresponding to the current chip select signal; The device address code of the target SPI slave device is embedded into the synchronization bit of the chip select signal; Verification is performed based on the target SPI slave device and the device address code.

6. An interactive control device based on SPI simulating CAN communication, characterized in that, include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the interactive control method based on SPI simulating CAN communication as described in any one of claims 1 to 5.

7. A non-volatile computer storage medium storing computer-executable instructions, characterized in that, The computer-executable instructions are configured to implement the interactive control method based on SPI-simulated CAN communication as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Mutual communication method among plurality of serial interface devices

    CN111628920A

  • Data transmission method and device, equipment and storage medium

    CN121187993A