Write-in method of communication protocol of battery management system, electronic equipment and storage medium
By automatically extracting and writing communication protocol data values using candidate mapping relationships in photovoltaic devices, the inefficiency and error problems caused by manual editing are solved, and the efficiency and reliability of communication protocol writing is improved.
Patent Information
- Application Number
- CN202411213049.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-12-24
AI Technical Summary
When existing photovoltaic devices write different battery management system (BMS) communication protocols, they need to manually edit the underlying communication code, resulting in high workload, low efficiency and error-prone.
By obtaining the communication protocol identifier to be written in the target photovoltaic device, the storage address of the target protocol data value is determined using the pre-constructed candidate mapping relationship, and these data values are automatically extracted and written to avoid manual code editing.
It improves the efficiency and reliability of communication protocol writing, reduces workload, avoids errors caused by manual editing, and achieves higher accuracy and stability.
Smart Images

Figure CN119179653A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the technical field of photovoltaic equipment, and in particular to a method for writing a battery management system communication protocol, an electronic device, and a storage medium. Background Art
[0002] There are many battery management system (BMS) manufacturers on the market. Different BMS manufacturers use different BMS communication protocols. Photovoltaic equipment needs to support the access of lithium battery BMS communication protocols, and often faces the need to write BMS communication protocols of different BMS manufacturers into photovoltaic equipment.
[0003] The common practice in the current industry is that whenever a BMS communication protocol is written into a photovoltaic device, the underlying communication code of the photovoltaic device needs to be manually edited to realize the writing of the BMS communication protocol. This method will bring a large workload, low writing efficiency and prone to errors. Summary of the invention
[0004] The first aspect of the present application provides a method for writing a battery management system communication protocol, comprising: obtaining a target protocol identifier of a communication protocol to be written in a target photovoltaic device; determining a target mapping relationship from candidate mapping relationships according to the target protocol identifier, and determining a target storage address in a target memory of a target protocol data value contained in the communication protocol to be written according to the target mapping relationship; wherein the candidate mapping relationship is determined according to a candidate protocol data type contained in the candidate communication protocol, and a candidate storage address in the target memory of a candidate protocol data value corresponding to the candidate protocol data type; extracting the target protocol data value from the target memory according to the target storage address, and writing the communication protocol to be written according to the target protocol data value.
[0005] The second aspect of the present application provides an electronic device, which includes a memory for storing a group of instructions and at least one processor configured to execute the group of instructions so that the electronic device executes the method according to the first aspect.
[0006] A third aspect of the present application provides a non-transitory computer-readable storage medium, which stores a set of instructions for a computer, and when the set of instructions is executed, causes the computer to perform the method as described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0007] In order to more clearly illustrate the technical solutions in the present application or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0008] Figure 1 A schematic diagram of a host according to an embodiment of the present application is shown.
[0009] Figure 2 A flowchart of a method for writing a battery management system communication protocol according to an embodiment of the present application is shown.
[0010] Figure 3 A flowchart of a method for writing a battery management system communication protocol according to an embodiment of the present application is shown.
[0011] Figure 4 A flowchart of a method for writing a battery management system communication protocol according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0012] In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.
[0013] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in this application should be understood by people with ordinary skills in the field to which this application belongs. "Target", "candidate", "new", "first", "second" and similar words used in this application do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" and other similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" and other similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect.
[0014] Figure 1 FIG. 1 is a schematic diagram of a host 100 according to an embodiment of the present application. The host 100 may be an electronic device running a simulation system. Figure 1 As shown, the host 100 may include: a processor 102, a memory 104, a network interface 106, a peripheral interface 108 and a bus 110. The processor 102, the memory 104, the network interface 106 and the peripheral interface 108 are connected to each other in communication within the host through the bus 110.
[0015] Processor 102 may be a central processing unit (CPU), an image processor, a neural network processor (NPU), a microcontroller (MCU), a programmable logic device, a digital signal processor (DSP), an application specific integrated circuit (ASIC), or one or more integrated circuits. Processor 102 may be used to perform functions related to the technology described in this application. In some embodiments, processor 102 may also include multiple processors integrated into a single logical component. Figure 1 As shown, the processor 102 may include a plurality of processors 103A, 103B, and 102c.
[0016] The memory 104 may be configured to store data (eg, instruction sets, computer codes, intermediate data, etc.). In some embodiments, the simulation test system for simulation test design may be a computer program stored in the memory 104. Figure 1 As shown, the data stored in the memory may include program instructions (e.g., program instructions for implementing the writing method of the battery management system communication protocol of the present application) and data to be processed (e.g., the memory may store temporary code generated during the compilation process). The processor 102 may also access the program instructions and data stored in the memory, and execute the program instructions to operate on the data to be processed. The memory 104 may include a volatile storage device or a non-volatile storage device. In some embodiments, the memory 104 may include a random access memory (RAM), a read-only memory (ROM), an optical disk, a magnetic disk, a hard disk, a solid-state drive (SSD), a flash memory, a memory stick, etc.
[0017] The network interface 106 can be configured to provide communication with other external devices to the host 100 via a network. The network can be any wired or wireless network capable of transmitting and receiving data. For example, the network can be a wired network, a local wireless network (e.g., Bluetooth, WiFi, near field communication (NFC) etc.), a cellular network, the Internet or a combination thereof. It is understood that the type of network is not limited to the above specific examples. In some embodiments, the network interface 106 can include any number of network interface controllers (NICs), radio frequency modules, transceivers, modems, routers, gateways, adapters, cellular network chips, etc., in any combination.
[0018] The peripheral interface 108 can be configured to connect the host 100 to one or more peripheral devices to achieve information input and output. For example, the peripheral devices can include input devices such as a keyboard, a mouse, a touch pad, a touch screen, a microphone, and various sensors, and output devices such as a display, a speaker, a vibrator, and an indicator light.
[0019] The bus 110 may be configured to transmit information between various components of the host 100 (e.g., the processor 102, the memory 104, the network interface 106, and the peripheral interface 108), such as an internal bus (e.g., a processor-memory bus), an external bus (USB port, PCI-E bus), etc.
[0020] It should be noted that, although the above host architecture only shows the processor 102, the memory 104, the network interface 106, the peripheral interface 108 and the bus 110, in the specific implementation process, the host architecture may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above host architecture may also only include the components necessary for implementing the embodiment of the present application, and does not necessarily include all the components shown in the figure.
[0021] Figure 2 FIG. 2 is a flowchart of a method 200 for writing a battery management system communication protocol according to an embodiment of the present application. The method 200 may be Figure 1 The host 100 shown is executed, and the host 100 can be configured in a photovoltaic device. The method 200 can include the following steps.
[0022] In step 201, a target protocol identifier of a communication protocol to be written into a target photovoltaic device is obtained.
[0023] The target photovoltaic equipment refers to the equipment used by photovoltaic manufacturing enterprises in the production of raw materials, battery components, parts and components, and which basically maintains its original physical form and function during repeated use. For example, the target photovoltaic equipment may be a photovoltaic all-in-one machine, which is a system that integrates solar panels, energy storage batteries, charge and discharge controllers, inverters and other equipment (such as charging piles, electric vehicles, etc.).
[0024] In order to ensure the healthy operation of energy storage batteries, target photovoltaic devices are usually connected to a battery management system (also known as a BMS). The battery management system is mainly used to monitor and manage the status of the battery to ensure the safety and efficient operation of the battery, such as monitoring the battery's voltage, temperature, current and other parameters. In addition, the battery management system will also exchange information with other devices through the communication interface, such as information exchange with the target photovoltaic device, and the information exchange between the battery management system and other devices is based on the battery management system communication protocol (also known as the BMS communication protocol, hereinafter referred to as the communication protocol).
[0025] Each battery management system manufacturer has developed a corresponding communication protocol for information exchange between the battery management system and other devices, that is, through any communication protocol corresponding to the battery management system, other devices can communicate with the battery management system to obtain the system parameters of the battery management system, such as battery parameters. Different battery management system manufacturers may use different types of communication protocols, including but not limited to CAN communication protocol, RS-485 communication protocol, MODBUS communication protocol, LonWorks communication protocol, etc., and because different manufacturers have different definitions of protocol content, some manufacturers use the same type of communication protocol, such as MODBUS communication protocol, which will make these communication protocols contain different protocol data types and protocol data values, such as register addresses, undervoltage standards, overvoltage standards, etc. Therefore, whenever the target photovoltaic device is connected to a battery management system, it is necessary to rewrite the communication protocol corresponding to the battery management system to ensure that it can smoothly exchange information with the battery management system. However, since the common practice in the current industry is to manually edit the underlying communication code of the photovoltaic device to realize the writing of the communication protocol, this will undoubtedly bring a large workload, low writing efficiency, and a large amount of manual code editing will also be prone to errors, resulting in incorrect writing of the communication protocol.
[0026] Each communication protocol corresponds to a unique protocol identifier, such as a protocol number, etc. The protocol identifier is used as identification information to distinguish each communication protocol, that is, the corresponding communication protocol can be directly determined according to any protocol identifier. The communication protocol to be written refers to the communication protocol currently to be written to the target photovoltaic device, and the target protocol identifier refers to the protocol identifier corresponding to the communication protocol to be written.
[0027] In some embodiments, the target photovoltaic device performs a table lookup operation in the protocol identification table to determine the target protocol identification corresponding to the communication protocol to be written.
[0028] In step 202, a target mapping relationship is determined from candidate mapping relationships according to a target protocol identifier, and a target storage address in a target memory of a target protocol data value included in the communication protocol to be written is determined according to the target mapping relationship.
[0029] Among them, candidate protocol data types contained in various candidate communication protocols and candidate protocol data values corresponding to each candidate protocol data type are pre-stored in the target memory of the target photovoltaic device. The candidate protocol data type refers to the type of protocol data contained in the candidate communication protocol, such as overvoltage standard, undervoltage standard, reading battery voltage value, etc. The candidate protocol data value refers to the specific assignment corresponding to the candidate protocol data type. For example, when the candidate protocol data type is "overvoltage standard", the candidate protocol data value indicates the specific standard content corresponding to the "overvoltage standard"; correspondingly, if the candidate protocol data type is "undervoltage standard", the candidate protocol data value indicates the specific standard content corresponding to the "undervoltage standard".
[0030] Furthermore, in the target memory of the target photovoltaic device, exclusive memory areas are allocated for various candidate communication protocols, so that the candidate protocol data types contained in different candidate communication protocols, and the candidate protocol data values corresponding to each candidate protocol data type, are stored in their respective corresponding exclusive memory areas to facilitate search and sorting. In addition, a candidate mapping relationship is also maintained in the target photovoltaic device, wherein the candidate mapping relationship is determined according to the candidate protocol data types contained in the candidate communication protocol, and the candidate storage addresses of the candidate protocol data values corresponding to the candidate protocol data types in the target memory, that is, each candidate mapping relationship records the candidate storage addresses of the various candidate protocol data types contained in the various candidate communication protocols, and the candidate protocol data values corresponding to the various candidate protocol data types in the target memory. For example, the candidate mapping relationship may include "protocol data type 1-candidate storage address 1", indicating that the candidate storage address of the candidate protocol data value corresponding to "protocol data type 1" in the target memory is "candidate storage address 1".
[0031] Furthermore, corresponding candidate mapping relationships are established in advance for various candidate communication protocols in the target photovoltaic device, and an association relationship between each candidate mapping relationship and a candidate protocol identifier is established in advance based on the candidate communication protocol corresponding to each candidate mapping relationship. That is, based on the candidate protocol identifier of any candidate communication protocol, the candidate mapping relationship corresponding to the candidate communication protocol can be determined based on the candidate protocol identifier.
[0032] It can be understood that the target mapping relationship records various target protocol data types included in the communication protocol to be written, as well as target protocol data values corresponding to the various target protocol data types, and target storage addresses in the target memory.
[0033] The candidate mapping relationship may be established in one of the following ways, including but not limited to:
[0034] 1) The target photovoltaic device obtains a candidate communication instruction sent by a user using any candidate communication protocol, and uses an instruction parsing system to parse the candidate communication instruction to obtain a candidate protocol data value corresponding to at least one candidate protocol data type contained in the candidate communication protocol, and stores the candidate protocol data value in the target memory according to a pre-assigned candidate storage address, thereby establishing a candidate mapping relationship corresponding to the candidate communication protocol.
[0035] 2) The target photovoltaic equipment collects candidate communication instructions sent by various candidate communication protocols on the market, and uses an instruction parsing system to parse the various candidate communication instructions to obtain candidate protocol data values corresponding to at least one candidate protocol data type contained in the various candidate communication protocols, and stores the candidate protocol data values in the target memory according to the pre-assigned candidate storage address, thereby establishing candidate mapping relationships corresponding to the various candidate communication protocols.
[0036] The instruction parsing system can interpret and process the corresponding candidate communication instructions according to the function codes and data formats of different candidate communication instructions to parse and obtain the candidate protocol data types contained in the corresponding candidate communication protocol, and the candidate protocol data values corresponding to the candidate protocol data types. The instruction parsing system can be established based on a neural network model, wherein the neural network model can be obtained by model training based on sample communication instructions and label information corresponding to the sample communication instructions, and the label information can be obtained based on the sample protocol data types and sample protocol data values obtained by manually parsing the sample communication instructions.
[0037] In some embodiments, the target photovoltaic device matches the target protocol identifier of the communication protocol to be written with the pre-established association relationship between each candidate mapping relationship and the candidate protocol identifier, and determines the target mapping relationship associated with the target protocol identifier from the candidate mapping relationship based on the matching result, and extracts information based on the target mapping relationship to determine the target storage address in the target memory of the target protocol data value of the target protocol data type contained in the communication protocol to be written.
[0038] In step 203, the target protocol data value is extracted from the target memory according to the target storage address, and the communication protocol to be written is written according to the target protocol data value.
[0039] In some embodiments, the target photovoltaic device extracts data from the target memory according to the determined target storage address to extract the target protocol data value of the target protocol data type contained in the communication protocol to be written from the target memory, and then generates the target protocol code corresponding to the communication protocol to be written according to the target protocol data value and the protocol code template, and writes the communication protocol to be written into the target photovoltaic device according to the target protocol code.
[0040] The embodiment of the present application pre-builds and maintains a candidate mapping relationship in the target photovoltaic device. When the target photovoltaic device has a communication protocol writing requirement, it only needs to obtain the target protocol identifier of the communication protocol to be written, and can use the candidate mapping relationship to extract the target protocol data value contained in the communication protocol to be written in the target memory, and finally use the target protocol data value to write the communication protocol to be written. Therefore, when the target photovoltaic device needs to write a communication protocol, there is no need to manually edit the underlying communication code of the photovoltaic device, which reduces the workload and improves the writing efficiency. It can also avoid the problem of incorrect writing of the communication protocol due to easy errors in manual code editing, and improve the reliability and accuracy of communication protocol writing.
[0041] Figure 3 FIG. 3 is a flowchart of a method 300 for writing a battery management system communication protocol according to an embodiment of the present application. The method 300 may be Figure 1 The host 100 shown is executed, and the host 100 can be configured in a photovoltaic device. The method 300 can include the following steps.
[0042] In step 301, a candidate communication instruction sent by any candidate communication protocol is obtained, and the candidate communication instruction is parsed to determine at least one candidate byte data included in the candidate communication instruction.
[0043] The candidate communication instruction refers to a character string sent using the candidate communication protocol, that is, the instruction content of the candidate communication instruction consists of an N-base character string, and each character can be further converted into byte data.
[0044] Exemplarily, taking the MODBUS communication protocol as an example for explanation, the instruction content of the candidate communication instruction is composed of a hexadecimal string. Assume that the instruction content of a candidate communication instruction is "0103 75 30 00 64 5E 22", wherein "01" represents the number of communications, that is, the number of instructions sent to complete one communication; "03" represents the function code, that is, the function code in the MODBUS communication protocol, which defines the type of operation to be performed; "75 30" represents the register address, that is, the register address to be read or written; "00 64" represents the number of data, that is, the number of data related to the function code operation; "5E22" represents the check code, that is, the check code used to ensure the integrity of the communication data.
[0045] In some embodiments, the target photovoltaic device obtains a candidate communication instruction sent using any candidate communication protocol, and parses the string of the instruction content of the candidate communication instruction to convert it into at least one byte data as the candidate byte data. Continuing to explain using the MODBUS communication protocol as an example, if the target photovoltaic device obtains a candidate communication instruction sent using the MODBUS communication protocol, the hexadecimal string of the instruction content of the candidate communication instruction is parsed to convert it into at least one byte data as the candidate byte data.
[0046] In step 302, a candidate protocol data value corresponding to at least one candidate protocol data type included in the candidate communication protocol is determined based on at least one candidate byte data, and candidate storage addresses allocated to various candidate protocol data types in the target memory are determined.
[0047] In some embodiments, an instruction parsing system is used to interpret each candidate byte data to determine the relationship between the candidate byte data and the candidate protocol data values corresponding to various candidate protocol data types. For example, the instruction parsing system is used to determine: the 1st byte data corresponds to the candidate protocol data value corresponding to candidate protocol data type 1; the 2nd to 10th byte data correspond to the candidate protocol data value corresponding to candidate protocol data type 2; the 11th to 20th byte data correspond to the candidate protocol data value corresponding to candidate protocol data type 2, and so on.
[0048] Based on the relationship between the determined candidate byte data and the candidate protocol data values corresponding to various candidate protocol data types, the candidate byte data is extracted to determine the candidate protocol data value corresponding to at least one candidate protocol data type contained in the candidate communication protocol, and based on the candidate protocol identifier of the candidate communication protocol, the candidate storage address pre-allocated for the candidate communication protocol in the target memory is further determined.
[0049] In step 303, the candidate protocol data values corresponding to the various candidate protocol data types are stored in the target memory according to the candidate storage addresses respectively corresponding to the various candidate protocol data types, and a candidate mapping relationship corresponding to the candidate communication protocol is established based on the various candidate protocol data types and the candidate storage addresses respectively corresponding to the various candidate protocol data types.
[0050] In some embodiments, the target photovoltaic device further determines the candidate storage addresses corresponding to various candidate protocol data types in the candidate storage addresses allocated for the candidate communication protocol, and stores the candidate protocol data values corresponding to the various candidate protocol data types in the target memory according to the candidate storage addresses corresponding to the various candidate protocol data types.
[0051] Exemplarily, assuming that the candidate storage address assigned to the candidate communication protocol is "address 1 to address 100", and assuming that the candidate storage address assigned to the "candidate protocol data type 1" is "address 1 to address 10", the candidate protocol data value corresponding to the "candidate protocol data type 1" is stored in "address 1 to address 10" of the target memory; and assuming that the candidate storage address assigned to the "candidate protocol data type 2" is "address 11 to address 30", the candidate protocol data value corresponding to the "candidate protocol data type 2" is stored in "address 11 to address 30" of the target memory.
[0052] After the candidate protocol data values are stored in the target memory, a candidate mapping relationship corresponding to the candidate communication protocol is established according to various candidate protocol data types and candidate storage addresses corresponding to various candidate protocol data types.
[0053] Exemplarily, assuming that the candidate protocol data value corresponding to "candidate protocol data type 1" is stored in "address 1 to address 10" of the target memory, a mapping relationship of "candidate protocol data type 1-address 1 to address 10" is established. Assuming that the candidate protocol data value corresponding to "candidate protocol data type 2" is stored in "address 11 to address 30" of the target memory, a mapping relationship of "candidate protocol data type 2-address 11 to address 30" is established, and so on, until a mapping relationship between all candidate protocol data types and candidate storage addresses in the candidate communication protocol is established, and the candidate mapping relationship corresponding to the candidate communication protocol is summarized.
[0054] By acquiring a candidate communication instruction sent by any candidate communication protocol and parsing the candidate communication instruction, at least one candidate byte data included in the candidate communication instruction is determined; according to the at least one candidate byte data, a candidate protocol data value corresponding to at least one candidate protocol data type included in the candidate communication protocol is determined, and candidate storage addresses allocated to various candidate protocol data types in the target memory are determined; according to the candidate storage addresses respectively corresponding to the various candidate protocol data types, the candidate protocol data values corresponding to the various candidate protocol data types are stored in the target memory, and according to the various candidate protocol data types and the candidate storage addresses respectively corresponding to the various candidate protocol data types, a candidate mapping relationship corresponding to the candidate communication protocol is established. Due to the introduction of the instruction interpretation system, the beneficial effects are:
[0055] 1. High flexibility: The instruction interpretation system can dynamically parse and execute communication protocols from different manufacturers, without the need to write specific adaptation code for each new protocol. This flexibility greatly shortens the cycle of new product or system integration, allowing rapid response to market changes and technology updates.
[0056] 2. Improve software robustness and stability: Since the instruction interpretation system can uniformly handle various communication protocols, it reduces software errors and anomalies caused by differences in communication protocols, thereby improving the stability and reliability of the entire system. At the same time, this architecture also facilitates troubleshooting and repair.
[0057] 3. Reduce R&D costs: Under traditional methods, whenever a new communication protocol needs to be connected, a lot of code writing and testing work is required. However, with the instruction interpretation system, these tasks can be greatly reduced, reducing manpower and time costs, and making more efficient use of R&D resources.
[0058] 4. Enhanced scalability: With the advancement of technology and the expansion of the market, more new communication protocols may appear in the future. The instruction interpretation system can be easily expanded to support these new protocols without large-scale transformation of the original system.
[0059] 5. Create value: This innovative solution not only brings technological breakthroughs and competitive advantages to the enterprise itself, but also provides users with a more convenient, efficient and reliable service experience. At the same time, it also sets a benchmark for the entire industry and promotes the standardization and normalization of related technologies.
[0060] In step 304, the target protocol identifier of the communication protocol to be written in the target photovoltaic device and the first candidate protocol identifiers respectively associated with each candidate mapping relationship are obtained, and each first candidate protocol identifier is matched with the target protocol identifier respectively.
[0061] Among them, after each candidate mapping relationship is established, the candidate protocol identifier of the candidate communication protocol corresponding to each candidate mapping relationship is determined as the first candidate protocol identifier, and an association relationship between each candidate mapping relationship and the first candidate protocol identifier is established. For example, assuming that the candidate protocol identifier of the candidate communication protocol 1 corresponding to the candidate mapping relationship 1 is "123456", then "123456" is used as the first candidate protocol identifier, and an association relationship between "candidate mapping relationship 1" and the first candidate protocol identifier "123456" is established.
[0062] In some embodiments, the target photovoltaic device obtains the target protocol identifier and the first candidate protocol identifiers respectively associated with each candidate mapping relationship, and matches each first candidate protocol identifier with the target protocol identifier respectively to determine the first candidate protocol identifier that matches the target protocol identifier.
[0063] In step 305, if the first candidate protocol identifier associated with any candidate mapping relationship matches the target protocol identifier, the candidate mapping relationship is used as the target mapping relationship, and the target storage address of the target protocol data value contained in the communication protocol to be written in the target memory is determined according to the target mapping relationship.
[0064] Exemplarily, assuming that the target protocol identifier is "11223344", and the first candidate protocol identifier associated with candidate mapping relationship 2 is "11223344", candidate mapping relationship 2 is used as the target mapping relationship. Assuming that the target mapping relationship includes "candidate protocol data type 1-address 1 to address 10" and "candidate protocol data type 2-address 11 to address 30", "address 1 to address 30" are used as the target storage address of the target protocol data value contained in the communication protocol to be written in the target memory.
[0065] By obtaining the first candidate protocol identifier associated with each candidate mapping relationship, and matching each first candidate protocol identifier with the target protocol identifier; if the first candidate protocol identifier associated with any candidate mapping relationship matches the target protocol identifier, then the candidate mapping relationship is used as the target mapping relationship. On the one hand, the correctness of the target mapping relationship determination is guaranteed through protocol identifier matching, avoiding the problem of incorrect determination of the target mapping relationship, which further leads to incorrect extraction of the target protocol data value. On the other hand, it can also speed up the efficiency of determining the target mapping relationship, thereby further speeding up the efficiency of extracting the target protocol data.
[0066] In step 306, the target protocol data value is extracted from the target memory according to the target storage address, and the communication protocol to be written is written according to the target protocol data value.
[0067] Optionally, after matching each first candidate protocol identifier with the target protocol identifier respectively, the method further includes:
[0068] A. If the first candidate protocol identifier associated with each candidate mapping relationship does not match the target protocol identifier, an unknown protocol prompt message is sent to the target user end.
[0069] Among them, if the first candidate protocol identifier associated with each candidate mapping relationship does not match the target protocol identifier, it means that the candidate mapping relationship corresponding to the communication protocol to be written has not been established in the target photovoltaic device, and the communication protocol to be written is an unknown communication protocol. At this time, the target user (such as technical engineers, etc.) needs to manually parse the communication protocol to be written, determine the target protocol data type contained in the communication protocol to be written, and the target protocol data value corresponding to the target protocol data type, and organize it into a protocol configuration file.
[0070] In some embodiments, when the target photovoltaic device determines that the first candidate protocol identifier associated with each candidate mapping relationship does not match the target protocol identifier, it generates an unknown protocol prompt message and sends it to the target user terminal corresponding to the target user.
[0071] B. Obtain the protocol configuration file sent by the target user terminal, and determine the target protocol data value corresponding to the target protocol data type included in the communication protocol to be written according to the protocol configuration file as the newly added protocol data value.
[0072] The protocol configuration file includes the target protocol data value corresponding to the target protocol data type included in the communication protocol to be written, and may also include information such as the manufacturer number, manufacturer name, and target storage address.
[0073] In some embodiments, the target photovoltaic device obtains the protocol configuration file sent by the target user terminal, parses the protocol configuration file, obtains the target protocol data value corresponding to the target protocol data type included in the communication protocol to be written, and then uses it as the newly added protocol data value. The type of the protocol configuration file includes an XML file.
[0074] C. Determine the target storage address allocated for the target protocol data type in the target memory as the newly added storage address, and store the newly added protocol data value in the target memory according to the newly added storage address.
[0075] In some embodiments, the target photovoltaic device automatically allocates a storage address for the communication protocol to be written as the target storage address, or obtains the target storage address based on the parsing result of the protocol configuration file, further uses the target storage address as the newly added storage address, and stores the newly added protocol data value in the target memory according to the newly added storage address.
[0076] Furthermore, according to the target protocol data type to which the newly added protocol data value belongs and the newly added storage address, a candidate mapping relationship corresponding to the communication protocol to be written is constructed.
[0077] If the first candidate protocol identifier associated with each candidate mapping relationship does not match the target protocol identifier, an unknown protocol prompt message is sent to the target user end; the protocol configuration file sent by the target user end is obtained, and the target protocol data value corresponding to the target protocol data type included in the communication protocol to be written is determined according to the protocol configuration file as the newly added protocol data value; the target storage address allocated to the target protocol data type in the target memory is determined as the newly added storage address, and the newly added protocol data value is stored in the target memory according to the newly added storage address, so that when the target photovoltaic device has not yet parsed and stored the target protocol data value included in the communication protocol to be written, the relevant user is promptly notified to manually parse the target protocol data value and store it in the target memory accordingly, thereby ensuring that the extraction of the target protocol data value can be executed smoothly, and further ensuring that the target photovoltaic device can write the communication protocol to be written in time.
[0078] Optionally, the communication protocol to be written is a telecommunications communication protocol or a MODBUS communication protocol.
[0079] Since the protocol frame formats of the telecommunication communication protocol and the MODBUS communication protocol are fixed, only the protocol data values are different, the communication protocol to be written is set to the telecommunication communication protocol or the MODBUS communication protocol. On the one hand, it can ensure the effective execution of the writing method of the battery management system communication protocol, and on the other hand, it expands the types of communication protocols adapted by the method.
[0080] Figure 4 FIG. 4 is a flowchart of a method 400 for writing a battery management system communication protocol according to an embodiment of the present application. The method 400 may be Figure 1 The host 100 shown is executed, and the host 100 may be configured in a photovoltaic device. The method 400 may include the following steps.
[0081] In step 401, a target protocol identifier of a communication protocol to be written into a target photovoltaic device is obtained.
[0082] In step 402, the second candidate protocol identifiers respectively associated with each candidate data value table are obtained.
[0083] The candidate data value table records the candidate protocol data types included in the associated candidate communication protocol, and the candidate protocol data values corresponding to the candidate protocol data types.
[0084] Exemplarily, assuming that the candidate communication protocol associated with candidate data value table 1 is "candidate communication protocol 1", it means that candidate data value table 1 records the candidate protocol data types included in "candidate communication protocol 1" and the candidate protocol data values corresponding to the candidate protocol data types.
[0085] In step 403, a target data value table is determined from the candidate data value table according to the matching results between each second candidate protocol identifier and the target protocol identifier.
[0086] In some embodiments, the target photovoltaic device matches the second candidate protocol identifier associated with each candidate data value table with the target protocol identifier of the communication protocol to be written, and uses any candidate data value table to which the second candidate protocol identifier that successfully matches the target protocol identifier belongs as the target data value table.
[0087] Exemplarily, assuming that the target protocol identifier is "123456", if the second candidate protocol identifier associated with "candidate data value table 5" is also "123456", the candidate data value table 5 is used as the target data value table.
[0088] In step 404, at least one target protocol data type included in the communication protocol to be written is determined based on at least one candidate protocol data type recorded in the target data value table, and target protocol data values corresponding to various target protocol data types are determined based on the candidate protocol data values corresponding to various candidate protocol data types recorded in the target data value table.
[0089] In some embodiments, the target photovoltaic device parses the data recorded in the target data value table, uses at least one candidate protocol data type recorded in the target data value table as at least one target protocol data type included in the communication protocol to be written, and uses the candidate protocol data values corresponding to the various candidate protocol data types recorded in the target data value table as the target protocol data values corresponding to the various target protocol data types.
[0090] In step 405, the communication protocol to be written is written according to the target protocol data value.
[0091] The method comprises the following steps: obtaining a target protocol identifier of a communication protocol to be written in a target photovoltaic device; obtaining a second candidate protocol identifier respectively associated with each candidate data value table; wherein the candidate data value table records the candidate protocol data type contained in the associated candidate communication protocol, and the candidate protocol data value corresponding to the candidate protocol data type; determining the target data value table from the candidate data value table according to the matching results of each second candidate protocol identifier and the target protocol identifier; determining at least one target protocol data type contained in the communication protocol to be written according to at least one candidate protocol data type recorded in the target data value table, and determining the target protocol data values respectively corresponding to various target protocol data types according to the candidate protocol data values respectively corresponding to various candidate protocol data types recorded in the target data value table; writing the communication protocol to be written according to the target protocol data value, since the candidate protocol data type and the candidate protocol data value are pre-recorded in the candidate data value table, the target protocol data value can be directly determined by looking up the table using the candidate data value table, without the need to extract data from the target memory, thereby accelerating the efficiency of determining the target protocol data value and further improving the efficiency of writing the communication protocol to be written in the target photovoltaic device.
[0092] Optionally, writing the communication protocol to be written according to the target protocol data value further includes:
[0093] In step 4051, a protocol code template corresponding to the communication protocol to be written is determined according to the target protocol identifier of the communication protocol to be written.
[0094] Among them, the protocol code template refers to a code template pre-written for various communication protocols. It can be understood that the protocol code template contains common basic code content and also includes custom code content to be filled in, and the custom code content is the protocol data value of each protocol data type contained in various communication protocols.
[0095] In some embodiments, the target photovoltaic device matches the target protocol identifier of the communication protocol to be written with the candidate protocol identifiers corresponding to each candidate protocol code template, and determines the protocol code template corresponding to the communication protocol to be written according to the matching result.
[0096] In step 4052, according to the target protocol data type to which the target protocol data value belongs, the target code position corresponding to the target protocol data value in the protocol code template is determined, and the target protocol data value is written into the protocol code template according to the target code position to generate the target protocol code.
[0097] Among them, for different candidate protocol code templates, according to the code positions of different protocol data types to be filled in the custom code content in the candidate protocol code template, a preset mapping relationship between the candidate protocol data types and the candidate code positions is pre-established, that is, according to the preset mapping relationship, the code position of any protocol data type in the candidate protocol code template can be directly determined.
[0098] In some embodiments, the target photovoltaic device determines the target protocol data type to which the target protocol data value belongs, and matches the target protocol data type with a preset mapping relationship to determine the code position corresponding to the target protocol data type in the protocol code template, as the target code position corresponding to the target protocol data value in the protocol code template, and writes the target protocol data value into the protocol code template according to the target code position to generate a target protocol code.
[0099] For example, assuming that the target protocol data type to which any target protocol data value belongs is "protocol data type 1", and the candidate code position associated with "protocol data type 1" in the preset mapping relationship is "code position x", that is, the target protocol data value corresponding to "protocol data type 1" should be filled in the "code position x" of the protocol code template, then "code position x" will be used as the target code position corresponding to the target protocol data value in the protocol code template.
[0100] Optionally, determining a target code position corresponding to the target protocol data value in the protocol code template according to the target protocol data type to which the target protocol data value belongs further includes:
[0101] Obtain a preset mapping relationship between candidate protocol data types and candidate code positions in the protocol code template; match the target protocol data type with various candidate protocol data types in the preset mapping relationship, and use the candidate protocol data type that matches the target protocol data type as the auxiliary protocol data type; determine the candidate code position associated with the auxiliary protocol data type according to the preset mapping relationship as the target code position corresponding to the target protocol data value in the protocol code template.
[0102] Exemplarily, assuming that the target protocol data type is "overvoltage standard", the candidate protocol data type "overvoltage standard" in the preset mapping relationship is used as the auxiliary protocol data type. Assuming that the candidate code position associated with the candidate protocol data type "overvoltage standard" in the preset mapping relationship is "X segment Y row Z1~Z5 character positions", "X segment Y row Z1~Z5 character positions" are used as the target protocol data value corresponding to the target protocol data type "overvoltage standard", and the corresponding target code position in the protocol code template.
[0103] By obtaining the preset mapping relationship between the candidate protocol data type and the candidate code position in the protocol code template; matching the target protocol data type with various candidate protocol data types in the preset mapping relationship, and using the candidate protocol data type that matches the target protocol data type as the auxiliary protocol data type; determining the candidate code position associated with the auxiliary protocol data type according to the preset mapping relationship as the target code position corresponding to the target protocol data value in the protocol code template, on the one hand, the efficiency of determining the target code position is guaranteed, and on the other hand, the accuracy of determining the target code position can be guaranteed, thereby avoiding the problem of incorrect writing of the target protocol data value in the protocol code template.
[0104] In step 4053, the communication protocol to be written is written into the target photovoltaic device according to the target protocol code.
[0105] In some embodiments, the target protocol code is automatically written into the underlying communication code of the target photovoltaic device, so as to write the communication protocol to be written into the target photovoltaic device.
[0106] The protocol code template corresponding to the communication protocol to be written is determined according to the target protocol identifier of the communication protocol to be written; the target code position corresponding to the target protocol data value in the protocol code template is determined according to the target protocol data type to which the target protocol data value belongs, and the target protocol data value is written into the protocol code template according to the target code position to generate the target protocol code; the communication protocol to be written is written into the target photovoltaic device according to the target protocol code, so that the target protocol code is automatically generated by using the protocol code template, without the need for manual repeated code editing, thereby reducing the workload and improving the writing efficiency, and also avoiding the problem of incorrect writing of the communication protocol due to the easy error of manual code editing, thereby improving the reliability and accuracy of the communication protocol writing.
[0107] The present application also provides an electronic device. The electronic device may be Figure 1 The electronic device may include a memory for storing a set of instructions; and at least one processor configured to execute the set of instructions so that the electronic device executes methods 200 to 400.
[0108] The embodiment of the present application further provides a non-transitory computer-readable storage medium. The non-transitory computer-readable storage medium stores a set of computer instructions, and the set of instructions is used to make the computer perform methods 200 to 400 when executed.
[0109] Some embodiments of the present application are described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0110] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application (including the claims) is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the present application as described above, which are not provided in detail for the sake of simplicity.
[0111] Although the present application has been described in conjunction with specific embodiments of the present application, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.
[0112] This application is intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this application should be included in the scope of protection of this application.
Claims
1. A method for writing a battery management system communication protocol, comprising: Obtain the target protocol identifier of the communication protocol to be written in the target photovoltaic device; Determine a target mapping relationship from candidate mapping relationships according to the target protocol identifier, and determine a target storage address of the target protocol data value contained in the communication protocol to be written in the target memory according to the target mapping relationship; wherein the candidate mapping relationship is determined according to the candidate protocol data type contained in the candidate communication protocol, and the candidate storage address of the candidate protocol data value corresponding to the candidate protocol data type in the target memory; The target protocol data value is extracted from the target memory according to the target storage address, and the communication protocol to be written is written according to the target protocol data value.
2. The method of claim 1, wherein: Before obtaining the target protocol identifier of the communication protocol to be written in the target photovoltaic device, the method further includes: Acquire a candidate communication instruction sent by any of the candidate communication protocols, and parse the candidate communication instruction to determine at least one candidate byte data included in the candidate communication instruction; Determine, according to the at least one candidate byte data, a candidate protocol data value corresponding to at least one candidate protocol data type included in the candidate communication protocol, and determine candidate storage addresses allocated to various candidate protocol data types in the target memory; According to the candidate storage addresses respectively corresponding to the various candidate protocol data types, the candidate protocol data values corresponding to the various candidate protocol data types are stored in the target memory, and based on the various candidate protocol data types and the candidate storage addresses respectively corresponding to the various candidate protocol data types, the candidate mapping relationship corresponding to the candidate communication protocol is established.
3. The method of claim 1, wherein: Determining a target mapping relationship from candidate mapping relationships according to the target protocol identifier further includes: Obtaining first candidate protocol identifiers respectively associated with each of the candidate mapping relationships, and matching each of the first candidate protocol identifiers with the target protocol identifier respectively; If the first candidate protocol identifier associated with any of the candidate mapping relationships matches the target protocol identifier, the candidate mapping relationship is used as the target mapping relationship.
4. The method of claim 1, wherein: After each of the first candidate protocol identifiers is matched with the target protocol identifier respectively, the method further includes: If the first candidate protocol identifier associated with each of the candidate mapping relationships does not match the target protocol identifier, sending a protocol unknown prompt message to the target user terminal; Acquire the protocol configuration file sent by the target user terminal, and determine the target protocol data value corresponding to the target protocol data type included in the communication protocol to be written according to the protocol configuration file as the newly added protocol data value; A target storage address allocated for the target protocol data type in the target memory is determined as a newly added storage address, and the newly added protocol data value is stored in the target memory according to the newly added storage address.
5. The method of claim 1, further comprising: Obtain the target protocol identifier of the communication protocol to be written in the target photovoltaic device; Obtaining second candidate protocol identifiers respectively associated with each candidate data value table; wherein the candidate data value table records the candidate protocol data type included in the associated candidate communication protocol, and the candidate protocol data value corresponding to the candidate protocol data type; Determine a target data value table from the candidate data value table according to the matching results of each of the second candidate protocol identifiers and the target protocol identifier; Determine at least one target protocol data type included in the communication protocol to be written according to at least one candidate protocol data type recorded in the target data value table, and determine target protocol data values corresponding to various target protocol data types according to candidate protocol data values corresponding to various candidate protocol data types recorded in the target data value table; The communication protocol to be written is written according to the target protocol data value.
6. The method according to claim 1 or 5, wherein: Writing the communication protocol to be written according to the target protocol data value further comprises: Determining a protocol code template corresponding to the communication protocol to be written according to a target protocol identifier of the communication protocol to be written; Determine the target code position corresponding to the target protocol data value in the protocol code template according to the target protocol data type to which the target protocol data value belongs, and write the target protocol data value into the protocol code template according to the target code position to generate a target protocol code; The communication protocol to be written is written into the target photovoltaic device according to the target protocol code.
7. The method of claim 6, wherein: Determining a target code position corresponding to the target protocol data value in the protocol code template according to a target protocol data type to which the target protocol data value belongs further includes: Obtaining a preset mapping relationship between candidate protocol data types and candidate code positions in the protocol code template; Matching the target protocol data type with various candidate protocol data types in the preset mapping relationship, and using the candidate protocol data type that matches the target protocol data type as the auxiliary protocol data type; The candidate code position associated with the auxiliary protocol data type is determined according to the preset mapping relationship as the target code position corresponding to the target protocol data value in the protocol code template.
8. The method of claim 1, wherein: The communication protocol to be written is a telecommunication communication protocol or a MODBUS communication protocol.
9. An electronic device comprising a memory for storing a set of instructions; and At least one processor is configured to execute the set of instructions so that the electronic device performs the method according to any one of claims 1 to 8. 10 . A non-transitory computer-readable storage medium storing a set of instructions for a computer, the set of instructions being used to cause the computer to perform the method according to claim 1 when executed.
