A dual-layer protocol combined electricity meter upgrading method, device, equipment and medium
The meter upgrade method using a two-layer protocol combination, utilizing 21C and DLMS protocols, achieves resource optimization during the meter upgrade process, solves the problem of excessive resource consumption during meter upgrade, and improves system stability and compatibility.
Patent Information
- Application Number
- CN202611209618.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-11
- Publication Date
- 2026-11-06
- Estimated Expiration
- 2046-08-11
AI Technical Summary
Existing meter upgrade solutions consume too many resources, leading to limitations in MCU selection and high costs.
The meter upgrade method adopts a two-layer protocol combination, using the 21C protocol as the surface layer communication interaction channel and the DLMS protocol as the underlying service carrying channel. The instruction conversion is realized through the protocol adaptation layer, which reduces the development complexity and maintenance cost of the host computer and improves the compatibility and efficiency of the meter upgrade.
This technology enables the upgrading of electricity meters without modifying the existing host computer and electricity meter equipment, reducing resource consumption and improving system stability and scalability.
Smart Images

Figure CN122718131B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, and in particular to a method, apparatus, device, and medium for upgrading electricity meters using a two-layer protocol combination. Background Technology
[0002] With the increasing demands for cost control in the global electricity market, cost reduction and efficiency improvement have become core competitive strategies for electricity meter manufacturers. Currently, remote firmware upgrades for overseas electricity meters mainly adopt a firmware upgrade process based on the DLMS / COSEM protocol stack. Although this process is functionally complete, it relies on the complete DLMS.a library in actual use, resulting in a large Flash footprint (approximately 21KB or more), making it unsuitable for resource-constrained MCU platforms. Therefore, existing electricity meter upgrade solutions suffer from excessive resource consumption, leading to limitations in MCU selection and higher costs. Summary of the Invention
[0003] This invention provides a method, apparatus, device, and medium for upgrading electricity meters using a dual-layer protocol combination, in order to solve the problems of excessive resource consumption, limited MCU selection, and high cost in the existing electricity meter upgrade process.
[0004] In a first aspect, this application provides a method for upgrading an electricity meter using a two-layer protocol combination, applicable to electricity meters, comprising the steps of: responding to a communication connection request of a first communication protocol sent by a host computer, returning a corresponding negotiation waiting frame to the host computer; the communication connection request is used to request the electricity meter to establish a communication connection with the host computer and switch the electricity meter from an idle state to a negotiation waiting state; the negotiation waiting frame is used to indicate that the electricity meter enters the negotiation waiting state; responding to a programming mode selection instruction of the first communication protocol sent by the host computer, returning a corresponding programming authentication waiting frame to the host computer; the programming mode selection instruction is used to switch the electricity meter from the negotiation waiting state to the programming authentication waiting state, and the programming authentication waiting frame is used to indicate that the electricity meter enters the programming authentication waiting state; responding to the first communication protocol sent by the host computer... The protocol's programming access key is used by the meter to verify the host computer's upgrade access permission and switch the meter from the programming authentication waiting state to the programming connection state. The programming connection response frame is used to indicate that the meter has entered the programming connection state. The meter receives a first upgrade instruction sent sequentially by the host computer, and each time the first upgrade instruction is received, it is converted into a second upgrade instruction through a protocol adaptation layer. The first upgrade instruction is encapsulated in a first communication protocol format, and the second upgrade instruction is encapsulated in a second communication protocol format. In response to the second upgrade instruction, the meter upgrade operation is executed by calling the upgrade architecture interface corresponding to the second communication protocol, obtaining the corresponding upgrade execution result, and returning the upgrade execution result to the host computer.
[0005] Secondly, this application provides a method for upgrading an electricity meter using a two-layer protocol combination, applicable to a host computer, comprising the steps of: sending a communication connection request of a first communication protocol to the electricity meter; the communication connection request is used to request the electricity meter to establish a communication connection with the host computer and switch the electricity meter from an idle state to a negotiation waiting state; if a negotiation waiting frame is received from the electricity meter, a programming mode selection instruction of the first communication protocol is sent to the electricity meter; the negotiation waiting frame is used to instruct the electricity meter to enter the negotiation waiting state, and the programming mode selection instruction is used to switch the electricity meter from the negotiation waiting state to a programming authentication waiting state; if a programming authentication waiting frame is received from the electricity meter, a programming access key of the first communication protocol is sent to the electricity meter; the programming authentication waiting frame is used to instruct the electricity meter to enter the programming... In the authentication waiting state, the programming access key is used by the meter to verify the upgrade access permission of the host computer and switch the meter from the programming authentication waiting state to the programming connection state. If a programming connection response frame is received from the meter, a first upgrade instruction is sent to the meter sequentially. The programming connection response frame is used to indicate that the meter enters the programming connection state. The first upgrade instruction is encapsulated in a first communication protocol format. When the meter receives the first upgrade instruction, it converts the first upgrade instruction into a second upgrade instruction through a protocol adaptation layer. The second upgrade instruction is encapsulated in a second communication protocol format. The meter calls the upgrade architecture interface corresponding to the second communication protocol to perform the meter upgrade operation and obtain the corresponding upgrade execution result. The meter receives the upgrade execution result returned by the meter.
[0006] Thirdly, this application provides a meter upgrade device with a dual-layer protocol combination, applicable to electricity meters, comprising: a negotiation response module, configured to respond to a communication connection request of a first communication protocol sent by a host computer, and return a corresponding negotiation waiting frame to the host computer; the communication connection request is used to request the electricity meter to establish a communication connection with the host computer and switch the electricity meter from an idle state to a negotiation waiting state; the negotiation waiting frame is used to indicate that the electricity meter enters the negotiation waiting state; an authentication response module, configured to respond to a programming mode selection instruction of the first communication protocol sent by the host computer, and return a corresponding programming authentication waiting frame to the host computer; the programming mode selection instruction is used to switch the electricity meter from the negotiation waiting state to the programming authentication waiting state, and the programming authentication waiting frame is used to indicate that the electricity meter enters the programming authentication waiting state; and a connection response module, configured to respond to the communication connection request ... communication connection request is used to request the communication connection request to establish a communication connection between the host computer and The first communication protocol's programming access key is used to return a corresponding programming connection response frame to the host computer. The programming access key is used by the meter to verify the host computer's upgrade access permission and switch the meter from the programming authentication waiting state to the programming connection state. The programming connection response frame is used to indicate that the meter has entered the programming connection state. The instruction conversion module receives first upgrade instructions sequentially sent by the host computer and, upon receiving the first upgrade instruction, converts it into a second upgrade instruction through a protocol adaptation layer. The first upgrade instruction is encapsulated using a first communication protocol format, and the second upgrade instruction is encapsulated using a second communication protocol format. The upgrade execution module, in response to the second upgrade instruction, calls the upgrade architecture interface corresponding to the second communication protocol to perform the meter upgrade operation, obtains the corresponding upgrade execution result, and returns the upgrade execution result to the host computer.
[0007] Fourthly, this application provides a meter upgrade device with a dual-layer protocol combination, suitable for a host computer, comprising: a request sending module, configured to send a communication connection request of a first communication protocol to the meter; the communication connection request is used to request the meter to establish a communication connection with the host computer and switch the meter from an idle state to a negotiation waiting state; a mode sending module, configured to send a programming mode selection instruction of the first communication protocol to the meter if a negotiation waiting frame returned by the meter is received; the negotiation waiting frame is used to instruct the meter to enter the negotiation waiting state, and the programming mode selection instruction is used to switch the meter from the negotiation waiting state to a programming authentication waiting state; a key sending module, configured to send a programming access key of the first communication protocol to the meter if a programming authentication waiting frame returned by the meter is received; the programming authentication waiting frame is used to instruct the meter to enter the programming authentication waiting state. The programming authentication waiting state; the programming access key is used by the meter to verify the upgrade access permission of the host computer and switch the meter from the programming authentication waiting state to the programming connection state; the instruction sending module is used to send a first upgrade instruction to the meter sequentially if a programming connection response frame is received from the meter; the programming connection response frame is used to indicate that the meter enters the programming connection state; the first upgrade instruction is encapsulated in a first communication protocol format, and the meter converts the first upgrade instruction into a second upgrade instruction through a protocol adaptation layer each time it receives the first upgrade instruction. The second upgrade instruction is encapsulated in a second communication protocol format, and the meter calls the upgrade architecture interface corresponding to the second communication protocol to perform the meter upgrade operation and obtain the corresponding upgrade execution result; the result receiving module is used to receive the upgrade execution result returned by the meter.
[0008] Fifthly, this application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer device is configured as an electricity meter, the processor executes the computer program to implement the electricity meter upgrade method provided in the first aspect; or, when the computer device is configured as a host computer, the processor executes the computer program to implement the electricity meter upgrade method provided in the second aspect.
[0009] Sixthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described two-layer protocol combination meter upgrade method.
[0010] In the above-mentioned technical solution of the meter upgrade method, apparatus, computer equipment, and storage medium using a two-layer protocol combination, the meter upgrade method, when applied to an electricity meter, includes the following steps: responding to a communication connection request of a first communication protocol sent by a host computer, returning a corresponding negotiation waiting frame to the host computer; the communication connection request is used to request the electricity meter to establish a communication connection with the host computer and switch the electricity meter from an idle state to a negotiation waiting state; the negotiation waiting frame is used to instruct the electricity meter to enter the negotiation waiting state; responding to a programming mode selection instruction of the first communication protocol sent by the host computer, returning a corresponding programming authentication waiting frame to the host computer, the programming mode selection instruction is used to switch the electricity meter from the negotiation waiting state to the programming authentication waiting state, and the programming authentication waiting frame is used to instruct the electricity meter to enter the programming authentication waiting state; responding to the host computer... The meter sends a programming access key for the first communication protocol and returns a corresponding programming connection response frame to the host computer. The programming access key is used by the meter to verify the host computer's upgrade access permissions and switch the meter from a programming authentication waiting state to a programming connection state. The programming connection response frame indicates that the meter has entered the programming connection state. The meter receives first upgrade instructions sequentially sent by the host computer, and upon receiving each first upgrade instruction, converts it into a second upgrade instruction through a protocol adaptation layer. The first upgrade instruction is encapsulated using the first communication protocol format, and the second upgrade instruction is encapsulated using the second communication protocol format. In response to the second upgrade instruction, the meter upgrade operation is executed by calling the upgrade architecture interface corresponding to the second communication protocol, obtaining the corresponding upgrade execution result, and returning the upgrade execution result to the host computer. This method achieves instruction conversion between different communication protocols through a protocol adaptation layer, allowing the host computer to complete meter upgrades without supporting the second communication protocol. This reduces the development complexity and maintenance cost of the host computer, improves the compatibility and efficiency of meter upgrades, reduces resource consumption due to single-protocol limitations, and enhances system stability and scalability. Attached Figure Description
[0011] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is an interactive principle diagram of the electricity meter and the host computer in an embodiment of the electricity meter upgrade method with a two-layer protocol combination according to the present invention; Figure 2 This is a flowchart of the meter side in a meter upgrade method with a two-layer protocol combination according to an embodiment of the present invention; Figure 3 This is a detailed flowchart of step S4 on the meter side in a meter upgrade method with a dual-layer protocol combination according to an embodiment of the present invention. Figure 4 This is another specific flowchart of step S4 on the meter side in the meter upgrade method of the dual-layer protocol combination in one embodiment of the present invention; Figure 5 This is another specific flowchart of step S4 on the meter side in the meter upgrade method of the dual-layer protocol combination in one embodiment of the present invention; Figure 6 This is another specific flowchart of step S4 on the meter side in the meter upgrade method of the dual-layer protocol combination in one embodiment of the present invention; Figure 7 This is a flowchart of loading new firmware on the meter side in a meter upgrade method with a two-layer protocol combination according to an embodiment of the present invention; Figure 8 This is a flowchart of the host computer side in a meter upgrade method with a two-layer protocol combination according to an embodiment of the present invention; Figure 9 This is a detailed flowchart of step S9 on the host computer side in a meter upgrade method with a dual-layer protocol combination according to an embodiment of the present invention. Figure 10 This is a schematic diagram of a meter upgrade device with a dual-layer protocol combination according to an embodiment of the present invention; Figure 11 This is another schematic diagram of a meter upgrade device with a dual-layer protocol combination in one embodiment of the present invention; Figure 12 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0013] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0014] It should be pointed out first that in actual product development, the Flash storage space of the meter MCU is an extremely valuable resource. Taking the Fudan Micro FM33M04xER chip used in the following embodiments of this application as an example, its built-in Flash capacity is limited. Before code trimming, the read-only code area (RO) of the application program (APP) occupies 226,777 bytes, and the read-write data area (RW) occupies 27,421 bytes. After preliminary trimming, the APP RO is reduced to 205,619 bytes, and the RW is reduced to 25,264 bytes.
[0015] Further analysis revealed that the DLMS.a protocol library (a static link library) occupies a significant amount of storage space. Reducing Flash usage and cost reduction can be achieved by trimming the DLMS.a library. However, the DLMS.a library carries the meter's remote firmware upgrade functionality, including core modules such as upgrade file transfer (Image Transfer), upgrade script execution (Script Table), and upgrade scheduling (Single Action Schedule). Maintaining the meter's remote firmware upgrade capability after trimming the DLMS.a library becomes a pressing technical challenge.
[0016] In one embodiment, such as Figure 1 and Figure 2 As shown, a method for upgrading electricity meters using a two-layer protocol combination is provided, applicable to electricity meters, including the following steps: Step S1: In response to the communication connection request of the first communication protocol sent by the host computer, return the corresponding negotiation waiting frame to the host computer.
[0017] It should be noted that the first communication protocol is the IEC 21C protocol (IEC 62056-21), a dedicated serial communication protocol for on-site meter maintenance. It supports communication handshake, mode negotiation, permission verification, and interactive programming operations. The communication connection request is a handshake message sent by the host computer based on the IEC 21C protocol. Its core function is to initiate device communication docking, requesting the meter to establish a communication connection with the host computer and switching the meter from idle state to negotiation waiting state. The negotiation waiting frame is a meter-specific response message used to synchronize its communication status with the host computer, specifically indicating that the meter enters the negotiation waiting state. The idle state is the meter's default normal state, with no communication connection, no upgrade operations, and only basic metering functions are performed. The negotiation waiting state is a temporary negotiation state after the meter establishes a connection handshake, used to wait for the host computer to confirm the communication working mode.
[0018] like Figure 1 As shown, the electricity meter normally remains in an idle state, continuously listening for 21C protocol communication messages from the host computer. When the host computer initiates an upgrade operation, it sends a 21C protocol format communication connection request to the electricity meter, actively requesting to establish a point-to-point communication connection with the meter. After receiving this communication connection request, the electricity meter ends its idle standby state, parses the handshake message for validity, completes basic communication parameter matching, and simultaneously switches its operating state from idle to negotiation waiting state. After the state switch is completed, the electricity meter actively generates and returns the corresponding negotiation waiting frame to the host computer, synchronously informing the host computer of the current device status.
[0019] Among them, the standardized 21C protocol handshake and status response mechanism can accurately establish a dedicated communication channel between the host computer and the electricity meter, avoiding invalid communication interference; at the same time, through explicit status switching and frame response synchronization, the host computer can accurately grasp the working status of the electricity meter, providing a compliant communication foundation for subsequent programming mode negotiation and permission authentication operations, and ensuring the orderly nature of upgrade interaction from the source.
[0020] In this embodiment, a secure, closed-loop remote firmware upgrade is achieved using a two-layer protocol architecture. The first communication protocol, employing the 21C protocol, serves as the surface-level communication channel, responsible for command interaction, data transmission, and status responses between the host computer and the meter. The second communication protocol, using the DLMS protocol, acts as the underlying service carrier channel, responsible for carrying upgrade data and control commands converted by the protocol adaptation layer, enabling standardized firmware upgrade service processing. Therefore, before executing all upgrade steps, the meter must complete its basic infrastructure deployment in advance to provide pre-support for subsequent cross-protocol upgrades.
[0021] Specifically, before step S1, the process also includes: the electricity meter is pre-deployed with an upgrade service architecture built on the second communication protocol (DLMS protocol). This upgrade service architecture integrates multiple standardized upgrade architecture interfaces, including image initialization interface, data block writing interface, image verification interface, script execution interface, etc., which can respectively handle the electricity meter upgrade operations at different stages such as upgrade initialization, upgrade file block transmission, data integrity verification, and firmware activation.
[0022] It should be noted that the meter side retains a complete DLMS upgrade business architecture, including image file transfer objects, script table objects, and single-action scheduling objects, corresponding to different upgrade architecture interfaces. This ensures that the corresponding interface can be directly called to execute the meter upgrade operation when a corresponding instruction is received. The image file transfer object is responsible for the initialization, block writing, transfer verification, and status reading of the upgrade file, supporting the processing of both firmware upgrade files and parameter configuration files. In this application, the upgrade file specifically refers to the firmware upgrade file, i.e., the binary image data used to update the underlying operating logic of the meter. The script table object manages the definition and execution of upgrade scripts, configuring upgrade script actions through a read-only script table and executing the image activation operation during the activation phase. The single-action scheduling object manages the execution time of the upgrade scripts, triggering the execution of the upgrade scripts by periodically comparing the current time with the scheduled execution time, ensuring that the upgrade action is accurately triggered within the scheduled time window. Based on this, through the coordinated operation of object-oriented encapsulation and a timed scheduling mechanism, the upgrade process is automated and precisely controlled, ensuring the safety and reliability of the meter upgrade operation.
[0023] Furthermore, during actual deployment, the electricity meter can respond to upgrade requests pre-issued by the host computer, complete resource preloading and state initialization of the upgrade business architecture, and ensure that the upgrade business architecture is in a callable and ready state. This preliminary step provides core business capability support for subsequent 21C protocol instruction translation and DLMS protocol upgrade execution, and is a fundamental prerequisite for realizing the dual-layer protocol combination upgrade.
[0024] Step S2: In response to the programming mode selection instruction of the first communication protocol sent by the host computer, return the corresponding programming authentication waiting frame to the host computer.
[0025] It should be noted that the programming mode selection command is a high-level command specific to the 21C protocol, used to switch the meter from the regular data reading mode to the programmable operation and maintenance mode, granting high-privilege operation permissions such as firmware upgrades and parameter modification. In other words, it switches the meter from the negotiation waiting state to the programming authentication waiting state. The programming authentication waiting frame is a status synchronization response message used to confirm the completion of the mode switch and the waiting permission verification with the host computer, and instructs the meter to enter the programming authentication waiting state. The programming authentication waiting state is a dedicated waiting state after the meter mode switch, used only for receiving the host computer's permission key.
[0026] like Figure 1 As shown, after receiving the negotiation wait frame returned by the meter, the host computer confirms the completion of the communication handshake, selects the programming mode, and then sends a programming mode selection command in 21C protocol format to the meter. Upon receiving this command, the meter parses its validity, closes the regular data query channel, opens the programming maintenance channel, and switches its state from negotiation wait to programming authentication wait. After the state switch is complete, the meter generates a programming authentication wait frame and sends it back to the host computer, informing the host computer that it has entered the authorization verification ready state.
[0027] Among these features, the dedicated programming mode switching isolates the regular metering business of the electricity meter from the upgrade and maintenance business, preventing the upgrade operation from interfering with the normal metering function of the electricity meter; at the same time, after entering the authentication waiting state, the subsequent operation permissions are locked to prevent unauthorized device misoperation, which greatly improves the security and business independence of firmware upgrades.
[0028] Step S3: In response to the programming access key of the first communication protocol sent by the host computer, return the corresponding programming connection response frame to the host computer.
[0029] It should be noted that the programming access key is the highest-level key in the multi-level permission verification key system under the 21C protocol framework. It is the sole authorization credential for advanced programming operations on the meter, used by the meter to verify the host computer's upgrade access permissions and switch the meter from the programming authentication waiting state to the programming connection state. The programming connection response frame is a confirmation message indicating successful permission verification and serves as the legitimate credential for all subsequent upgrade command interactions, instructing the meter to enter the programming connection state. The programming connection state represents the meter's highest-level, ready state, allowing the execution of all firmware upgrade operations, including firmware writing, parameter configuration, and activation / rebooting—core maintenance actions.
[0030] like Figure 1 As shown, after receiving the programming authentication waiting frame, the host computer confirms that the meter is ready and then sends a programming access key in 21C protocol format to the meter. Upon receiving the programming access key, the meter compares it with the locally stored permission key to complete the host computer's upgrade access permission verification. If the key verification is valid, the meter switches its status from the programming authentication waiting state to the programming connection state, and simultaneously generates a programming connection response frame and sends it back to the host computer, confirming that the high-level upgrade channel has been officially established.
[0031] It should be noted that multi-level access control keys generally include four levels: P1, P2, P3, and P4. Level P4 is the highest level key, dedicated to core maintenance scenarios such as firmware upgrades and parameter configuration. Levels P1 to P3 correspond to basic data reading, routine parameter querying, and general business operations, respectively, forming a tiered access control system from low to high. This layered design satisfies the real-time communication efficiency requirements of on-site maintenance while also ensuring the standardization and stability of the underlying business logic, achieving decoupling between the communication layer and the business layer. Simultaneously, it ensures that only authorized terminals holding the P4 key can perform subsequent upgrade operations, preventing unauthorized access risks at the source.
[0032] Among them, the multi-level key authentication mechanism realizes the verification of the legitimacy of the upgrade subject, effectively blocking malicious upgrade requests from illegal devices and unauthorized terminals; at the same time, the locking of the programming connection status and the synchronization of the response frame ensure that all subsequent upgrade file initialization, data transmission, firmware activation and other operations are executed in a secure and compliant authorized environment, thus building a solid upgrade security defense from the permission level.
[0033] Step S4: Receive the first upgrade command sent sequentially by the host computer, and convert the first upgrade command into a second upgrade command through the protocol adaptation layer each time the first upgrade command is received.
[0034] It should be noted that the first upgrade command is encapsulated using the first communication protocol format. This first upgrade command is a 21C protocol format upgrade control and data command issued by the host computer, adapted for surface-level communication interaction. The second upgrade command is encapsulated using the second communication protocol format; that is, the second upgrade command is a DLMS protocol format command generated by the protocol adaptation layer, which can be recognized and invoked by the underlying upgrade service architecture. The protocol adaptation layer is the core middleware of the two-layer protocol architecture, possessing core capabilities for command parsing, address matching, protocol format conversion, and data translation. It is a key module for bridging 21C communication and DLMS upgrade services.
[0035] In this embodiment, this step is a loop iterative execution process, such as... Figures 3 to 6 As shown, after the meter enters the programming connection state, it continuously receives various first upgrade commands issued by the host computer in sequence according to the upgrade schedule. Upon receiving each first upgrade command in 21C protocol format, the meter immediately performs message parsing, identifier address matching, and protocol format translation through the protocol adaptation layer, uniformly converting it into a second upgrade command recognizable by the DLMS protocol. This achieves seamless conversion from surface-level communication commands to underlying business execution commands. The entire process executes commands one by one and provides feedback stage by stage. After completing one round of protocol conversion, the meter waits for the host computer to issue the next stage upgrade command, iterating until the entire upgrade process is completed.
[0036] In this embodiment, the protocol adaptation layer is responsible for establishing a bidirectional mapping relationship between 21C protocol messages and DLMS upgrade objects. The protocol adaptation layer includes a command mapping module, a data conversion module, and a state synchronization module, which are responsible for command semantic mapping, data format translation, and state consistency maintenance, respectively, and together constitute the core logical closed loop of protocol conversion. The command mapping module is responsible for mapping 21C protocol command types (ProgWr / ProgBlkWr / ProgRd / Execute, etc.) to corresponding DLMS upgrade operations. The mapping rules are based on the OBIS addresses in the 21C messages. For example, command type ProgWr and OBIS 0.0.44.0.1.255 correspond to a transmission initialization operation; command type ProgBlkWr and OBIS 0.0.44.3.0.255 correspond to a block data transmission operation; command types ProgRd / Execute and OBIS 0.0.44.3.0.255 correspond to a transmission verification operation; command types ProgRd / Execute and OBIS 0.0.44.4.0.255 correspond to a firmware activation operation; and command type ProgRd and OBIS 0.0.44.6.0.255 correspond to a status query operation. The data conversion module is responsible for the mutual conversion between the ASCII / hexadecimal data format of the 21C protocol and the binary data format required by the DLMS upgrade object. For example, the DLMS ImageType (U32 type) is encoded in little-endian 4-byte format in the 21C data block; the firmware filename (ASCII string) is transmitted in standard string format. The state synchronization module is used to maintain the state machine during the upgrade process (initializing / transmitting / verifying / activating / completed / failed), ensuring that the upgrade execution results corresponding to the 21C commands can be correctly fed back to the host computer. On this basis, the state synchronization module reverse maps the DLMS execution results into 21C protocol response messages, ensuring that the host computer can accurately perceive the current upgrade progress and execution status. This bidirectional transparent mapping mechanism not only shields the complexity brought about by the differences in underlying protocols, but also builds a solid communication bridge at the logical level, ensuring that every command interaction accurately reaches the core business.
[0037] Among them, the protocol adaptation layer achieves seamless adaptation of the two protocols without modifying the 21C standard interaction logic of the host computer, nor does it require reconstructing the mature DLMS upgrade business architecture of the electricity meter, and is compatible with existing equipment and operation and maintenance system; the step-by-step instruction iterative conversion mode ensures orderly connection of each upgrade stage, avoids instruction confusion and data disorder, and improves the stability and compatibility of the upgrade process.
[0038] like Figure 3 As shown, the first upgrade instruction includes a programming write instruction, and the second upgrade instruction includes an initialization instruction. The corresponding step S4 includes: Step S41: Receive the programming write instruction sent by the host computer. The programming write instruction carries the initialization interface identifier address and writes the transmission initialization data into the initialization interface identifier address.
[0039] It should be noted that the programming write command is a 21C protocol-specific parameter write command, using the ProgWr command type, used to send upgrade initialization configuration data. The initialization interface identifier address is a custom-defined OBIS address 0.0.44.0.1.255, used to uniquely identify the upgrade initialization service interface. The transmitted initialization data consists of firmware upgrade pre-configuration parameters, including firmware filename, version number, checksum, and file type, which are the core parameters for creating an upgrade session.
[0040] In this embodiment, the transmission initialization data is a custom binary structure, encapsulated within the data payload of the 21C protocol ProgWr instruction; the structure arranges various upgrade initialization input parameters according to a fixed byte offset, enabling the host computer to transmit configuration information such as image type, file size, and block specifications to the meter, providing complete input parameters for calling the DLMS image initialization interface.
[0041] The host computer pre-generates transmission initialization binary data according to a preset offset rule: sequentially filling in the control word, block size, image type length, image type string, total image length, and firmware file name string. For example: setting the control word to 0x0001 represents a brand new firmware upgrade; setting the block size to 0x0400, meaning each subsequent data block is a maximum of 1024 bytes; setting the image type identifier length to 0x07, followed by the string FIRMWARE representing a firmware image; filling in the image file size as 0x00085000, corresponding to a total firmware size of 544768 bytes; and filling in the firmware file name string as V1.2.3.bin. The host computer encapsulates the complete binary structure into a 21C protocol programming write instruction carrying the initialization interface identifier address and sends it to the meter. After receiving the message, the protocol adaptation layer can parse all fields byte by byte according to the fixed offset position. It reads the control word from offset 0, the block size from offset 2, the image type identifier length from offset 4, the image type identifier from offset 5, the image file size from offset 5+N, and the firmware file name from offset 9+N. It then extracts all upgrade configuration parameters in sequence, converts the parameters into the input parameters required by the DLMS protocol image initialization interface, and generates initialization instructions.
[0042] In this embodiment, a standardized binary structure carries the complete set of initialization parameters, enabling structured transmission of upgrade configuration information between the host computer and the meter. The block size, image type, and total file size are clearly defined, allowing the meter to pre-allocate a corresponding length of receive buffer based on the parsed block size and predict whether the remaining external Flash storage space is sufficient based on the image file size. This effectively avoids transmission interruption issues caused by parameter mismatch, buffer overflow, or insufficient space during subsequent block transmission stages, ensuring a stable and reliable cross-protocol upgrade initialization process.
[0043] Step S42: Parse the initialization interface identifier address in the programming write instruction through the protocol adaptation layer and convert it into an initialization instruction.
[0044] It should be noted that the initialization command is in DLMS protocol format. The initialization command is used by the meter to call the mirror initialization interface and complete the transmission and initialization of the upgrade file according to the transmission initialization data.
[0045] like Figure 3 As shown, during the upgrade initialization phase, the meter receives a 21C protocol programming write command sent by the host computer. This command payload carries the initialization interface identifier address 0.0.44.0.1.255. After the protocol adaptation layer identifies the command type ProgWr and the dedicated OBIS address 0.0.44.0.1.255, it determines that it is an upgrade initialization request, meaning the current upgrade phase is an upgrade initialization service. It then strips the 21C protocol encapsulation, extracts the payload, and translates it into an initialization command in DLMS format, completing the protocol conversion. Subsequently, it proceeds to step S5, where, based on the initialization command, the underlying DLMS service interface is called to perform the initialization operation, and complete transmission initialization data is written to the corresponding address space.
[0046] Specifically, by matching dedicated addresses and translating protocols, the upgrade initialization process is precisely triggered. Based on standardized transmission initialization data, a dedicated upgrade session is created, temporary storage resources are allocated, and transmission status parameters are initialized. This allows the meter to complete the pre-receive preparation for the upgrade file, providing a standardized operating environment for the stable transmission and accurate verification of subsequent upgrade file data blocks, and avoiding upgrade failures caused by abnormal parameters.
[0047] It should be noted that in actual execution, steps S4 and S5 are an iterative process. Upon receiving the first upgrade command each time, the corresponding upgrade stage's protocol conversion and response feedback are executed. That is, after the protocol adaptation layer converts the corresponding first upgrade command into a second upgrade command, it immediately responds to the second upgrade command by calling the upgrade architecture interface corresponding to the second communication protocol to execute the meter upgrade operation, obtains the upgrade execution result for the corresponding upgrade stage, and returns the upgrade execution result for the corresponding upgrade stage to the host computer. Then, the host computer sends the first upgrade command for the next upgrade stage to the meter. After receiving it, the meter continues to execute the protocol conversion and response feedback for the next upgrade stage until all upgrade stages are completed.
[0048] Further, after receiving the corresponding initialization command, the process proceeds to step S5. In response to the initialization command, the mirror initialization interface is called to complete the transmission initialization of the upgrade file, obtain the upgrade execution result for the corresponding stage, encapsulate the result into a response frame in the first communication protocol format, and return the response frame to the host computer. This response frame is used to report the transmission initialization status to the host computer, confirming that the meter is ready to receive subsequent upgrade file data blocks.
[0049] like Figure 4 As shown, after confirming successful transmission initialization, the meter enters the data reception stage of the upgrade file. At this time, the first upgrade instruction also includes a block write instruction, the second upgrade instruction also includes a block write instruction, and step S4 also includes: Step S43: Receive the block write instruction sent by the host computer. The block write instruction carries the block write interface identifier address and writes the data block of the upgrade file at the block write interface identifier address.
[0050] It should be noted that the chunked write command is a 21C protocol command for writing large-capacity data chunks, using the ProgBlkWr command type, adapted for scenarios involving the fragmented transmission of large-volume upgrade files. The chunked write interface identifier address is a dedicated OBIS addressing address used to match upgrade file chunked write services. A data block is the smallest transmission unit after the upgrade file is split, including the block sequence number, block size, and block data, ensuring the orderly splicing of fragmented data.
[0051] Step S44: Parse the chunk write interface identifier address in the chunk write instruction through the protocol adaptation layer and convert it into a chunk write instruction.
[0052] It should be noted that the block write command is a DLMS protocol format command, which is used by the electricity meter to call the data block write interface to write the received data blocks into the electricity meter's temporary storage area.
[0053] like Figure 4As shown, after the meter responds with a successful initialization reply, it enters the data reception phase of the upgrade file. The meter continuously receives 21C protocol block write instructions cyclically issued by the host computer. The instructions carry the block write interface identifier address 0.0.44.3.0.255, and write the data blocks of the upgrade file in the corresponding address space one by one. The protocol adaptation layer parses the ProgBlkWr instruction type and the block write interface identifier address 0.0.44.3.0.255, identifies the block transmission service scenario, completes 21C message parsing and data extraction, and converts it into a block write instruction in DLMS protocol format. Then, it can proceed to step S5, where the meter calls the corresponding data block write interface based on the block write instruction to write each data block in an orderly manner to the meter's external Flash temporary storage area, completing the block caching of the upgrade file. After all data blocks have been received, the host computer sends a transmission end instruction to the meter, triggering the subsequent integrity verification process.
[0054] The block transmission combined with protocol translation mode can solve the problem that large upgrade files cannot be transmitted in a single transmission. At the same time, the block sequence number and block size double verification ensure that the fragmented data is orderly, without omissions or errors. The data blocks of the upgrade file are cached by the temporary storage area to avoid device failure caused by directly overwriting the upgrade file, which greatly improves the fault tolerance and stability of large-capacity upgrade files.
[0055] Furthermore, the first upgrade instruction also includes a status read instruction, and the second upgrade instruction also includes a status query instruction. Before the host computer sends the transmission end instruction to the meter, the meter also needs to receive the 21C protocol status read instruction sent by the host computer. This status read instruction uses the ProgRd instruction type and carries the status read interface identifier address 0.0.44.6.0.255, used to read the data block reception status of the upgrade file. Then, the meter parses the ProgRd instruction type and the status read interface identifier address 0.0.44.6.0.255 through the protocol adaptation layer, identifies the status query business scenario, and generates a DLMS protocol format status query instruction. This status query instruction is used by the meter to call the status query interface in step S5 of the corresponding upgrade stage to obtain the reception completion status of the currently received data blocks, and encapsulates the status into a 21C protocol format status response message, which is then returned to the host computer. The host computer judges the transmission progress accordingly, and after confirming that all data blocks have been received correctly, sends a transmission end instruction, triggering the meter to execute the subsequent integrity verification process.
[0056] like Figure 5 As shown, after writing all data blocks, the meter enters the verification phase, at which point the meter needs to perform integrity verification on the upgrade file in the temporary storage area. The first upgrade instruction also includes an execution instruction, and the second upgrade instruction also includes a transmission verification instruction. Step S4 further includes: Step S45: Receive the execution instruction sent by the host computer. The execution instruction carries the transmission verification interface identifier address.
[0057] It should be noted that the execution command is a 21C protocol service trigger command, using the ProgRd / Execute command type, used to initiate the transmission verification process. The transmission verification interface identifier address is the dedicated OBIS address for the transmission verification service, 0.0.44.3.0.255, which is the same as the block write interface identifier address, but the semantics are different. The latter points to the data write buffer, while the former points to the verification service logic entry point, used to locate the transmission verification service entry point inside the meter.
[0058] Step S46: Parse the transmission verification interface identifier address in the execution instruction through the protocol adaptation layer and convert it into a transmission verification instruction.
[0059] It should be noted that the transmission verification command is a DLMS protocol format command, which is used by the electricity meter to call the mirror verification interface to perform integrity verification on the upgrade files in the temporary storage area.
[0060] like Figure 5 As shown, after all data blocks have been transmitted and written, the meter enters the verification phase. It receives an execution command for the 21C protocol from the host computer, which carries the transmission verification interface identifier address 0.0.44.3.0.255. The protocol adaptation layer parses the ProgRd command type and the transmission verification interface identifier address 0.0.44.3.0.255, identifies the verification service requirements, and converts the 21C format execution command into a DLMS protocol format transmission verification command. Then, in step S5, the meter calls the mirror verification interface based on this transmission verification command, triggering the meter's mirror verification interface to start the verification process, performing a global CRC integrity check on the complete upgrade file cached in the temporary storage area. If the verification passes, the meter returns a successful verification response to the host computer and then enters the firmware activation phase; if the verification fails, it returns an error code and waits for the host computer to initiate a retransmission or terminate the upgrade process. This status feedback mechanism constitutes a key decision point in the upgrade process. It ensures that only rigorously verified firmware can enter the activation stage and provides a clear basis for fault tolerance handling in abnormal scenarios. Thus, it achieves a seamless connection from data verification to system activation in the logical closed loop, laying a solid foundation for the secure loading and stable operation of subsequent firmware.
[0061] Among these measures, the integrity of the upgrade files is verified to ensure that the data is received completely before the verification is performed, thus avoiding invalid verification operations. At the same time, relying on the DLMS standardized image verification mechanism, abnormal situations such as firmware packet loss, incorrect packets, and tampering can be accurately identified. If the verification fails, the host computer can retransmit the data, thus ensuring the integrity and security of the upgraded firmware from the data level.
[0062] like Figure 6 As shown, after successful verification, the meter enters the firmware activation stage. At this time, the first upgrade instruction also includes an activation action instruction, the second upgrade instruction also includes a firmware activation instruction, and step S4 also includes: Step S47: Receive the activation action command sent by the host computer. The activation action command carries the firmware activation interface identifier address.
[0063] It should be noted that the activation action command is a 21C protocol upgrade completion command, used to trigger the formal firmware activation. The firmware activation interface identifier address is the dedicated OBIS address for the activation service, 0.0.44.4.0.255, used to accurately locate the firmware activation service entry point inside the meter.
[0064] Step S48: Parse the firmware activation interface identifier address in the activation action command through the protocol adaptation layer and convert it into a firmware activation command.
[0065] It should be noted that the firmware activation command is a DLMS protocol format command, which is used by the meter to call the script execution interface to write the upgrade file in the temporary storage area to the formal running area to activate the new firmware.
[0066] like Figure 6 As shown, after the firmware integrity verification passes, the meter enters the firmware activation stage. The meter receives the 21C protocol activation action command from the host computer, which carries the firmware activation interface identifier address. The protocol adaptation layer parses the ProgRd / Execute command type and the firmware activation interface identifier address 0.0.44.4.0.255, identifies the firmware activation service, and converts the 21C activation action command into a firmware activation command in DLMS protocol format. Then, it can proceed to step S5, where the meter calls the script execution interface based on the firmware activation command, executes the preset upgrade file, and migrates the verified complete upgrade file from the temporary storage area to the meter's formal program execution area, completing the new firmware activation configuration.
[0067] Firmware activation is triggered only after successful verification, preventing abnormal firmware from overwriting the official running program. Firmware migration and activation are completed through a standardized script execution mechanism, making the process standardized and reusable. At the same time, the temporary storage area and the official running area are separated, completely avoiding problems such as meter crashes and bricking caused by abnormalities during the upgrade, and ensuring the reliability of the upgrade.
[0068] Step S5: In response to the second upgrade command, call the upgrade architecture interface corresponding to the second communication protocol to perform the meter upgrade operation, obtain the corresponding upgrade execution result, and return the upgrade execution result to the host computer.
[0069] It should be noted that the upgrade architecture interface is a standardized functional interface for the DLMS upgrade business architecture, corresponding to the entire upgrade process including initialization, writing, verification, and activation. The upgrade execution result is the status feedback data for each stage of the upgrade operation, including information such as success, failure, and reason for exception, which is used by the host computer to control the status of the entire upgrade process.
[0070] like Figures 1-6 As shown, after each protocol adaptation and conversion to generate the second upgrade command, the meter immediately responds to the command content, precisely calling the corresponding dedicated interface in the DLMS protocol upgrade business architecture to execute the upgrade operation for the corresponding stage. This includes sequentially completing upgrade initialization, data block writing, data integrity verification, and new firmware activation. After each stage of operation is completed, the meter generates the corresponding upgrade execution result, encapsulates the result data into a 21C protocol format response frame, and transmits it back to the host computer in real time, achieving phased feedback and phased confirmation.
[0071] In this application, precise matching and calling of instructions and interfaces ensures accurate implementation of operations at each upgrade stage, without omissions or errors; and combined with a mechanism for feedback of execution results at each stage, the host computer can monitor the upgrade progress and status in real time, promptly detect and handle upgrade anomalies, achieve closed-loop management of the entire process, and significantly reduce the upgrade failure rate.
[0072] Furthermore, after the firmware is activated and confirmed to be successful, the communication link must be released and the device restarted to ensure that the new firmware is fully loaded and effective, so that the meter returns to normal metering operation and completes the final closed loop of the upgrade process.
[0073] Specifically, such as Figure 7 As shown, after returning the last upgrade execution result to the host computer, the process also includes: Step S51: Receive the communication disconnect command sent by the host computer.
[0074] It should be noted that the communication disconnection command is a 21C protocol link release command, which is used to instruct the meter to disconnect the communication connection with the host computer after the new firmware is activated.
[0075] Step S52: In response to the communication disconnection command, disconnect the communication connection with the host computer and trigger the meter to restart to load the new firmware.
[0076] It should be noted that the meter restart is an active reload operation after firmware activation, used to load the new firmware program and complete the final upgrade.
[0077] like Figure 7As shown, after the electricity meter returns the final upgrade execution result of successful firmware activation to the host computer, it receives a communication disconnect command for the 21C protocol from the host computer. In response to the communication disconnect command, the electricity meter actively disconnects the dedicated 21C communication link with the host computer, ending the upgrade session. Subsequently, after the communication disconnection is complete, the electricity meter automatically triggers a system restart. During the restart process, the new firmware program in the official running area is loaded, completing the final activation of the firmware upgrade.
[0078] In this application, actively releasing the communication link after the upgrade is completed can avoid long-term occupation of the communication channel and affect the routine operation and maintenance of the electricity meter; at the same time, by restarting and reloading the new firmware, the new firmware program is ensured to be fully effective, and the upgrade session is terminated, allowing the electricity meter to return to normal metering operation, thus realizing a complete closed loop of the upgrade process.
[0079] Furthermore, after the meter restarts, a firmware verification operation is performed. The meter actively reads the local firmware version information to verify whether the currently running firmware is consistent with the firmware version being upgraded. Simultaneously, it checks the startup and running status and basic functional parameters of the new firmware to determine if the firmware loads correctly, without any operational anomalies or program crashes. If the versions match and the firmware runs normally, the upgrade is considered fully effective. If the versions do not match or the new firmware has operational anomalies or functional failures, the meter automatically triggers the firmware rollback mechanism, reverting to the original stable firmware version before the upgrade, ensuring the meter can operate normally. After the restart verification and rollback operations are completed, the meter returns to normal metering operation.
[0080] In this application, the effectiveness of firmware upgrades can be accurately verified through version comparison after restart and dual verification of operational status, eliminating issues such as fraudulent upgrades and abnormal firmware loading. Simultaneously, an automatic rollback mechanism for anomalies is added to promptly restore the original firmware in case of a new firmware failure, completely resolving issues such as meter crashes and functional malfunctions caused by upgrade failures. This significantly improves upgrade fault tolerance and device operational stability, achieving a complete closed loop for the entire upgrade process.
[0081] In one embodiment, such as Figure 1 and Figure 8 As shown, a method for upgrading electricity meters using a two-layer protocol combination is provided, applicable to host computers, and includes the following steps: Step S6: Send a communication connection request for the first communication protocol to the electricity meter.
[0082] It should be noted that the communication connection request is a host computer 21C protocol handshake start command, which is the start signal of the upgrade interaction process. It is used to request the meter to establish a communication connection with the host computer and switch the meter from idle state to negotiation waiting state.
[0083] like Figure 1 and Figure 8As shown, the host computer, acting as the interaction initiator, actively generates a communication connection request message in 21C protocol format, sends the request to the meter to be upgraded, actively requests to establish a point-to-point communication connection, and triggers the meter to start the communication negotiation process from the idle state.
[0084] The upgrade process is initiated proactively by adopting a standardized handshake request, and communication links are established on demand. This avoids invalid communication occupying resources and enables flexible initiation of upgrade interactions.
[0085] Step S7: If a negotiation wait frame is received from the meter, a programming mode selection instruction for the first communication protocol is sent to the meter.
[0086] It should be noted that the negotiation wait frame is a communication readiness feedback message from the electricity meter, used to inform the host computer that the handshake is complete and instruct the electricity meter to enter the negotiation wait state. The programming mode selection instruction is a high-level mode switching instruction, used to switch the electricity meter from the negotiation wait state to the programming authentication wait state.
[0087] like Figure 1 and Figure 8 As shown, the host computer continuously listens to the meter's response messages. After successfully receiving the negotiation waiting frame returned by the meter, it confirms that the communication handshake is successful and the meter has entered the negotiation waiting state. Then, by selecting the programming mode, it generates and sends a programming mode selection command in 21C protocol format. After the programming mode selection command is issued, it triggers the meter to switch to the programming authentication waiting state.
[0088] Among them, the step-by-step execution of operations based on device status feedback can ensure the precise timing of command issuance, avoid operational failures caused by premature commands, and ensure the orderly progress of the upgrade process.
[0089] Step S8: If a programming authentication waiting frame is received from the meter, then send the programming access key of the first communication protocol to the meter.
[0090] It should be noted that the programming authentication wait frame is a feedback message indicating that the meter mode switch is complete, used to instruct the meter to enter the programming authentication wait state. The programming access key is the upgrade permission verification credential, the core key for entering the higher-level upgrade operation, used by the meter to verify the host computer's upgrade access permissions, and to switch the meter from the programming authentication wait state to the programming connection state.
[0091] like Figure 1 and Figure 8 As shown, after receiving the programming authentication waiting frame returned by the meter, the host computer confirms that the meter has entered the permission verification ready state, then retrieves the pre-stored valid programming access key, encapsulates it into a 21C protocol format message and sends it to the meter, enabling the meter to complete the host computer's permission validity verification.
[0092] By first confirming the device status and then issuing the permission key, and strictly following the prior permission verification logic, the system eliminates unauthorized upgrade operations from the operational process, ensuring the compliance and security of upgrade and maintenance.
[0093] Step S9: If a programming connection response frame is received from the meter, the first upgrade command is sent to the meter sequentially.
[0094] It should be noted that the programming connection response frame is the final confirmation message indicating that the meter's authorization verification has passed and the upgrade channel is ready, used to indicate that the meter has entered the programming connection state. The first upgrade instruction is encapsulated in the first communication protocol format, which is used by the meter to convert the first upgrade instruction into a second upgrade instruction through the protocol adaptation layer each time it receives the first upgrade instruction; the second upgrade instruction is encapsulated in the second communication protocol format, which is used by the meter to call the upgrade architecture interface corresponding to the second communication protocol to execute the meter upgrade operation and obtain the corresponding upgrade execution result.
[0095] As mentioned earlier, the first upgrade command includes four core command categories: programming write command, block write command, execution command, and activation action command, covering the entire upgrade process. Correspondingly, the host computer needs to send the programming write command, block write command, execution command, and activation action command in sequence to complete the firmware writing and activation. Subsequently, the meter completes the firmware writing and activation based on the converted second upgrade command and feeds back the upgrade execution results of each stage to the host computer. This process has been described in detail above and will not be repeated here.
[0096] like Figure 9 As shown, specifically, step S9 includes the following sub-steps: Step S91: Send a programming write command to the meter.
[0097] Step S92: Send a block write command to the electricity meter.
[0098] Step S93: Send an execution command to the electricity meter.
[0099] Step S94: Send an activation command to the meter.
[0100] It should be noted that steps S91-S94 correspond to the aforementioned steps S41-S48, forming a complete interaction process between the host computer and the electricity meter, ensuring the closed-loop and reliability of the upgrade process. Before the host computer sends the first upgrade command for the corresponding upgrade stage to the electricity meter each time, it must wait for the electricity meter to return the corresponding programming connection response frame or the upgrade execution result for the corresponding upgrade stage. Only after confirming that there are no errors will the host computer send the first upgrade command for the next upgrade stage, in order to ensure the accuracy of data transmission and the stability of the upgrade process.
[0101] Among them, by issuing standardized time-sequence commands and combining them with a phased confirmation mechanism, the system is fully adapted to the cross-protocol upgrade logic of electricity meters, ensuring that the entire upgrade process is orderly, controllable, and traceable, completely avoiding the problems of command disorder and data misalignment, and greatly improving the stability and success rate of remote upgrades.
[0102] Step S10: Receive the upgrade execution result returned by the electricity meter.
[0103] It should be noted that the upgrade execution result consists of status feedback data for each stage of the meter's upgrade operation, which is the core basis for the host computer to determine the upgrade progress and result. This status feedback data includes states such as idle state, transmission initialization complete, data block transmission in progress, transmission verification in progress, firmware activation in progress, upgrade successful, and upgrade failed.
[0104] In this embodiment, after each round of instructions is issued, the host computer continuously monitors and receives the upgrade execution results of each stage returned by the electricity meter, and records the upgrade progress, operation status, and abnormal information in real time. After receiving the final upgrade execution result of successful firmware activation returned by the electricity meter, the host computer confirms that the firmware writing and activation process is complete, and then sends a 21C protocol communication disconnection command to the electricity meter, instructing the electricity meter to release the communication link and restart the device to load the new firmware.
[0105] Among them, by monitoring the status and receiving the results throughout the entire process, the host computer can achieve full control over the remote upgrade, and can check for anomalies in real time, record upgrade logs, and actively release the link after the upgrade is completed to achieve reasonable use of resources and complete the entire upgrade interaction loop.
[0106] Furthermore, after receiving the final upgrade execution result returned by the meter, the process also includes sending a communication disconnect command to the meter. This command instructs the meter to disconnect the communication connection with the host computer using the first communication protocol after activating the new firmware, and triggers a meter restart to load the new firmware. The specific process has been detailed above and will not be repeated here.
[0107] In summary, this application discloses a method for upgrading an electricity meter using a two-layer protocol combination. When applied to an electricity meter, the method includes the following steps: responding to a communication connection request of a first communication protocol sent by a host computer, returning a corresponding negotiation waiting frame to the host computer; the communication connection request is used to request the electricity meter to establish a communication connection with the host computer and switch the electricity meter from an idle state to a negotiation waiting state; the negotiation waiting frame is used to indicate that the electricity meter enters the negotiation waiting state; responding to a programming mode selection instruction of the first communication protocol sent by the host computer, returning a corresponding programming authentication waiting frame to the host computer, the programming mode selection instruction is used to switch the electricity meter from the negotiation waiting state to the programming authentication waiting state, and the programming authentication waiting frame is used to indicate that the electricity meter enters the programming authentication waiting state; responding to a communication connection request of a ...; the programming connection request is used to request the electricity meter to establish a communication connection with the host computer and switch the electricity meter from an idle state to a programming authentication waiting state; the programming authentication waiting frame is used to indicate that the electricity meter enters the programming authentication waiting state; the programming connection request is used to request the electricity meter to establish a communication connection with the host computer and switch the electricity meter from an idle state to a programming authentication waiting state; the programming authentication waiting frame is used to indicate that the electricity meter enters the programming authentication waiting state; the programming connection request is used to request the electricity meter to establish a communication connection with the host computer and switch the electricity meter from an idle state to a programming authentication waiting state; the programming connection waiting frame is used to indicate that the electricity meter enters the programming authentication waiting state; the programming connection waiting frame is used to indicate that the electricity meter enters the programming authentication waiting state; the programming connection waiting frame is used to indicate that the electricity meter enters the The meter uses a programming access key of the communication protocol to return a corresponding programming connection response frame to the host computer. The programming access key is used by the meter to verify the host computer's upgrade access permissions and switch the meter from a programming authentication waiting state to a programming connection state. The programming connection response frame indicates that the meter has entered the programming connection state. The meter receives first upgrade instructions sequentially sent by the host computer, and upon receiving a first upgrade instruction, it converts the first upgrade instruction into a second upgrade instruction through a protocol adaptation layer. The first upgrade instruction is encapsulated using a first communication protocol format, and the second upgrade instruction is encapsulated using a second communication protocol format. In response to the second upgrade instruction, the meter performs an upgrade operation by calling the upgrade architecture interface corresponding to the second communication protocol, obtains the corresponding upgrade execution result, and returns the upgrade execution result to the host computer. When applied to a host computer, the method includes the following steps: sending a communication connection request for the first communication protocol to the electricity meter; if a negotiation waiting frame is received from the electricity meter, sending a programming mode selection instruction for the first communication protocol to the electricity meter; if a programming authentication waiting frame is received from the electricity meter, sending a programming access key for the first communication protocol to the electricity meter; if a programming connection response frame is received from the electricity meter, sending a first upgrade instruction to the electricity meter sequentially; and receiving the upgrade execution result returned by the electricity meter. This method, while preserving the stability of the original DLMS upgrade architecture, inserts a protocol adaptation layer between the DLMS upgrade architecture (upper layer) and the 21C protocol (lower layer), ensuring that changes to the communication protocol do not affect the integrity of the business logic. Furthermore, it dynamically maps the communication instructions of the 21C protocol to the DLMS standard upgrade operation, enabling the 21C protocol, which originally could only perform simple data read and write operations, to carry the complete firmware upgrade process. This achieves flexible switching of the underlying communication channel while ensuring zero-modification reuse of the upper-layer core business logic, achieving a balance between space saving and functional preservation. This layered decoupling design is not only suitable for the DLMS to 21C switchover scenario, but can also be extended to the replacement of other protocol stacks, demonstrating strong versatility and reusability. Furthermore, through a market-differentiated adaptation mechanism, the same upgrade architecture code can be adapted to the standard market, the AK market, and other customized markets.When adding a new market, only the parameter configuration of that market needs to be added to the protocol adaptation layer, without modifying the core upgrade logic, which greatly reduces the development and maintenance costs of multi-market products.
[0108] Taking the FM33M04xER chip as an example, the original solution (DLMS upgrade) occupied 226,777 bytes of APP RO. After adopting the solution of this invention, the APP RO was reduced to approximately 209,000 bytes (205,619 + approximately 3,500 adaptation layer codes), resulting in a net saving of approximately 17,700 bytes (approximately 17.3KB), a saving ratio of approximately 7.8%. The RW data area was reduced from 27,421 bytes to approximately 25,500 bytes, resulting in a net saving of approximately 1,900 bytes, which is of significant value for MCU platforms with limited Flash resources. Secondly, this solution achieves space optimization at the software level, without requiring the replacement of a larger capacity MCU chip. Furthermore, after adopting the solution of this invention, the hardware BOM cost remains completely unchanged, achieving the same cost reduction effect solely through software architecture optimization. Furthermore, the present invention fully retains all the functions of the DLMS upgrade architecture, including: upgrade file transfer initialization, block data transmission (supporting breakpoint resumption), CRC verification of transmitted data, firmware activation and automatic restart, automatic rollback upon upgrade failure, etc. Compared with the original DLMS solution, the upgrade success rate, transmission stability, and user experience are not reduced in any way. Meanwhile, the host computer upgrade tool only needs to add 21C protocol support to the communication layer (the standard 21C protocol stack is widely used), while the upper-layer upgrade business logic (transmission initialization / block transmission / verification / activation) remains unchanged, minimizing the workload of modifying both the host and host computers. At the same time, after switching the underlying communication from DLMS to 21C, the communication speed and stability are not reduced.
[0109] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0110] In one embodiment, a dual-layer protocol combination meter upgrade device is provided, applicable to electricity meters. This dual-layer protocol combination meter upgrade device corresponds one-to-one with the meter upgrade methods applicable to electricity meters described in the above embodiments. For example... Figure 10 As shown, the meter upgrade device with the dual-layer protocol combination includes a negotiation response module 101, an authentication response module 102, a connection response module 103, a command conversion module 104, and an upgrade execution module 105. Detailed descriptions of each functional module are as follows: The negotiation response module 101 is used to respond to the communication connection request of the first communication protocol sent by the host computer and return a corresponding negotiation waiting frame to the host computer; the communication connection request is used to request the electricity meter to establish a communication connection with the host computer and switch the electricity meter from the idle state to the negotiation waiting state; the negotiation waiting frame is used to indicate that the electricity meter enters the negotiation waiting state.
[0111] The authentication response module 102 is used to respond to the programming mode selection instruction of the first communication protocol sent by the host computer and return the corresponding programming authentication waiting frame to the host computer; the programming mode selection instruction is used for the meter to switch from the negotiation waiting state to the programming authentication waiting state; the programming authentication waiting frame is used to indicate that the meter enters the programming authentication waiting state.
[0112] The connection response module 103 is used to respond to the programming access key of the first communication protocol sent by the host computer and return a corresponding programming connection response frame to the host computer; the programming access key is used by the meter to verify the upgrade access permission of the host computer and switch the meter from the programming authentication waiting state to the programming connection state; the programming connection response frame is used to indicate that the meter enters the programming connection state.
[0113] The instruction conversion module 104 is used to receive the first upgrade instruction sent sequentially by the host computer, and convert the first upgrade instruction into a second upgrade instruction through the protocol adaptation layer each time the first upgrade instruction is received; the first upgrade instruction is encapsulated in the first communication protocol format, and the second upgrade instruction is encapsulated in the second communication protocol format.
[0114] The upgrade execution module 105 is used to respond to the second upgrade command, call the upgrade architecture interface corresponding to the second communication protocol to perform the meter upgrade operation, obtain the corresponding upgrade execution result, and return the upgrade execution result to the host computer.
[0115] In another embodiment, a dual-layer protocol combination meter upgrade device is provided, suitable for a host computer. This dual-layer protocol combination meter upgrade device corresponds one-to-one with the meter upgrade methods suitable for host computers described in the above embodiments. For example... Figure 11 As shown, the meter upgrade device with the dual-layer protocol combination includes a request sending module 106, a mode sending module 107, a key sending module 108, a command sending module 109, and a result receiving module 110. Detailed descriptions of each functional module are as follows: The request sending module 106 is used to send a communication connection request of the first communication protocol to the electricity meter; the communication connection request is used to request the electricity meter to establish a communication connection with the host computer and switch the electricity meter from the idle state to the negotiation waiting state.
[0116] The mode sending module 107 is used to send a programming mode selection instruction of the first communication protocol to the electricity meter if it receives a negotiation waiting frame returned by the electricity meter; the negotiation waiting frame is used to instruct the electricity meter to enter the negotiation waiting state; the programming mode selection instruction is used to switch the electricity meter from the negotiation waiting state to the programming authentication waiting state.
[0117] The key sending module 108 is used to send a programming access key of the first communication protocol to the electricity meter if it receives a programming authentication waiting frame returned by the electricity meter; the programming authentication waiting frame is used to instruct the electricity meter to enter the programming authentication waiting state; the programming access key is used by the electricity meter to verify the upgrade access permission of the host computer and switch the electricity meter from the programming authentication waiting state to the programming connection state.
[0118] The instruction sending module 109 is used to send a first upgrade instruction to the meter sequentially if a programming connection response frame is received from the meter. The programming connection response frame is used to indicate that the meter has entered the programming connection state. The first upgrade instruction is encapsulated in a first communication protocol format, which is used by the meter to convert the first upgrade instruction into a second upgrade instruction through a protocol adaptation layer each time it receives the first upgrade instruction. The second upgrade instruction is encapsulated in a second communication protocol format, which is used by the meter to call the upgrade architecture interface corresponding to the second communication protocol to perform the meter upgrade operation and obtain the corresponding upgrade execution result.
[0119] The result receiving module 110 is used to receive the upgrade execution result returned by the electricity meter.
[0120] Specific limitations regarding the dual-protocol combined meter upgrade device can be found in the limitations of the dual-protocol combined meter upgrade method described above, and will not be repeated here. Each module in the aforementioned dual-protocol combined meter upgrade device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0121] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 12 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a two-layer protocol combination method for upgrading electricity meters.
[0122] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer device is configured as an electricity meter, the processor executes the computer program to implement the electricity meter upgrade method with a two-layer protocol combination as described in the above embodiment, for example... Figure 2 S1-S5, as shown, will not be described again here to avoid repetition. Alternatively, when the processor executes the computer program, it implements the functions of each module / unit in this embodiment of the meter upgrade device suitable for electricity meters, for example... Figure 10 The functions of the negotiation response module 101, authentication response module 102, connection response module 103, instruction conversion module 104, and upgrade execution module 105 shown are not described again here to avoid repetition.
[0123] In another embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer device is configured as a host computer, the processor executes the computer program to implement the meter upgrade method applicable to a host computer described in the above embodiments, for example... Figure 8 S6-S10, as shown, will not be described again here to avoid repetition. Alternatively, when the processor executes the computer program, it implements the functions of each module / unit in this embodiment of the meter upgrade device suitable for a host computer, for example... Figure 11 The functions of the request sending module 106, pattern sending module 107, key sending module 108, instruction sending module 109, and result receiving module 110 shown are not described again here to avoid repetition.
[0124] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When executed by a processor, the computer program implements the meter upgrade method with a two-layer protocol combination described in the above embodiments, for example... Figure 2 As shown in S1-S5, or Figure 8 S6-S10, as shown, will not be described again here to avoid repetition. Alternatively, when the computer program is executed by the processor, it implements the functions of each module / unit in this embodiment of the meter upgrade device with the above-described two-layer protocol combination, for example... Figure 10 The functions of the negotiation response module 101, authentication response module 102, connection response module 103, instruction conversion module 104, and upgrade execution module 105 shown are as follows: Figure 11 The functions of the request sending module 106, pattern sending module 107, key sending module 108, instruction sending module 109, and result receiving module 110 shown are not described again here to avoid repetition. The computer-readable storage medium can be non-volatile or volatile.
[0125] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0126] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0127] It should be noted that any AI models, software tools, or components not belonging to this company appearing in the embodiments of this application are merely illustrative examples and do not represent actual use. All user personal information involved in the embodiments of this application has been authorized (with the knowledge and consent) by the relevant parties or has been fully authorized by all parties, and the executing entity may obtain it through various legal and compliant means. The collection, storage, use, processing, transmission, provision, and disclosure of the information, data, and signals involved all comply with relevant laws and regulations and do not violate public order and good morals.
[0128] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A method for upgrading electricity meters using a two-layer protocol combination, applicable to electricity meters, characterized in that, Including the following steps: In response to a communication connection request of the first communication protocol sent by the host computer, a corresponding negotiation waiting frame is returned to the host computer; the communication connection request is used to request the electricity meter to establish a communication connection with the host computer and to switch the electricity meter from an idle state to a negotiation waiting state; The negotiation waiting frame is used to instruct the meter to enter the negotiation waiting state; In response to the programming mode selection instruction of the first communication protocol sent by the host computer, a corresponding programming authentication waiting frame is returned to the host computer; the programming mode selection instruction is used to switch the meter from the negotiation waiting state to the programming authentication waiting state; the programming authentication waiting frame is used to instruct the meter to enter the programming authentication waiting state. In response to the programming access key of the first communication protocol sent by the host computer, the meter returns a corresponding programming connection response frame to the host computer; the programming access key is used by the meter to verify the upgrade access permission of the host computer and switch the meter from the programming authentication waiting state to the programming connection state; the programming connection response frame is used to indicate that the meter enters the programming connection state. The system receives a first upgrade instruction sent sequentially by the host computer, and converts the first upgrade instruction into a second upgrade instruction through a protocol adaptation layer each time it receives the first upgrade instruction; the first upgrade instruction is encapsulated using a first communication protocol format, and the second upgrade instruction is encapsulated using a second communication protocol format. In response to the second upgrade instruction, the upgrade architecture interface corresponding to the second communication protocol is called to perform the meter upgrade operation, obtain the corresponding upgrade execution result, and return the upgrade execution result to the host computer. The first upgrade instruction includes a programming write instruction, and the second upgrade instruction includes an initialization instruction. The step of receiving the first upgrade instruction sequentially sent by the host computer, and converting the first upgrade instruction into a second upgrade instruction through a protocol adaptation layer each time the first upgrade instruction is received, includes: The system receives a programming write instruction sent by the host computer. The programming write instruction carries an initialization interface identifier address, and writes transmission initialization data into the initialization interface identifier address. The protocol adaptation layer parses the initialization interface identifier address in the programming write instruction and converts it into the initialization instruction; the initialization instruction is used by the meter to call the mirror initialization interface to complete the transmission initialization of the upgrade file.
2. The meter upgrade method according to claim 1, characterized in that, The first upgrade instruction further includes a block write instruction, and the second upgrade instruction further includes a block write instruction. The step of receiving the first upgrade instruction sequentially sent by the host computer, and converting the first upgrade instruction into the second upgrade instruction through a protocol adaptation layer each time the first upgrade instruction is received, further includes: The system receives a block write instruction sent by the host computer. The block write instruction carries a block write interface identifier address, and writes the data block of the upgrade file at the block write interface identifier address. The protocol adaptation layer parses the block write interface identifier address in the block write instruction and converts it into the block write instruction; the block write instruction is used by the electricity meter to call the data block write interface and write the received data block into the temporary storage area of the electricity meter.
3. The meter upgrade method according to claim 2, characterized in that, The first upgrade instruction further includes an execution instruction, and the second upgrade instruction further includes a transmission verification instruction. The step of receiving the first upgrade instruction sequentially sent by the host computer, and converting the first upgrade instruction into a second upgrade instruction through a protocol adaptation layer each time the first upgrade instruction is received, further includes: Receive the execution instruction sent by the host computer, the execution instruction carrying the transmission verification interface identifier address; The protocol adaptation layer parses the transmission verification interface identifier address in the execution instruction and converts it into the transmission verification instruction; the transmission verification instruction is used by the meter to call the mirror verification interface to perform integrity verification on the upgrade file in the temporary storage area.
4. The meter upgrade method according to claim 3, characterized in that, The first upgrade instruction further includes an activation action instruction, and the second upgrade instruction further includes a firmware activation instruction. The step of receiving the first upgrade instruction sequentially sent by the host computer, and converting the first upgrade instruction into a second upgrade instruction through a protocol adaptation layer each time the first upgrade instruction is received, further includes: Receive the activation action command sent by the host computer, the activation action command carrying the firmware activation interface identifier address; The firmware activation interface identifier address in the activation action instruction is parsed by the protocol adaptation layer and converted into the firmware activation instruction. The firmware activation instruction is used by the meter to call the script execution interface to write the upgrade file in the temporary storage area into the formal running area to activate the new firmware.
5. The meter upgrade method according to claim 1, characterized in that, After returning the last upgrade execution result to the host computer, the process also includes: Receive a communication disconnection command sent by the host computer; the communication disconnection command is used to instruct the meter to disconnect the communication connection with the host computer after activating the new firmware; In response to the communication disconnect command, the communication connection with the host computer is disconnected, and the meter is triggered to restart to load the new firmware.
6. The meter upgrade method according to claim 1, characterized in that, Before returning a corresponding negotiation wait frame to the host computer in response to a communication connection request of the first communication protocol sent by the host computer, the method further includes: Deploy an upgrade service architecture based on the second communication protocol; the upgrade service architecture includes multiple upgrade architecture interfaces, which are used to handle meter upgrade operations at different stages.
7. A method for upgrading electricity meters using a dual-layer protocol combination, applicable to a host computer, characterized in that, Including the following steps: Send a communication connection request of the first communication protocol to the electricity meter; the communication connection request is used to request the electricity meter to establish a communication connection with the host computer and switch the electricity meter from an idle state to a negotiation waiting state; If a negotiation wait frame is received from the meter, a programming mode selection instruction for the first communication protocol is sent to the meter. The negotiation waiting frame is used to instruct the meter to enter the negotiation waiting state; The programming mode selection instruction is used to switch the electricity meter from the negotiation waiting state to the programming authentication waiting state; If a programming authentication waiting frame is received from the meter, the programming access key of the first communication protocol is sent to the meter; the programming authentication waiting frame is used to instruct the meter to enter the programming authentication waiting state; the programming access key is used by the meter to verify the upgrade access permission of the host computer and switch the meter from the programming authentication waiting state to the programming connection state. If a programming connection response frame is received from the meter, a first upgrade command is sent to the meter in sequence. The programming connection response frame is used to indicate that the meter enters the programming connection state; the first upgrade instruction is encapsulated in a first communication protocol format, and is used by the meter to convert the first upgrade instruction into a second upgrade instruction through a protocol adaptation layer each time it receives the first upgrade instruction; the second upgrade instruction is encapsulated in a second communication protocol format, and is used by the meter to call the upgrade architecture interface corresponding to the second communication protocol to perform the meter upgrade operation and obtain the corresponding upgrade execution result; Receive the upgrade execution result returned by the electricity meter; The first upgrade instruction includes a programming write instruction, the second upgrade instruction includes an initialization instruction, and the step of sequentially sending the first upgrade instruction to the meter includes: The programming write instruction is sent to the electricity meter; the programming write instruction carries an initialization interface identifier address, and transmission initialization data is written to the initialization interface identifier address; the programming write instruction is used by the electricity meter to parse the initialization interface identifier address in the programming write instruction through the protocol adaptation layer, and convert it into the initialization instruction; the initialization instruction is used by the electricity meter to call the mirror initialization interface to complete the transmission initialization of the upgrade file.
8. The meter upgrade method according to claim 7, characterized in that, The first upgrade instruction further includes a block write instruction, and the second upgrade instruction further includes a block write instruction. The step of sequentially sending the first upgrade instruction to the meter also includes: The block write instruction is sent to the electricity meter; the block write instruction carries a block write interface identifier address, and writes the data block of the upgrade file at the block write interface identifier address; the block write instruction is used by the electricity meter to parse the block write interface identifier address in the block write instruction through the protocol adaptation layer, and convert it into the block write instruction; the block write instruction is used by the electricity meter to call the data block write interface and write the received data block into the temporary storage area of the electricity meter.
9. The meter upgrading method according to claim 8, characterized in that, The first upgrade instruction further includes an execution instruction, and the second upgrade instruction further includes a transmission verification instruction. The step of sequentially sending the first upgrade instruction to the meter further includes: The execution instruction is sent to the electricity meter; the execution instruction carries a transmission verification interface identifier address, and the execution instruction is used by the electricity meter to parse the transmission verification interface identifier address in the execution instruction through the protocol adaptation layer and convert it into the transmission verification instruction. The transmission verification instruction is used by the electricity meter to call the mirror verification interface to perform integrity verification on the upgrade file in the temporary storage area.
10. The method for upgrading an electricity meter according to claim 9, characterized in that, The first upgrade instruction further includes an activation action instruction, and the second upgrade instruction further includes a firmware activation instruction. The step of sequentially sending the first upgrade instruction to the meter also includes: The activation action command is sent to the electricity meter; the activation action command carries a firmware activation interface identifier address; the activation action command is used by the electricity meter to parse the firmware activation interface identifier address in the activation action command through the protocol adaptation layer and convert it into the firmware activation command; the firmware activation command is used by the electricity meter to call the script execution interface to write the upgrade file in the temporary storage area into the formal running area to activate the new firmware.
11. The meter upgrading method according to claim 7, characterized in that, After receiving the last upgrade execution result returned by the electricity meter, the process also includes: Send a communication disconnect command to the electricity meter; the communication disconnect command is used to instruct the electricity meter to disconnect the communication connection with the host computer after activating the new firmware, and trigger the electricity meter to restart to load the new firmware.
12. A dual-layer protocol combination meter upgrade device, applicable to electricity meters, characterized in that, include: The negotiation response module is used to respond to the communication connection request of the first communication protocol sent by the host computer and return a corresponding negotiation waiting frame to the host computer. The communication connection request is used to request the electricity meter to establish a communication connection with the host computer and to switch the electricity meter from an idle state to a negotiation waiting state. The negotiation waiting frame is used to instruct the meter to enter the negotiation waiting state; The authentication response module is used to respond to the programming mode selection instruction of the first communication protocol sent by the host computer and return a corresponding programming authentication waiting frame to the host computer; the programming mode selection instruction is used to switch the meter from the negotiation waiting state to the programming authentication waiting state; the programming authentication waiting frame is used to instruct the meter to enter the programming authentication waiting state. A connection response module is used to respond to the programming access key of the first communication protocol sent by the host computer and return a corresponding programming connection response frame to the host computer; the programming access key is used by the electricity meter to verify the upgrade access permission of the host computer and switch the electricity meter from the programming authentication waiting state to the programming connection state; the programming connection response frame is used to indicate that the electricity meter enters the programming connection state. The instruction conversion module is used to receive the first upgrade instruction sent sequentially by the host computer, and convert the first upgrade instruction into a second upgrade instruction through the protocol adaptation layer each time the first upgrade instruction is received; the first upgrade instruction is encapsulated in a first communication protocol format, and the second upgrade instruction is encapsulated in a second communication protocol format. The upgrade execution module is used to respond to the second upgrade instruction, call the upgrade architecture interface corresponding to the second communication protocol to perform the meter upgrade operation, obtain the corresponding upgrade execution result, and return the upgrade execution result to the host computer; The first upgrade instruction includes a programming write instruction, and the second upgrade instruction includes an initialization instruction. The step of receiving the first upgrade instruction sequentially sent by the host computer, and converting the first upgrade instruction into a second upgrade instruction through a protocol adaptation layer each time the first upgrade instruction is received, includes: The system receives a programming write instruction sent by the host computer. The programming write instruction carries an initialization interface identifier address, and writes transmission initialization data into the initialization interface identifier address. The protocol adaptation layer parses the initialization interface identifier address in the programming write instruction and converts it into the initialization instruction; the initialization instruction is used by the meter to call the mirror initialization interface to complete the transmission initialization of the upgrade file.
13. A meter upgrade device with a dual-layer protocol combination, characterized in that, Applicable to host computers, including: The request sending module is used to send a communication connection request of the first communication protocol to the electricity meter; the communication connection request is used to request the electricity meter to establish a communication connection with the host computer and switch the electricity meter from an idle state to a negotiation waiting state; The mode sending module is used to send a programming mode selection instruction of the first communication protocol to the electricity meter if it receives a negotiation waiting frame returned by the electricity meter; the negotiation waiting frame is used to instruct the electricity meter to enter the negotiation waiting state; the programming mode selection instruction is used to switch the electricity meter from the negotiation waiting state to the programming authentication waiting state. The key sending module is used to send a programming access key of the first communication protocol to the electricity meter if it receives a programming authentication waiting frame returned by the electricity meter; the programming authentication waiting frame is used to instruct the electricity meter to enter the programming authentication waiting state; the programming access key is used by the electricity meter to verify the upgrade access permission of the host computer and switch the electricity meter from the programming authentication waiting state to the programming connection state. The instruction sending module is configured to send a first upgrade instruction to the electricity meter sequentially if a programming connection response frame is received from the electricity meter; the programming connection response frame is used to indicate that the electricity meter enters the programming connection state; the first upgrade instruction is encapsulated in a first communication protocol format, and the electricity meter converts the first upgrade instruction into a second upgrade instruction through a protocol adaptation layer each time it receives the first upgrade instruction; the second upgrade instruction is encapsulated in a second communication protocol format, and the electricity meter calls the upgrade architecture interface corresponding to the second communication protocol to perform the electricity meter upgrade operation and obtain the corresponding upgrade execution result; The result receiving module is used to receive the upgrade execution result returned by the electricity meter; The first upgrade instruction includes a programming write instruction, the second upgrade instruction includes an initialization instruction, and the step of sequentially sending the first upgrade instruction to the meter includes: The programming write instruction is sent to the electricity meter; the programming write instruction carries an initialization interface identifier address, and transmission initialization data is written to the initialization interface identifier address; the programming write instruction is used by the electricity meter to parse the initialization interface identifier address in the programming write instruction through the protocol adaptation layer, and convert it into the initialization instruction; the initialization instruction is used by the electricity meter to call the mirror initialization interface to complete the transmission initialization of the upgrade file.
14. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the computer device is configured as an electricity meter, the processor executes a computer program to implement the electricity meter upgrade method as described in any one of claims 1 to 6; or, when the computer device is configured as a host computer, the processor executes a computer program to implement the electricity meter upgrade method as described in any one of claims 7 to 11.
15. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the meter upgrade method as described in any one of claims 1 to 11.
Citation Information
Patent Citations
Load identification method based on dual-core intelligent electric meter
CN113281565A
