Data read-write method and heterogeneous system
By setting the specified storage area and mapped memory in a heterogeneous system, the problem that the real-time CPU cannot directly access the main memory is solved, and the data storage requirements of the real-time system are realized, ensuring real-time and effective operation.
Patent Information
- Application Number
- CN202410012588.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-03
- Publication Date
- 2025-07-04
AI Technical Summary
In heterogeneous multiprocessor systems, real-time CPUs cannot directly access the main memory device, resulting in poor real-time data acquisition and processing and control of the real-time system, which cannot meet the storage needs of the real-time system.
Set the specified storage area and mapped memory in the general system. The data of the real-time system is written to the specified storage area and then updated to the mapped memory synchronously. The real-time system reads the data through the mapped memory.
It realizes the data storage requirements of real-time systems in heterogeneous systems, ensures the real-time and effective operation of real-time systems, and the data can be checked and traced at any time.
Smart Images

Figure CN120256329A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the technical field of batteries, and relate to, but are not limited to, a data reading and writing method and a heterogeneous system. Background Art
[0002] At present, processor systems are mainly divided into two categories according to different integrated chips: homogeneous multi-core processor systems and heterogeneous multi-core processor systems. A homogeneous multi-core processor system means that the structures of the computing cores integrated in the processor are the same, and a symmetric system design is adopted; a heterogeneous processor system means that the structures of the computing cores integrated in the processor are different, and the system efficiency can be greatly improved through reasonable task allocation.
[0003] For a heterogeneous multi-processor system on a chip (SOC, System-on-a-chip), an SOC system can be composed of one or several microcontroller units (MCUs, Microcontroller Unit), a central processing unit (CPU, Central Processing Unit), a digital signal processor (DSP, Digital Signal Processor), or a field programmable gate array (FPGA, Field Programmable Gate Array). The embedded memory (EMMC, Embedded MultiMedia Card) file system and the flash memory system (FLASH, Flash EEPROM Memory) are usually driven by a general-purpose CPU. The real-time CPU cannot directly access the main storage device, resulting in that the current heterogeneous multi-processor system cannot meet the storage requirements of the real-time system, and the storage-related modules in the real-time system cannot operate normally. Summary of the Invention
[0004] To solve the problems existing in the related technologies, the embodiments of the present application provide a data reading and writing method and a heterogeneous system. A specified storage area and a mapped memory for storing real-time system data are set in the general system. The written data is stored in the specified storage area and synchronously updated to the mapped memory. The real-time system reads the data through the mapped memory, and the data storage requirements of the real-time system in the heterogeneous system can be realized.
[0005] In a first aspect, the present application provides a data reading and writing method, which is applied to a general system in the heterogeneous system. The data reading and writing method includes: setting a specified storage area and a mapped memory corresponding to the specified storage area based on the data storage requirements of the real-time system; wherein, the heterogeneous system further includes the real-time system; in response to a write command of the real-time system, writing the data to be written corresponding to the write command into the specified storage area; updating the data in the mapped memory based on the data to be written to obtain an updated mapped memory; in response to a read command of the real-time system, determining the data to be read corresponding to the read command in the updated mapped memory, and sending the data to be read to the real-time system.
[0006] In the above embodiment, a specified storage area and a mapped memory for storing the data of the real-time system are set in the general system. The written data is stored in the specified storage area and synchronously updated to the mapped memory. The real-time system reads the data through the mapped memory. It can meet the data storage requirements of the real-time system in the heterogeneous system, and the specified storage area stores all the values of the real-time system, including current data and historical data, so that the data of the real-time system can be queried and traced at any time; at the same time, it is relatively slow for the real-time system to read the data in the specified storage area. Through the mapped memory, the real-time system can quickly read the data in the mapped memory, which not only ensures the real-time performance of the real-time system but also ensures the effective operation of the real-time system.
[0007] In some embodiments, setting the mapped memory includes: creating an initial mapped memory; reading the stored data in the specified storage area to obtain a reading result; in response to the reading result indicating that there is no stored data in the specified storage area, obtaining the memory size of the specified storage area; modifying the memory initial value of the initial mapped memory based on the memory size of the specified storage area to obtain the mapped memory; in response to the reading result indicating that there is stored data in the specified storage area, updating the initial mapped memory based on the stored data in the specified storage area to obtain the mapped memory.
[0008] In the above embodiment, the set mapped memory is set based on the memory size of the specified storage area. After copying all the data in the specified storage area, the real-time system can quickly obtain the data from the mapped memory, ensuring the data acquisition requirements of the real-time system.
[0009] In some embodiments, updating the initial mapped memory based on the stored data in the specified storage area to obtain the mapped memory includes: sequentially performing data validity verification on at least one piece of stored data in the specified storage area to obtain a first verification result for each piece of stored data; performing data parsing on the stored data characterized by the first verification result being valid to obtain parsed data; and updating the parsed data to the initial mapped memory to obtain the mapped memory.
[0010] In the above embodiments, after the data in the specified storage area is parsed and updated to the mapped memory, the data in the mapped memory is not only all the data of the real-time system, but also the data that can be directly used after being parsed and read by the real-time system, reducing the step of parsing the data after the real-time system reads the data, improving the efficiency, and avoiding the problem that the real-time system affects the real-time performance due to parsing the data.
[0011] In some embodiments, before creating the initial mapped memory, the method further includes: creating a first data transmission channel for the real-time system; the first data transmission channel is used to receive the write command and the read command; after obtaining the mapped memory, the method further includes: based on the first data transmission channel, sending an indication information representing the completion of the initialization of the general system to the real-time system.
[0012] In the above embodiments, before data reading and writing, the general system is initialized, avoiding the problem of incorrect feedback to the read command or write command caused by data reading and writing before the initialization is successful, and reducing the problem of loss of data to be written.
[0013] In some embodiments, in response to the write command of the real-time system, writing the data to be written corresponding to the write command into the specified storage area includes: in response to the write command of the real-time system, performing data parsing on the write command to obtain parsed data including at least the size of the data to be written; based on the parsed data, determining the capacity information of the latest log file in the specified storage area; in response to the capacity information indicating that the latest log file is not full, writing the data to be written into the latest log file in the specified storage area; in response to the capacity information indicating that the latest log file is full, creating a new log file in the specified storage area and writing the data to be written into the new log file.
[0014] In the above embodiments, storing the data written by the real-time system in the form of log files occupies less storage space in the general system, is easy to configure and manage, and the log files are easy to retrieve and analyze, and can quickly find information about specific operations according to date range, user and other criteria.
[0015] In some embodiments, the method further includes: in response to a failure in parsing data of the write command or a failure in updating data in the mapped memory based on the data to be written, generating an error record and sending the error record to the real-time system.
[0016] In the above embodiments, after receiving the error record, the real-time system can know the situation of data write failure or data unreadable, can analyze the error cause, and write the data again to avoid the problem that the real-time system cannot read the required data subsequently.
[0017] In some embodiments, the responding to a read command of the real-time system, determining the data to be read corresponding to the read command in the updated mapped memory, and sending the data to be read to the real-time system includes: in response to the read command of the real-time system, parsing the data of the read command to obtain the data read address corresponding to the read command; determining the data to be read at the data read address in the updated mapped memory, and sending the data to be read to the real-time system.
[0018] In the above embodiments, the real-time system reads data in a specified storage area relatively slowly. Through the mapped memory, the real-time system can quickly read the data in the mapped memory, which not only ensures the real-time performance of the real-time system but also ensures the effective operation of the real-time system.
[0019] In some embodiments, the method further includes: in response to a failure in parsing data of the read command or a failure in determining the data to be read in the updated mapped memory, generating an error record and sending the error record to the real-time system.
[0020] In a second aspect, an embodiment of the present application provides a data reading and writing method, which is applied to the real-time system in the heterogeneous system. The data reading and writing method includes: in response to at least one read command or write command of multiple external applications, sorting the at least one read command or write command by priority to obtain a read command or write command that meets the sending condition; sending the read command or the write command to the general system in the heterogeneous system.
[0021] In the above embodiments, the real-time system reads or writes data based on the priority of the read command or write command, can give priority to processing urgent real-time events, reduces the probability of accidents, and improves the security of the system.
[0022] In some embodiments, the method further includes: creating a second data transmission channel with the general system; the sending the read command or the write command to the general system in the heterogeneous system includes: based on the second data transmission channel, sending the read command or the write command to the general system in the heterogeneous system.
[0023] In some embodiments, sending the write command to the general system in the heterogeneous system includes: obtaining the transmission status information of the second data transmission channel; in response to the transmission status information indicating that the second data transmission channel is in an idle state, sending the write command and the data to be written corresponding to the write command to the general system based on the second data transmission channel; in response to the successful sending of the write command and the data to be written, setting the task type and modifying the transmission status information to a busy state; in response to the general system determining that the write command and the data to be written are normal, determining the task completion status of the sending task of the write command as a success status and modifying the busy state to an idle state. In the above embodiments, the embodiments of the present application limit the transmission status information of the second data transmission channel, avoiding the problem that the second data transmission channel simultaneously transmits data and commands for multiple tasks, resulting in data writing and reading errors, and improving the accuracy of data reading and writing in the heterogeneous system.
[0024] In some embodiments, the method further includes: in response to the transmission status information indicating that the second data transmission channel is in a busy state or the sending of the write command and the data to be written fails, after delaying for a first preset time period, obtaining the transmission status information of the second data transmission channel again or sending the write command and the data to be written to the general system again based on the second data transmission channel; in response to the general system determining that the write command and the data to be written are abnormal or not receiving the information that the general system determines that the write command and the data to be written are normal within a second preset time period, determining the task completion status of the sending task of the write command as a failure status and returning the failure status to the external application.
[0025] In some embodiments, sending the read command to the general system in the heterogeneous system includes: obtaining the transmission status information of the second data transmission channel; in response to the transmission status information indicating that the second data transmission channel is in an idle state, sending the read command and the data reading address corresponding to the read command to the general system based on the second data transmission channel; in response to the successful sending of the read command and the data reading address, setting the task type and modifying the transmission status information to a busy state; in response to the general system determining that the read command and the data reading address are normal, obtaining the data to be read corresponding to the data reading address sent by the general system and modifying the busy state to an idle state.
[0026] In the above embodiments, the transmission status information of the second data transmission channel is restricted to avoid the problem of data writing and reading errors caused by the second data transmission channel simultaneously transmitting data and commands for multiple tasks, thereby improving the accuracy of data reading and writing in the heterogeneous system.
[0027] In some embodiments, the method further includes: in response to the transmission status information indicating that the second data transmission channel is in a busy state or the sending of the read command and the data read address fails, after delaying for a third preset time period, obtaining the transmission status information of the second data transmission channel again or sending the read command and the data read address to the general system again based on the second data transmission channel; in response to the general system determining that the read command and the data read address are abnormal or not receiving the information that the general system determines that the read command and the data read address are normal within a fourth preset time period, determining the acquisition task of the read command as a fault state and returning the fault state to the external application.
[0028] In a third aspect, an embodiment of the present application provides a heterogeneous system, which includes a general system and a real-time system; the real-time system at least includes a data interface and a memory driver; wherein, the data interface is used to receive at least one read command or write command of multiple external applications; the memory driver is used to prioritize at least one read command or write command of multiple external applications in response to the at least one read command or write command to obtain the highest-priority read command or write command; sending the read command or the write command to the general system in the heterogeneous system; the general system at least includes a processor, a designated storage area, and a mapped memory corresponding to the designated storage area; wherein, the processor is used to set the designated storage area and the mapped memory corresponding to the designated storage area based on the data storage requirements of the real-time system; wherein, the heterogeneous system further includes the real-time system; in response to the write command of the real-time system, writing the data to be written corresponding to the write command into the designated storage area; updating the data in the mapped memory based on the data to be written to obtain an updated mapped memory; in response to the read command of the real-time system, determining the data to be read corresponding to the read command in the updated mapped memory and sending the data to be read to the real-time system.
[0029] In the above embodiments, a specified storage area for storing real-time system data and mapped memory are set in the general system. The written data is stored in the specified storage area and synchronously updated to the mapped memory. The real-time system reads data through the mapped memory. It can meet the data storage requirements of the real-time system in heterogeneous systems, and all values of the real-time system, including current data and historical data, are stored in the specified storage area, enabling the data of the real-time system to be queried and traced at any time. At the same time, the real-time system reads data from the specified storage area relatively slowly. Through the mapped memory, the real-time system can quickly read the data in the mapped memory, which not only ensures the real-time performance of the real-time system but also guarantees the effective operation of the real-time system.
[0030] The above description is only an overview of the technical solution of the present application. In order to understand the technical means of the present application more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features, and advantages of the present application more obvious and understandable, the following specifically illustrates the specific embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 is an optional architecture schematic diagram of a heterogeneous system provided by an embodiment of the present application;
[0032] Figure 2 is an optional flowchart of a data reading and writing method provided by an embodiment of the present application Figure 1 ;
[0033] Figure 3 is an optional flowchart of a data reading and writing method provided by an embodiment of the present application Figure 2 ;
[0034] Figure 4 is an optional flowchart of a data reading and writing method provided by an embodiment of the present application Figure 3 ;
[0035] Figure 5 is an optional flowchart of a data reading and writing method provided by an embodiment of the present application Figure 4 ;
[0036] Figure 6 is an architecture schematic diagram of a heterogeneous BMS system provided by an embodiment of the present application;
[0037] Figure 7 is the overall flowchart of a data reading and writing method provided by an embodiment of the present application;
[0038] Figure 8 is the flowchart of real-time system initialization provided by an embodiment of the present application;
[0039] Figure 9 is the flowchart of general system initialization provided by an embodiment of the present application;
[0040] Figure 10 is the flowchart of the general system write operation provided by the embodiments of the present application;
[0041] Figure 11 is the flowchart of the real-time system write operation provided by the embodiments of the present application;
[0042] Figure 12 is the flowchart of the general system read operation provided by the embodiments of the present application;
[0043] Figure 13 is the flowchart of the real-time system read operation provided by the embodiments of the present application. Detailed implementation manners
[0044] In order to make the objectives, technical solutions, and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be construed as limiting the present application. All other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of the present application.
[0045] In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments. However, it can be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with each other without conflict. Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meaning as commonly understood by those skilled in the technical field to which the embodiments of the present application belong. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0046] With the increasing application of heterogeneous multi-core processors in industrial scenarios, heterogeneous multi-core processors can be used in the field of battery testing and simulation. Battery testing and simulation instruments are essential equipment for the healthy and rapid development of industries such as electric vehicles and power batteries. The SOC used in heterogeneous battery management systems (BMS, Battery Management System) usually consists of a general-purpose CPU (such as the arm-a series) and a real-time CPU (such as the arm-m / r series), as well as devices such as DSP and FPGA. The main storage devices (such as FLASH and EMMC) are generally driven by the general-purpose CPU. The real-time CPU cannot directly access the main storage device, and the storage-related modules in the real-time system cannot operate normally, resulting in poor real-time performance of data acquisition, processing, and control in conventional battery testing and simulation instruments because the real-time system cannot directly access the main memory, seriously restricting the authenticity and reliability of battery testing and simulation instruments.
[0047] To solve the problems of data in a real-time system being unable to be collected and processed in real time and poor real-time control due to the inability to access the main memory, the applicant found through research that a continuous memory block in a general system can be used to simulate the non-volatile memory (NVM) of the real-time system. The data values written by the real-time system can be reflected on this memory block, and this memory block can be a read-only memory (ROM) that can achieve permanent storage. However, in this case, the real-time system cannot read data in real time and quickly, and some real-time judgments (such as braking operations or accelerating and decelerating operations when heterogeneous systems are applied to vehicles) cannot be realized. At this time, the data on the ROM can be mapped to a random access memory (RAM), and the real-time system can read data from the RAM in real time to achieve real-time data reading and writing of the real-time system.
[0048] Therefore, the embodiments of the present application provide a data reading and writing method for a heterogeneous system, which is applied to a general system in the heterogeneous system. The general system sets a specified storage area and a mapped memory corresponding to the specified storage area based on the data storage requirements of the real-time system; in response to a write command of the real-time system, the data to be written corresponding to the write command is written into the specified storage area, and based on the data to be written, the data in the mapped memory is updated to obtain an updated mapped memory. In response to a read command of the real-time system, the data to be read corresponding to the read command is determined in the updated mapped memory, and the data to be read is sent to the real-time system. In this way, not only can the data storage requirements of the real-time system in the heterogeneous system be realized, but also the specified storage area stores all the data of the real-time system, including current data and historical data. In this way, the data of the real-time system can be checked and traced at any time; at the same time, the real-time system can quickly read the data in the mapped memory, which not only ensures the real-time performance of the real-time system but also ensures the effective operation of the real-time system.
[0049] The heterogeneous system provided by the embodiments of the present application can be used in a battery management system. A battery pack having the battery management system can be used in power-consuming devices such as vehicles, ships, or aircraft, but is not limited thereto. By using the power system of the battery pack, battery, etc. that uses the heterogeneous system provided by the embodiments of the application, it is beneficial to relieve and automatically adjust the deterioration of the expansion force of the battery cells, supplement the consumption of the electrolyte, and improve the stability of the battery performance and the battery life.
[0050] The battery pack with the heterogeneous system provided by the embodiments of the present application can be an electrical device powered by a power source. The electrical device can be, but is not limited to, a mobile phone, a tablet computer, a laptop computer, an electric toy, an electric tool, a battery car, an electric vehicle, a ship, a spacecraft, and so on. Among them, the electric toy can include a fixed or mobile electric toy, for example, a game console, an electric vehicle toy, an electric ship toy, an electric aircraft toy, and so on. The spacecraft can include an airplane, a rocket, a space shuttle, a spaceship, and so on.
[0051] In the embodiments of the present application, the battery pack can be formed by connecting multiple batteries in series and parallel. Among them, the battery can be a battery cell. A battery cell refers to a basic unit that can realize the mutual conversion of chemical energy and electrical energy, and can be used to make a battery module or a battery pack, so as to supply power to an electrical device. The battery cell can be a secondary battery, and a secondary battery refers to a battery cell that can be activated by charging after discharging to continue to be used. The battery cell can be a lithium-ion battery, a sodium-ion battery, a sodium-lithium-ion battery, a lithium-metal battery, a sodium-metal battery, a lithium-sulfur battery, a magnesium-ion battery, a nickel-metal hydride battery, a nickel-cadmium battery, a lead-acid battery, etc. The embodiments of the present application do not limit this.
[0052] The data reading and writing method provided by the embodiments of the present application is applied to a heterogeneous system, such as Figure 1 shown Figure 1 is an optional architecture diagram of the heterogeneous system provided by the embodiments of the present application. The heterogeneous system 10 includes a general system 101 and a real-time system 102. The real-time system 102 at least includes a data interface 1021 and a memory driver 1022. The data interface 1021 is used to receive at least one read command or write command of multiple external applications; the memory driver 1022 is used to prioritize at least one read command or write command in response to at least one read command or write command of multiple external applications to obtain the read command or write command with the highest priority; and send the read command or write command to the general system in the heterogeneous system.
[0053] The general system 101 at least includes a processor (not shown in the figure), a designated storage area 1011, and a mapped memory 1012 corresponding to the designated storage area 1011. The processor is used to set the designated storage area 1011 and the mapped memory 1012 corresponding to the designated storage area 1011 based on the data storage requirements of the real-time system 102; write the data to be written corresponding to the write command into the designated storage area 1011 in response to the write command of the real-time system 102; update the data in the mapped memory 1012 based on the data to be written to obtain an updated mapped memory; and determine the data to be read corresponding to the read command in the updated mapped memory and send the data to be read to the real-time system 102 in response to the read command of the real-time system 102.
[0054] In some embodiments, the general system 101 further includes a main storage unit, which can be a memory storing processor-executable instructions. When the instructions are executed by the processor, the data reading and writing method provided by the embodiments of the present application is implemented. The executable instructions can be in the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and can be deployed in any form, including being deployed as an independent program or being deployed as a module, component, subroutine, or other unit suitable for use in a computing environment. As an example, the executable instructions may or may not correspond to files in the file system, and can be stored as part of a file that stores other programs or data. For example, they can be stored in one or more scripts in a Hyper Text Markup Language (HTML) document, stored in a single file dedicated to the program in question, or stored in multiple cooperating files (e.g., files storing one or more modules, subroutines, or code portions).
[0055] In some embodiments, the data interface 1021 can be an Automotive Open System Architecture (AUTOSAR) storage interface, enabling the heterogeneous system provided by the embodiments of the present application to connect to different automotive architectures, so as to be applied to different vehicles and platforms, improve software reuse, reduce development costs, and meet the functional availability and real-time requirements of vehicles. The heterogeneous system provided by the embodiments of the present application can also be applied to any platform and device that requires real-time data and real-time operations, and the present application does not limit this.
[0056] In some embodiments, the designated storage area 1011 can be implemented in the form of a file system, and the data written by the real-time system 102 can be written into the file system in the form of a log file; the mapped memory 1012 can be RAM, enabling the real-time system to quickly read the stored data.
[0057] In some embodiments, the general system 101 and the real-time system 102 can run on different CPUs.
[0058] Figure 2 is an optional process schematic of the data reading and writing method provided by the embodiments of the present application Figure 1 , such as Figure 2 shown, the data reading and writing method is applied to the general system in the heterogeneous system. The data reading and writing method provided by the embodiments of the present application can be implemented through steps S201 to S204:
[0059] Step S201: Based on the data storage requirements of the real-time system, set a specified storage area and the mapped memory corresponding to the specified storage area; wherein, the heterogeneous system further includes the real-time system.
[0060] In the embodiments of the present application, the data storage requirements of the real-time system refer to the read and write services of data in the real-time system. When the heterogeneous system is applied to the automotive field, the real-time system can be an automotive braking system or an acceleration / deceleration system, which requires real-time control; when the heterogeneous system is applied to the battery field, the real-time system can be a battery management system, which needs to judge in real time whether the battery has overcharging, over-discharging or over-voltage conditions.
[0061] In the embodiments of the present application, the specified storage area can be a continuous memory in the general system. This continuous memory can be an independent storage unit from the main storage units FLASH and EMMC of the general system, or a continuous memory on FLASH and EMMC. Here, the specified storage area can be non-volatile memories such as ROM and Flash memory, which can be read multiple times after being written, and the stored data will not be lost after power-off.
[0062] In the embodiments of the present application, the mapped memory is a memory corresponding to the specified storage area, which can be RAM. RAM can perform data reading and writing very quickly. When data is written into the specified storage area, the mapped memory backs up the data to be used as a temporary data storage medium for the real-time system, so that the real-time system can quickly read data and achieve real-time operations.
[0063] In some embodiments, the size of the specified storage area is determined by the data storage requirements of the real-time system. The size of the specified storage area can store all the written data of the real-time system to enable the real-time system to run smoothly. The mapped memory can be the same size as the specified storage area or larger than the memory of the specified storage area. The embodiments of the present application do not limit this.
[0064] Step S202: In response to the write command of the real-time system, write the data to be written corresponding to the write command into the specified storage area.
[0065] In the embodiments of the present application, after the general system receives the write command of the real-time system, it writes the data to be written corresponding to the write command into the specified storage area.
[0066] In the embodiments of the present application, the general system and the real-time system can run on different chips. The CPUs of different chips implement data communication between the general system and the real-time system through a bus (such as a Peripheral Component Interconnect express (PCIe) bus, a Serial Peripheral Interface (SPI) bus, etc.) and Ethernet. They can also run on different CPUs of the same chip, and the CPUs implement data communication between the general system and the real-time system through shared memory and the like.
[0067] Step S203: Update the data in the mapped memory based on the data to be written, to obtain an updated mapped memory.
[0068] In the embodiments of the present application, each time the data to be written is written into the specified storage area, the mapped memory is updated, and the data to be written written into the specified storage area is updated to the mapped memory, so that the mapped memory has all the data of the specified storage area for the real-time system to read.
[0069] In the embodiments of the present application, the mapped memory can be a RAM. A RAM can only temporarily store data. Each time the system is powered off, the data in the mapped memory will disappear. Therefore, each time the system is powered on, the mapped memory will first update the data in the specified storage area so that the real-time system can read historical data in real time. And each time the data to be written is written into the specified storage area, the mapped memory will update the currently written data. Therefore, the mapped memory has not only current data but also historical data of the real-time system.
[0070] Step S204: In response to a read command from the real-time system, determine the data to be read corresponding to the read command in the updated mapped memory, and send the data to be read to the real-time system.
[0071] In the embodiments of the present application, the read command can carry a data identifier, such as a data address. When the general system receives the read command from the real-time system, it determines the data to be read corresponding to the read command in the updated mapped memory according to the data address, and sends the data to be read to the real-time system.
[0072] In the embodiments of the present application, a specified storage area for storing real-time system data and a mapped memory are set in a general system. The written data is stored in the specified storage area and synchronously updated to the mapped memory. The real-time system reads data through the mapped memory. It can meet the data storage requirements of the real-time system in heterogeneous systems, and the specified storage area stores all values of the real-time system, including current data and historical data, enabling the data of the real-time system to be queried and traced at any time. At the same time, the real-time system reads data from the specified storage area relatively slowly. Through the mapped memory, the real-time system can quickly read the data in the mapped memory, which not only ensures the real-time performance of the real-time system but also ensures the effective operation of the real-time system.
[0073] In some embodiments, the setting of the mapped memory in step S201 can be implemented through steps S2011 to S2015:
[0074] Step S2011, create an initial mapped memory.
[0075] Here, the initial mapped memory can be a continuous memory in the general system. The size of the continuous memory can be a value pre-set by a technician, which can be the same as the size of the specified storage area or larger than the memory of the specified storage area.
[0076] Step S2012, read the stored data in the specified storage area to obtain a read result.
[0077] In some embodiments, there may or may not be stored data of the real-time system in the specified storage area. In the case of having stored data, update the stored data to the initial mapped memory.
[0078] Step S2013, in response to the read result indicating that there is no stored data in the specified storage area, obtain the memory size of the specified storage area.
[0079] In the embodiments of the present application, in the case where there is no stored data in the specified storage area, the size of the initial mapped memory can be modified based on the memory size of the specified storage area so that the modified mapped memory can store the data written by the real-time system in the specified storage area.
[0080] In some embodiments, the memory size of the specified storage area can also be pre-set by a technician or estimated by the processor of the general system based on the data volume applied in the real-time system.
[0081] Step S2014, modify the memory initial value of the initial mapped memory based on the memory size of the specified storage area to obtain the mapped memory.
[0082] Here, modifying the initial memory value of the initial mapped memory may mean changing the initial memory size of the initial mapped memory according to the initial memory size of the specified storage area, so that the mapped memory after modifying the memory size can copy all the data in the specified storage area.
[0083] Step S2015, in response to the reading result indicating that there is stored data in the specified storage area, update the initial mapped memory based on the stored data in the specified storage area to obtain the mapped memory.
[0084] In some embodiments, when there is stored data in the specified storage area, the stored data in the specified storage area can be copied into the initial mapped memory, and the memory size of the initial mapped memory can be modified based on the memory size of the storage area, so that the modified mapped memory can store all the data in the specified storage area.
[0085] The mapped memory set in the embodiments of the present application is set based on the memory size of the specified storage area. After copying all the data in the specified storage area, the real-time system can quickly obtain data from the mapped memory, ensuring the data acquisition requirements of the real-time system.
[0086] In the embodiments of the present application, step S2015 can be implemented through steps S1 to S3:
[0087] Step S1, sequentially perform data validity verification on at least one stored data in the specified storage area to obtain a first verification result of each stored data.
[0088] In some embodiments, data validity verification refers to performing error detection on stored data to determine whether the data is data of the real-time system, so as to ensure the correctness and integrity of the copied stored data. The data validity verification can be cyclic redundancy check (CRC, Cyclic Redundancy Check), that is, before data update, calculate the stored data in the specified storage area to obtain a data check code corresponding to each data, copy the data check code together with the corresponding stored data, and after the stored data is updated to the mapped memory, calculate the check code of each stored data in the mapped memory again, and compare the calculated check code with the previously calculated check code. If they are the same, it means the data is complete and there is no error during the update process. If the data is incomplete, it means there is an error during the update process, and an error message needs to be fed back to the processor of the general system and the real-time system.
[0089] In the embodiments of the present application, it is necessary to perform data validity verification on all the stored data in the specified storage area to obtain a first verification result of each stored data, and the first verification result includes data valid and invalid.
[0090] Step S2: Parse the stored data for which the first verification result is valid to obtain parsed data.
[0091] In some embodiments, when the real-time system writes data, it can be written in the form of a log file. Therefore, when updating the data in the specified storage area to the mapped memory, the log file can be parsed to obtain parsed data that the real-time system can directly read.
[0092] In some embodiments, data such as the timestamp and address of the log file can be parsed through regular expressions, and the log file can also be parsed through a dedicated parsing tool (such as ELK Stack).
[0093] Step S3: Update the parsed data to the initial mapped memory to obtain the mapped memory.
[0094] In the embodiment of the present application, after parsing the data in the specified storage area and updating it to the mapped memory, the data in the mapped memory is not only all the data of the real-time system, but also the data that can be directly used after being read by the real-time system after parsing. This reduces the step of parsing data after the real-time system reads the data, improves the efficiency, and avoids the problem that the real-time system affects the real-time performance due to parsing data.
[0095] In some embodiments, before creating the initial mapped memory, the embodiment of the present application may further include step S4:
[0096] Step S4: Create a first data transmission channel for the real-time system; the first data transmission channel is used to receive the write command and the read command.
[0097] In some embodiments, the general system and the real-time system run on different CPUs. To achieve communication between the two CPUs, it needs to be realized through multi-core heterogeneous inter-core communication. Therefore, the general system needs to create a first data transmission channel that can implement the heterogeneous inter-core communication protocol for data transmission with the real-time system. For example, the real-time system encapsulates the data to be communicated (such as the write command and the read command) into a data frame according to the requirements of the heterogeneous inter-core communication protocol and sends it to the general system, and the general system receives the data based on the first data transmission channel.
[0098] Correspondingly, after obtaining the mapped memory, the method may further include step S5:
[0099] Step S5: Based on the first data transmission channel, send an indication message indicating that the initialization of the general system is completed to the real-time system.
[0100] In some embodiments, general system initialization refers to the operation in which, based on the data storage requirements of the real-time system, after the general system sets the specified storage area and maps the memory, the mapped memory updates the stored data in the specified storage area. After the mapped memory updates the latest stored data in the specified storage area, it indicates that the general system initialization is completed.
[0101] In the embodiments of the present application, after the general system initialization is completed, the general system can perform read and write operations on the real-time system. Therefore, after the general system initialization is completed, it is necessary to send, through the first data transmission channel, an indication message indicating that the general system initialization is completed to the real-time system. Based on this indication message, the real-time system performs data read and write operations.
[0102] In the embodiments of the present application, before data read and write are performed, the general system is initialized, avoiding the problem that incorrect feedback cannot be made to read or write commands due to data read and write before the initialization is successful, and reducing the probability of loss of data to be written.
[0103] In some embodiments, Figure 3 is an optional process schematic of the data read and write method provided by the embodiments of the present application Figure 2 , such as Figure 3 shown, step S202 can be implemented through steps S301 to S304.
[0104] Step S301, in response to the write command of the real-time system, perform data parsing on the write command to obtain parsed data including at least the size of the data to be written.
[0105] In the embodiments of the present application, after receiving the write command of the real-time system, it is necessary to perform data parsing on the write command to determine the data to be written corresponding to the write command and the size of the data to be written, so as to determine whether the latest log file in the specified storage area can write the data to be written.
[0106] In the embodiments of the present application, the data written by the real-time system to the specified storage area is stored in the form of a log file. Each log file contains multiple entries. Each entry in the log file can contain information such as the data address, data content, and CRC checksum of a single write by the real-time system. When a single log file exceeds the preset size, the data is written to the next log file.
[0107] Based on the log-based storage mechanism, the embodiments of the present application can record the key data of the entire life cycle of the real-time system.
[0108] Step S302, based on the parsed data, determine the capacity information of the latest log file in the specified storage area.
[0109] In some embodiments, the parsed data includes at least the size of the data to be written. According to the size of the data to be written, the capacity information of the latest log file in the specified storage area is determined, that is, whether the latest log file is full, or whether the latest log file can write the data to be written corresponding to the write command.
[0110] In some embodiments, whether the latest log file is full can be determined by judging whether the latest log file exceeds the preset size corresponding to the log file. If the latest log file exceeds or is equal to the preset size, it means that the latest log file is full.
[0111] Step S303, in response to the capacity information indicating that the latest log file is not full, write the data to be written into the latest log file in the specified storage area.
[0112] In some embodiments, the latest log file not being full means that the current log file is not full and the current log file can write the data to be written. At this time, the data to be written can be written into the latest log file in the specified storage area.
[0113] Step S304, in response to the capacity information indicating that the latest log file is full, create a new log file in the specified storage area and write the data to be written into the new log file.
[0114] In some embodiments, when the latest log file is full, a new log file can be created in the specified storage area and the data to be written can be written into the new log file.
[0115] The embodiments of the present application store the data written by the real-time system in the form of log files, which occupy less storage space in the general system, are easy to configure and manage, and the log files are easy to retrieve and analyze, and can quickly find the information of specific operations according to the date range, user and other criteria.
[0116] In some embodiments, in response to the failure of data parsing for the write command or the failure of updating the data in the mapped memory based on the data to be written, an error record is generated and sent to the real-time system. In this way, after receiving the error record, the real-time system can know the situation of data writing failure or data unreadable, can analyze the error reason, and write the data again to avoid the problem that the real-time system cannot read the required data subsequently.
[0117] In some embodiments, Figure 4 is an optional process schematic diagram of the data reading and writing method provided by the embodiments of the present application Figure 3 as Figure 4 shown, step S204 can be implemented through step S401 and step S402:
[0118] Step S401: In response to a read command of the real-time system, parse the data of the read command to obtain the data reading address corresponding to the read command.
[0119] Step S402: Determine the data to be read at the data reading address in the updated mapping memory, and send the data to be read to the real-time system.
[0120] In the embodiment of the present application, after all the data in the specified storage area is updated in the mapping memory, that is, after the initialization is completed, when a data read command of the real-time system is received, the data of the read command can be parsed to obtain the data reading address corresponding to the read command. Based on the data reading address, the data to be read corresponding to the read command can be determined in the mapping memory, and the data to be read is sent to the real-time system to meet the real-time data reading requirement of the real-time system.
[0121] In some embodiments, in response to the failure of parsing the data of the read command or the failure of determining the data to be read in the updated mapping memory, an error record is generated and sent to the real-time system.
[0122] In response to the failure of parsing the data of the read command or the failure of determining the data to be read in the updated mapping memory, an error record is generated and sent to the real-time system. In this way, after receiving the error record, the real-time system can know the situation of data writing failure or data unreadable, analyze the error reason, and write the data again to avoid the problem that the real-time system cannot read the required data subsequently.
[0123] In the embodiment of the present application, the real-time system reads the data in the specified storage area relatively slowly. Through the mapping memory, the real-time system can quickly read the data in the mapping memory, which not only ensures the real-time performance of the real-time system but also ensures the effective operation of the real-time system.
[0124] Figure 5 It is an optional process schematic diagram of the data reading and writing method provided by the embodiment of the present application Figure 4 , as Figure 5 shown, the data reading and writing method is applied to the real-time system in the heterogeneous system. The data reading and writing method provided by the embodiment of the present application can be implemented through step S501 and step S502:
[0125] Step S501: In response to at least one read command or write command of multiple external applications, perform priority sorting on the at least one read command or write command to obtain a read command or write command that meets the sending condition.
[0126] In an embodiment of the present application, a real-time system can be connected to multiple external applications through a data interface. For example, it can be connected to the braking system and speed control system of a vehicle. The real-time system can receive read commands or write commands from multiple external applications simultaneously. The memory driver prioritizes at least one read command or write command in response to the at least one read command or write command from multiple external applications, and obtains a read command or write command that meets the sending condition.
[0127] Here, the sending condition can be the read command or write command with the highest priority among at least one read command or write command. For example, a read command or write command from the braking system.
[0128] Step S502: Send the read command or the write command to the general system in the heterogeneous system.
[0129] In an embodiment of the present application, the memory driver of the real-time system can sequentially send at least one read command or write command to the general system according to the priority order of at least one read command or write command.
[0130] In an embodiment of the present application, the real-time system reads or writes data based on the priority of the read command or write command, can give priority to processing urgent real-time events, reduces the probability of accidents, and improves the security of the system.
[0131] In some embodiments, the data reading and writing method provided in the embodiment of the present application further includes step S10:
[0132] Step S10: Create a second data transmission channel with the general system.
[0133] In some embodiments, the general system and the real-time system run on different CPUs. To achieve communication between the two CPUs, it needs to be realized through multi-core heterogeneous inter-core communication. Therefore, the real-time system needs to create a first data transmission channel that can implement the heterogeneous inter-core communication protocol for data transmission with the general system. For example, based on the second data transmission channel, the data to be communicated (such as write commands and read commands) is encapsulated into data frames and sent to the general system according to the requirements of the heterogeneous inter-core communication protocol.
[0134] Correspondingly, step S502 can be implemented through step S5021:
[0135] Step S5021: Based on the second data transmission channel, send the read command or the write command to the general system in the heterogeneous system.
[0136] In some embodiments, sending the write command to the general system in the heterogeneous system in step S502 can be implemented through steps S5022 to S5025:
[0137] Step S5022: Obtain the transmission status information of the second data transmission channel.
[0138] In some embodiments, the second data transmission channel has two transmission states, namely the idle state and the busy state. When the second data transmission channel is in the idle state, data transmission can be performed; when the second data transmission channel is in the busy state, data transmission cannot be performed.
[0139] Step S5023: In response to the transmission status information indicating that the second data transmission channel is in the idle state, send the write command and the data to be written corresponding to the write command to the general system based on the second data transmission channel.
[0140] In the embodiments of the present application, when the second data transmission channel is in the idle state, the write command and the data to be written corresponding to the write command are encapsulated through the second data transmission channel and sent to the general system.
[0141] Step S5024: In response to the successful sending of the write command and the data to be written, set the task type and modify the transmission status information to the busy state.
[0142] In some embodiments, the task type refers to whether the task currently executed by the second transmission channel is data writing or data reading. After the write command is successfully sent, when the general system does not feedback the successful writing of the data to be written, the second transmission channel is used to transmit the data and instruction transmission corresponding to the write command. Therefore, the transmission status information of the second transmission channel is modified to the busy state. At this time, the second transmission channel can only be used for transmitting the data and instruction transmission corresponding to the write command.
[0143] Step S5025: In response to the general system determining that the write command and the data to be written are normal, determine the task completion status of the sending task of the write command as the successful state and modify the busy state to the idle state.
[0144] In some embodiments, after the general system determines that the write command and the data to be written are normal, the task completion status of the sending task of the write command is determined as the successful state, and the transmission status information of the second transmission channel is modified from the busy state to the idle state.
[0145] The embodiments of the present application restrict the transmission status information of the second data transmission channel, avoiding the problem that the second data transmission channel simultaneously performs data and command transmissions of multiple tasks, resulting in data writing and reading errors, and improving the accuracy of data reading and writing in heterogeneous systems.
[0146] In some embodiments, the data reading and writing method provided by the embodiments of the present application may further include step S20 and step S30:
[0147] Step S20: In response to the transmission status information indicating that the second data transmission channel is in a busy state or the write command and the data to be written are sent failed, after delaying for a first preset time period, obtain the transmission status information of the second data transmission channel again or send the write command and the data to be written to the general system again based on the second data transmission channel.
[0148] In the embodiment of the present application, if the second data transmission channel is in a busy state, the real-time system can determine the transmission status of the second data transmission channel at regular intervals (for example, every 100 milliseconds (ms)) until the transmission status is in an idle state, and then perform data writing or reading of the next priority.
[0149] In some embodiments, if the real-time system fails to send a write command and data to be written to the general system, it can send them again after a certain period of time (for example, 100 ms). If the failure occurs a preset number of times (for example, three times), it is determined that the write command and the data to be written cannot be written, and the sending of the write command is performed.
[0150] Step S30: In response to the general system determining that the write command and the data to be written are abnormal or not receiving the information that the general system determines that the write command and the data to be written are normal within a second preset time period, determine the task completion status of the sending task of the write command as a failure status, and return the failure status to the external application.
[0151] In some embodiments, if the general system determines that the write command and the data to be written are abnormal (for example, the data cannot be written or the CRC check code of the data to be written calculated by the general system is inconsistent with the check code sent by the real-time system), the task completion status of the write command can be determined as a failure status and returned to the external application.
[0152] In some embodiments, if the real-time system does not receive the information that the general system determines that the write command and the data to be written are normal within a second preset time period (for example, 1000 ms), at this time, it may be that the data cannot be written, or there is an error in the second data transmission channel, etc., resulting in the real-time system not receiving the information that the general system determines that the write command and the data to be written are normal. The task completion status of the write command can be determined as a failure status and returned to the external application, indicating to the external application that the data writing of the write command fails.
[0153] In some embodiments, sending the read command to the general system in the heterogeneous system in step S502 can be implemented through steps S5026 to S5029:
[0154] Step S5026: Obtain the transmission status information of the second data transmission channel.
[0155] In some embodiments, the second data transmission channel has two transmission states, namely, an idle state and a busy state. When the second data transmission channel is in the idle state, data transmission can be performed; when the second data transmission channel is in the busy state, data transmission cannot be performed.
[0156] Step S5027: In response to the transmission state information indicating that the second data transmission channel is in the idle state, send the read command and the data read address corresponding to the read command to the general system based on the second data transmission channel.
[0157] In the embodiments of the present application, when the second data transmission channel is in the idle state, the read command and the data read address corresponding to the read command are sent to the general system through the second data transmission channel.
[0158] Step S5028: In response to the successful sending of the read command and the data read address, set the task type and modify the transmission state information to the busy state.
[0159] In the embodiments of the present application, after the read command and the data read address are successfully sent, set the current task type to data reading and modify the transmission state information of the second data transmission channel to the busy state.
[0160] Step S5029: In response to the general system determining that the read command and the data read address are normal, obtain the data to be read corresponding to the data read address sent by the general system, and modify the busy state to the idle state.
[0161] In some embodiments, after the general system determines that the read command and the data read address are normal, obtain the data to be read corresponding to the data read address, and send the data to be read to the real-time system. After the real-time system receives the data to be read corresponding to the data read address sent by the general system, modify the busy state to the idle state.
[0162] The embodiments of the present application limit the transmission state information of the second data transmission channel, avoid the problem that the second data transmission channel simultaneously transmits data and commands for multiple tasks, resulting in data writing and reading errors, and improve the accuracy of data reading and writing in heterogeneous systems.
[0163] In some embodiments, the data reading and writing method provided by the embodiments of the present application may further include step S40 and step S50:
[0164] Step S40, in response to the transmission status information indicating that the second data transmission channel is in a busy state or the read command and the data read address are sent fails, after delaying for a third preset time period, obtain the transmission status information of the second data transmission channel again or send the read command and the data read address to the general system again based on the second data transmission channel.
[0165] In the embodiment of the present application, if the second data transmission channel is in a busy state, the real-time system can determine the transmission status of the second data transmission channel at intervals (for example, every 100 milliseconds (ms)) until the transmission status is in an idle state, and then send the read command.
[0166] In some embodiments, if the real-time system fails to send the read command and the data read address to the general system, it can send them again after a period of time (for example, 100 ms). If the failure occurs a preset number of times (for example, three times), it is determined that the data to be read corresponding to the read command and the data read address cannot be obtained, and the data writing or reading of the next priority level is performed.
[0167] Step S50, in response to the general system determining that the read command and the data read address are abnormal or not receiving the information that the general system determines that the read command and the data read address are normal within a fourth preset time period, determine the acquisition task of the read command as a failure state, and return the failure state to the external application.
[0168] In some embodiments, if the general system determines that the read command and the data read address are abnormal (for example, there is no data to be read at the storage location corresponding to the data read address), the completion status of the read command task can be determined as a failure state and returned to the external application.
[0169] In some embodiments, if the real-time system does not receive the information that the general system determines that the read command and the data read address are normal within a fourth preset time period (for example, 1000 ms), at this time, it may be that the data cannot be obtained. The completion status of the read command task can be determined as a failure state and returned to the external application, indicating to the external application that the data acquisition of the read command fails.
[0170] Next, an exemplary application of the embodiment of the present application in an actual application scenario will be described.
[0171] The embodiment of the present application provides a virtual NVM solution. The general CPU provides NVM read and write services for inter-core communication, and the real-time CPU implements the Autosar Eeprom (i.e., memory driver) driver based on this service to be compatible with traditional BMS NVM services and drivers.
[0172] Figure 6It is a schematic diagram of the architecture of the heterogeneous BMS system provided by an embodiment of the present application. As Figure 6 shown, the heterogeneous BMS system includes a real-time system 601 and a general system 602. The real-time system 601 includes an AUTOSAR memory interface 6011 and a virtual EEP driver 6012. The general system 602 includes an NVM service 6021, a specified storage area 6022, and a memory mapping 6023.
[0173] Among them, data transmission between the real-time system 601 and the general system 602 is realized through a heterogeneous inter-core communication protocol.
[0174] In some embodiments, the general system 602 uses a continuous memory block to simulate the NVM of the real-time system 601, and the data values written in the log file are reflected on this memory block. The specified storage area 6022 can be a communication system file system, which consists of multiple log files. The data written by the real-time system 601 to the virtual NVM is stored in the communication system file system in the form of log files. Each entry in the log file contains the data address, data content, and CRC checksum written by the real-time system once. When a single log file exceeds the preset size, it is written to the next log file.
[0175] Figure 7 It is the overall flowchart of the data reading and writing method provided by an embodiment of the present application. As Figure 7 shown, the data reading and writing method can be implemented through steps S701 to S710:
[0176] Step S701: The general system reads the log file.
[0177] Here, it is to read the log file corresponding to the real-time system in the specified storage area. The specified storage area is used to store the write data of the real-time system.
[0178] Step S702: The general system generates a mapped memory.
[0179] The mapped memory is used to copy the write data of the real-time system in the specified storage area for real-time reading by the real-time system.
[0180] Step S703: The general system determines the operation type of the real-time system.
[0181] In some embodiments, if the real-time system is a read operation, step S709 is executed; if the real-time system is a write operation, step S704 is executed.
[0182] Step S704: The general system determines whether the current log file in the specified storage area is full.
[0183] In some embodiments, on the premise that the real-time system is performing a write operation, the general system determines whether the current log file in the specified storage area is full. If the current log file is full, step S705 is executed; if the current log file is not full, step S707 is executed.
[0184] Step S705: Create a new log file.
[0185] In some embodiments, the general system creates a new log file in the specified storage area.
[0186] Step S706: Write the entire mapped memory.
[0187] In some embodiments, the general system can write the log file in the specified storage area into the mapped memory.
[0188] Step S707: Write the operation address and data.
[0189] In some embodiments, the general system writes the operation address and data into the new log file.
[0190] Step S708: Update the mapped memory.
[0191] In some embodiments, the general system updates the operation address and data written in the new log file to the mapped memory.
[0192] Step S709: Read the mapped memory.
[0193] In some embodiments, on the premise that the real-time system is performing a read operation, the general system reads the data in the mapped memory.
[0194] Step S710: Send operation completion.
[0195] In some embodiments, the general system sends an indication message indicating the completion of the read operation or the write operation to the real-time system.
[0196] Figure 8 It is a flowchart of the initialization of the real-time system provided by the embodiments of the present application. As Figure 8 shown, the initialization of the real-time system can be implemented through steps S801 to S803:
[0197] Step S801: Create inter-core communication.
[0198] In some embodiments, inter-core communication refers to the heterogeneous inter-core communication protocol. If the creation is successful, step S802 is executed; if the creation fails, step S803 is executed.
[0199] Step S802: The initialization of the real-time system is completed.
[0200] Step S803: The initialization of the real-time system fails.
[0201] In the embodiment of the present application, if the initialization of the real-time system and the general system is completed, the data storage requirement of the real-time system on the general system can be realized. If the initialization of the real-time system fails, the modules related to storage in the real-time system cannot run properly.
[0202] Figure 9 It is the flowchart of the initialization of the general system provided by the embodiment of the present application. As Figure 9 shown, the initialization of the general system can be realized through steps S901 to S909:
[0203] Step S901: The general system creates inter-core communication.
[0204] In some embodiments, the inter-core communication refers to the heterogeneous inter-core communication protocol. If the creation is successful, step S902 is executed; if the creation fails, step S903 is executed.
[0205] Step S902: The general system creates mapped memory.
[0206] Step S903: The initialization of the general system fails.
[0207] In the embodiment of the present application, if the creation of the inter-core communication by the general system fails, it means that the initialization of the general system fails.
[0208] Step S904: The general system reads the log file directory.
[0209] In some embodiments, when the general system reads the log file directory, it judges whether the number of log files is greater than 0. If the number of log files is greater than 0, step S905 is executed; if the number of log files is equal to 0, step S906 is executed.
[0210] Step S905: The general system reads the latest log file line by line.
[0211] In some embodiments, after the general system reads the latest log file line by line, it judges whether the CRC check of the latest log file is valid. If the CRC check is valid, step S907 is executed; if the CRC check is invalid, step S908 is executed.
[0212] Step S906: The general system sets the initial value of the mapped memory.
[0213] Step S907: The general system updates the mapped memory.
[0214] In some embodiments, when the CRC check of the latest log file is valid, the log file is updated to the mapped memory.
[0215] Step S908: The general system generates an error record.
[0216] In some embodiments, when the CRC check of the latest log file is invalid, the general system generates an error record and sends it to the real-time system.
[0217] Step S909: The general system sends an initialization completion message to the real-time system.
[0218] Figure 10 It is a flowchart of the write operation of the general system provided by the embodiments of the present application. As Figure 10 shown, the write operation of the general system can be implemented through steps S101 to S109:
[0219] Step S101: The general system determines whether it is a write command.
[0220] In some embodiments, if the real-time system sends a write command, data verification is performed on the write command. If the data verification is successful, step S102 is executed; if the data verification fails, step S103 is executed.
[0221] Step S102: The general system determines whether the current log file is full.
[0222] In some embodiments, if the current log file is full, step S104 is executed; if the current log file is not full, step S106 is executed.
[0223] Step S103: The general system generates an error record and sends an error code.
[0224] In the embodiments of the present application, if the data verification fails, an error record is generated and an error code is sent to the real-time system.
[0225] Step S104: The general system creates a new log file.
[0226] Step S105: The general system writes to the mapped memory.
[0227] Step S106: The general system writes the operation address and data.
[0228] Step S107: The general system updates the mapped memory.
[0229] In some embodiments, if the general system successfully updates the mapped memory, step S108 is executed; if the general system fails to update the mapped memory, step S103 is executed.
[0230] Step S108: The general system sends a success code to the real-time system.
[0231] In some embodiments, if the general system successfully sends a success code, the write operation ends; if the general system fails to send a success code, step S109 is executed.
[0232] Step S109: The general system generates an error record.
[0233] In some embodiments, after generating the error record, the error record is sent to the real-time system.
[0234] Figure 11 It is a flowchart of the write operation of the real-time system provided by the embodiments of the present application. As Figure 11 shown, the write operation of the real-time system can be implemented through steps S111 to S119:
[0235] Step S111: The real-time system determines whether the inter-core communication is in the busy flag set.
[0236] In some embodiments, to determine whether the inter-core communication is in the busy flag set, if the inter-core communication is in the busy flag, step S112 is executed; if the inter-core communication is in the idle flag, step S113 is executed.
[0237] Step S112: The real-time system returns an error code.
[0238] Step S113: The real-time system sends a write command and data.
[0239] In some embodiments, after the real-time system sends a write command and data, it determines whether the inter-core communication is successful. If the inter-core communication is successful, step S114 is executed; if the inter-core communication is in the idle flag, step S112 is executed.
[0240] Step S114: The real-time system sets the Task type.
[0241] In some embodiments, the Task type is used to characterize whether the command of the real-time system is a read command or a write command.
[0242] Step S115: The real-time system sets the busy flag.
[0243] The real-time system sets the inter-core communication to the busy flag, indicating that an operation of a read command or a write command is in progress.
[0244] Step S116: The real-time system returns a success code.
[0245] In some embodiments, after returning the success code, it is determined whether the general system determines that the write command and data are normal. If the general system determines that the write command and data are normal, step S117 is executed; if the general system determines that the write command and data are not normal, step S118 is executed.
[0246] Step S117: The real-time system sets the success status.
[0247] The general system determines that the write command and data are normal, and the real-time system is set to the success status.
[0248] Step S118: The real-time system sets the failure status.
[0249] If the general system determines that the write command and data are abnormal, the real-time system is set to the failure status.
[0250] Step S119: The real-time system calls the task completion callback and clears the busy flag.
[0251] After the real-time system calls the task completion callback, the busy flag is cleared, indicating that the next task can be performed now.
[0252] Figure 12 It is the flowchart of the general system read operation provided by the embodiment of the present application. As Figure 12 shown, the general system read operation can be implemented through steps S121 to S125:
[0253] Step S121: The general system determines whether it is a read command.
[0254] In some embodiments, if the real-time system sends a read command, data verification is performed on the read command. If the data verification is successful, step S122 is executed; if the data verification fails, step S123 is executed.
[0255] Step S122: The general system reads the mapped memory.
[0256] Step S123: The general system generates an error record and sends an error code.
[0257] Step S124: The general system sends a success code.
[0258] In some embodiments, if the general system sends the success code successfully, the read operation ends; if the general system fails to send the success code, step S125 is executed.
[0259] Step S125: The general system generates an error record.
[0260] In some embodiments, after generating the error record, the error record is sent to the real-time system.
[0261] Figure 13 It is the flowchart of the real-time system read operation provided by the embodiment of the present application. As Figure 13 shown, the real-time system write operation can be implemented through steps S131 to S140:
[0262] Step S131: The real-time system determines whether the inter-core communication is in the busy flag set state.
[0263] In some embodiments, it is determined whether the inter-core communication is in the busy flag set. If the inter-core communication is in the busy flag, step S133 is executed; if the inter-core communication is in the idle flag, step S132 is executed.
[0264] Step S132: The real-time system sends a read command and an address.
[0265] In some embodiments, after the real-time system sends a read command and an address, it is determined whether the inter-core communication is successful. If the inter-core communication is successful, step S134 is executed; if the inter-core communication is in the idle flag, step S133 is executed.
[0266] Step S133: The real-time system returns an error code.
[0267] Step S134: The real-time system sets the Task type.
[0268] Step S135: The real-time system sets the busy flag.
[0269] Step S136: The real-time system returns a success code.
[0270] In some embodiments, after returning the success code, it is determined whether the general system determines that the read command and the address are normal. If the general system determines that the read command and the address are normal, step S137 is executed; if the general system determines that the read command and the address are not normal, step S139 is executed.
[0271] Step S137: The real-time system copies the data to the target address.
[0272] If the general system determines that the read command and the address are normal, the data in the address corresponding to the read command is sent to the real-time system, and the real-time system copies the data to the target address.
[0273] Step S138: The real-time system sets the success status.
[0274] After the real-time system copies the data to the target address, the status of the read command can be set to the success status.
[0275] Step S139: The real-time system sets the failure status.
[0276] Step S140: The real-time system calls the task completion callback and clears the busy flag.
[0277] After the real-time system calls the task completion callback, the busy flag is cleared, indicating that the next task can be performed now.
[0278] In the embodiments of the present application, engineers can also export log files. The data log can be exported in such a way that the host computer and the general system download through file services such as secure copy (SCP) and File Transfer Protocol (FTP).
[0279] The embodiments of the present application are based on a log-based storage mechanism and can record key data throughout the entire life cycle of a real-time system. The present application can meet the real-time system data storage requirements in a heterogeneous BMS. At the same time, it not only stores the current values of the system but also stores the historical values of the data.
[0280] As described above, the above are only the embodiments of the present application and are not intended to limit the protection scope of the present application. Any modifications, equivalent replacements, and improvements made within the spirit and scope of the present application are all included in the protection scope of the present application.
Claims
1. A data reading and writing method for a heterogeneous system, characterized in that The described data reading and writing method is applied to the general system in the heterogeneous system, and the data reading and writing method includes: Based on the data storage requirements of the real-time system, set a specified storage area and the mapped memory corresponding to the specified storage area; wherein, the heterogeneous system further includes the real-time system; In response to a write command from the real-time system, write the data to be written corresponding to the write command into the specified storage area; Based on the data to be written, update the data in the mapped memory to obtain an updated mapped memory; In response to a read command from the real-time system, determine the data to be read corresponding to the read command in the updated mapped memory, and send the data to be read to the real-time system.
2. The data reading and writing method according to claim 1, wherein Setting the mapped memory includes: Create an initial mapped memory; Read the stored data in the specified storage area to obtain a read result; In response to the read result indicating that there is no stored data in the specified storage area, obtain the memory size of the specified storage area; Based on the memory size of the specified storage area, modify the memory initial value of the initial mapped memory to obtain the mapped memory; In response to the read result indicating that there is stored data in the specified storage area, update the initial mapped memory based on the stored data in the specified storage area to obtain the mapped memory.
3. The data reading and writing method according to claim 2, wherein The updating the initial mapped memory based on the stored data in the specified storage area to obtain the mapped memory includes: Successively perform data validity verification on at least one stored data in the specified storage area to obtain a first verification result for each stored data; Perform data parsing on the stored data characterized by the first verification result being valid to obtain parsed data; Update the parsed data to the initial mapped memory to obtain the mapped memory.
4. The data reading and writing method according to claim 2, characterized in that Before creating the initial mapped memory, the method further includes: Create a first data transmission channel with the real-time system; the first data transmission channel is used to receive the write command and the read command; After obtaining the mapped memory, the method further includes: Based on the first data transmission channel, send indication information indicating that the initialization of the general system is completed to the real-time system.
5. The data reading and writing method according to any one of claims 1 to 4, characterized in that, The writing the data to be written corresponding to the write command into the specified storage area in response to the write command from the real-time system includes: In response to the write command from the real-time system, perform data parsing on the write command to obtain parsed data including at least the size of the data to be written; Based on the parsed data, determine the capacity information of the latest log file in the specified storage area; In response to the capacity information indicating that the latest log file is not full, write the data to be written into the latest log file in the specified storage area; In response to the capacity information indicating that the latest log file is full, create a new log file in the specified storage area and write the data to be written into the new log file.
6. The data reading and writing method according to claim 5, characterized in that, The method further includes: In response to a failure in parsing the write command or a failure in updating the data in the mapped memory based on the data to be written, an error record is generated and sent to the real-time system.
7. The data reading and writing method according to any one of claims 1 to 4, characterized in that The step of, in response to a read command from the real-time system, determining the data to be read corresponding to the read command in the updated mapped memory and sending the data to be read to the real-time system includes: In response to a read command from the real-time system, parsing the read command to obtain the data read address corresponding to the read command; Determining the data to be read at the data read address in the updated mapped memory and sending the data to be read to the real-time system.
8. The data reading and writing method according to claim 7, wherein The method further includes: In response to a failure in parsing the read command or a failure in determining the data to be read in the updated mapped memory, an error record is generated and sent to the real-time system.
9. A data reading and writing method for a heterogeneous system, characterized in that The data reading and writing method is applied to the real-time system in the heterogeneous system, and the data reading and writing method includes: In response to at least one read command or write command from multiple external applications, performing priority sorting on the at least one read command or write command to obtain a read command or write command that meets the sending condition; Sending the read command or the write command to the general system in the heterogeneous system.
10. The data reading and writing method according to claim 9, characterized in that, The method further includes: Creating a second data transmission channel with the general system; The step of sending the read command or the write command to the general system in the heterogeneous system includes: Based on the second data transmission channel, sending the read command or the write command to the general system in the heterogeneous system.
11. The data reading and writing method according to claim 10, wherein Sending the write command to the general system in the heterogeneous system includes: Obtaining the transmission status information of the second data transmission channel; In response to the transmission status information indicating that the second data transmission channel is in an idle state, sending the write command and the data to be written corresponding to the write command to the general system based on the second data transmission channel; In response to the successful sending of the write command and the data to be written, setting the task type and modifying the transmission status information to a busy state; In response to the general system determining that the write command and the data to be written are normal, determining the task completion status of the sending task of the write command as a successful state and modifying the busy state to an idle state.
12. The data reading and writing method according to claim 11, characterized in that, The method further includes: In response to the transmission status information indicating that the second data transmission channel is in a busy state or the failure of sending the write command and the data to be written, after delaying for a first preset time period, obtaining the transmission status information of the second data transmission channel again or sending the write command and the data to be written to the general system again based on the second data transmission channel; In response to the general system determining that the write command and the data to be written are abnormal or not receiving the information that the general system determines that the write command and the data to be written are normal within a second preset time period, determining the task completion status of the sending task of the write command as a failure state and returning the failure state to the external application.
13. The data reading and writing method according to claim 10, wherein Sending the read command to the general system in the heterogeneous system includes: Obtaining the transmission status information of the second data transmission channel; In response to the transmission status information indicating that the second data transmission channel is in an idle state, sending the read command and the data read address corresponding to the read command to the general system based on the second data transmission channel; In response to the successful sending of the read command and the data read address, setting the task type and modifying the transmission status information to a busy state; In response to the general system determining that the read command and the data read address are normal, obtaining the data to be read corresponding to the data read address sent by the general system and modifying the busy state to an idle state.
14. The data reading and writing method according to claim 13, characterized in that, The method further includes: In response to the transmission status information indicating that the second data transmission channel is in a busy state or the sending of the read command and the data read address fails, after delaying for a third preset time period, obtaining the transmission status information of the second data transmission channel again or sending the read command and the data read address to the general system again based on the second data transmission channel; In response to the general system determining that the read command and the data read address are abnormal or not receiving the information that the general system determines that the read command and the data read address are normal within a fourth preset time period, determining the acquisition task of the read command as a fault state and returning the fault state to the external application.
15. A heterogeneous system, characterized in that, The heterogeneous system includes a general system and a real-time system; The real-time system at least includes a data interface and a memory driver; wherein, The data interface is used to receive at least one read command or write command from multiple external applications; The memory driver is used to, in response to at least one read command or write command from multiple external applications, perform priority sorting on the at least one read command or write command to obtain the read command or write command with the highest priority; sending the read command or the write command to the general system in the heterogeneous system; The general system at least includes a processor, a specified storage area, and a mapped memory corresponding to the specified storage area; wherein, the processor is used to set the specified storage area and the mapped memory corresponding to the specified storage area based on the data storage requirements of the real-time system; wherein, the heterogeneous system further includes the real-time system; in response to the write command of the real-time system, writing the data to be written corresponding to the write command into the specified storage area; based on the data to be written, updating the data in the mapped memory to obtain an updated mapped memory; in response to the read command of the real-time system, determining the data to be read corresponding to the read command in the updated mapped memory and sending the data to be read to the real-time system.