A method for hot-switching configuration of transmission tower monitoring terminal parameters
By correcting the status flags and determining the active area of the FLASH memory in the transmission tower monitoring terminal, the parameter writing is ensured under the condition that the battery voltage and communication status meet the requirements. This solves the problem of inconsistent parameter updates, realizes safe hot-switching configuration, and improves the operational continuity of the terminal and the integrity of parameter updates.
Patent Information
- Application Number
- CN202610936085.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-26
- Publication Date
- 2026-11-10
AI Technical Summary
In existing technologies, when power transmission tower monitoring terminals update parameters in unattended environments in the field, incomplete data in the parameter area is easily caused by voltage drops, task preemption, or communication abnormalities. Furthermore, the remote and on-site configuration trigger times are independent, making it difficult to guarantee the consistency and integrity of parameter content, thus affecting the availability and synchronization effect of the terminal.
By reading the status flags and correcting the validity of the FLASH of the transmission tower monitoring terminal, the active data area is determined and loaded into the cache; when the battery voltage and communication status meet the conditions, the write ready flag is set to valid; after receiving the write request, the processing task is suspended, the data spare area is determined and erased, written and verified; after the verification is passed, the data active area is updated and the processing task is resumed, triggering version synchronization.
It enables safe hot-switching configuration under runtime constraints, reduces the risk of data corruption and version inconsistency during parameter updates, and improves the integrity of terminal parameter updates and operational continuity.
Smart Images

Figure CN123067948A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of parameter hot-switching configuration technology, and more specifically, to a method for hot-switching configuration of parameters for a transmission tower monitoring terminal. Background Technology
[0002] Hot-switch configuration technology for parameters is a crucial supporting technology for embedded monitoring terminals to update operating parameters without interrupting main business operations. It primarily enables functions such as parameter writing, parameter loading, version switching, and operating configuration synchronization. For transmission line tower monitoring terminals, which typically undertake the continuous acquisition of conductor status, tower environment, and equipment operating information, hot-switch configuration technology reduces the frequency of on-site maintenance downtime, improves remote operation and maintenance efficiency, and provides a fundamental guarantee for the long-term continuous operation of online monitoring systems for transmission lines.
[0003] In existing technologies, transmission tower monitoring terminals are mostly deployed in unattended outdoor environments. Terminal operating parameters are typically updated via remote maintenance platforms or on-site Bluetooth configuration. Since the terminals rely on battery power, and parameter writing often involves FLASH erasure and programming operations, voltage drops, task preemption, or communication anomalies during the writing process can easily cause the parameter area data to be partially written, resulting in the inability to read valid parameters after the terminal restarts. At the same time, the triggering times for remote parameter distribution and local configuration are independent of each other. When two requests arrive close together, the traditional single-area writing method cannot guarantee the complete consistency of parameter content. In addition, existing parameter writing mechanisms are usually independent of data acquisition task scheduling, battery voltage status, and communication connection status, which can easily lead to writing operations being performed within inappropriate operating windows, thereby affecting the availability and synchronization effect of terminal parameter updates. Therefore, how to achieve safe hot-switching configuration of parameters under the constraints of the operating status of transmission tower monitoring terminals has become a challenge for the industry. Summary of the Invention
[0004] This application provides a method for hot-switching configuration of parameters of a transmission tower monitoring terminal, which can realize safe hot-switching configuration of parameters under the constraints of the operating status of the transmission tower monitoring terminal.
[0005] In a first aspect, this application provides a method for hot-switching configuration of parameters for a transmission tower monitoring terminal, comprising the following steps: The status flags in the FLASH of the transmission tower monitoring terminal are read and validity is corrected. The active area of the FLASH is determined to obtain the data active area, and the parameter data in the data active area is loaded into the cache. When the battery voltage of the transmission tower monitoring terminal is not lower than the preset voltage threshold, the processing task is in a blocked state, and the MQTT channel status is connected, the write ready flag will be set to valid. When a parameter write request is received and the write ready flag is valid, the data spare area is determined based on the data active area pointer information. The current processing task is suspended, and the write ready flag is confirmed to be valid again after suspension. After confirmation, the data spare area is erased, written, and verified. After successful verification, the current timestamp is written to the data backup area and the status flag of the data backup area is set to valid. The pointer information of the data active area is updated to point to the data backup area. The data active area is erased, the suspended processing tasks are resumed, the cache is updated with the parameter data of the data backup area, and version synchronization is triggered.
[0006] In this embodiment, reading the status flags and correcting their validity in the FLASH memory of the transmission tower monitoring terminal specifically includes: Read the word data at the preset offset positions of the first and second parameter areas of the FLASH in the transmission tower monitoring terminal, and extract the area status flag from the word data; The validity of the zone status flags of the first parameter zone and the second parameter zone is checked. If the zone status flag is not within the preset valid value range, the zone status flag is forcibly set to the first preset value. Words are written to the preset offset positions of the first parameter area and the second parameter area, respectively.
[0007] In this embodiment, determining the active area of the FLASH memory to obtain the active data area, and loading the parameter data in the active data area into the cache specifically includes: When the status flag of the first parameter area of the FLASH is the second preset value and the status flag of the second parameter area of the FLASH is not the second preset value, the first parameter area is determined to be the data active area, and the FLASH page is erased in the second parameter area. When the status flag of the second parameter area of the FLASH is the second preset value and the status flag of the first parameter area of the FLASH is not the second preset value, the second parameter area is determined to be the data active area, and the FLASH page is erased on the first parameter area. When the status flags of the first parameter area and the second parameter area of the FLASH are both the second preset value, the write timestamp of the first parameter area and the write timestamp of the second parameter area are read, the area with the larger write timestamp is determined as the data active area, and the FLASH page is erased for the inactive area. When the status flags of the first parameter area and the second parameter area of the FLASH are not both the second preset value, the factory default parameter restoration procedure is executed. Perform cyclic redundancy check on the parameter data starting from a preset offset position in the data active area; After the cyclic redundancy check passes, the parameter data starting from the preset offset position in the data active area is read back character by character, and the read-back value is compared character by character with the data used during the cyclic redundancy check. After the character-by-character comparison is successful, all parameter data starting from the preset offset position in the active data area is copied to the cache.
[0008] In this embodiment, when the battery voltage of the transmission tower monitoring terminal is not lower than a preset voltage threshold, the processing task is in a blocked state, and the MQTT channel status is connected, setting the write ready flag to valid specifically includes: When the battery voltage value of the transmission tower monitoring terminal is not lower than the preset voltage threshold, the voltage normal flag is set to valid; when the battery voltage value is lower than the preset voltage threshold, the voltage normal flag is set to invalid. When the processing task of the transmission tower monitoring terminal is in a blocked state, the current value of the idle flag is used as the acquisition window state. When the processing task is in a suspended or deleted state, the acquisition window state is forcibly set to valid. Query the running status of network tasks. When a network task is in a blocked state, use the state maintained by the network task as the MQTT channel status. When a network task is in a suspended or deleted state, force the MQTT channel status to be valid. Read the voltage normal flag, the acquisition window status, and the MQTT channel status. When all three are valid, set the write ready flag to valid. When any one of the three is invalid, set the write ready flag to invalid.
[0009] In this embodiment, when a parameter write request is received and the write-ready flag is valid, determining the data spare area based on the data active area pointer information specifically includes: When a parameter write request is received and the write ready flag is valid, the pointer information of the active data area is read, and the active area pointer is obtained from the pointer information. When the active area pointer is the first code, the second parameter area of the FLASH is determined as the data spare area; When the active area pointer is the second code, the first parameter area of the FLASH is determined as the data spare area; When the active area pointer is other than a certain value, the area status flags of the first and second parameter areas of the FLASH are reread, the data active area is re-determined based on the area status flags, and the inactive area is determined as the data spare area.
[0010] In this embodiment, suspending the current processing task and then reconfirming that the write-ready flag is valid, followed by erasing, writing, and verifying the data spare area after confirmation, specifically includes: After suspending the processing task, read the write ready flag again, and after confirming that the write ready flag is valid, perform FLASH page erasure on the data spare area; Read the erase status flag of the FLASH page eraser, and after confirming that there are no error bits in the erase status flag, write the parameter data in the current execution buffer into the data spare area; Perform cyclic redundancy check calculation on the parameter data starting from the preset offset position in the data spare area, and write the check calculation result into the preset check value storage location in the data spare area; The parameter data starting from the preset offset position in the data spare area is read back word by word, and the cyclic redundancy check value is recalculated and recorded as the read-back check value. At the same time, the check value stored in the preset check value storage position in the data spare area is read and recorded as the flash check value. The readback check value is compared with the check calculation result, the readback check value is compared with the flash memory check value, and all word-by-word readback values are compared word-by-word with the parameter data in the current execution buffer.
[0011] In this embodiment, performing cyclic redundancy check calculations on the parameter data starting from a preset offset position in the data spare area, and writing the check calculation results into the preset check value storage location in the data spare area specifically includes: Read the parameter data that has been written to the data spare area starting from the preset offset position; Perform a write consistency check on the parameter data to obtain the write consistency check result; When the write consistency check result is passed, the parameter data is subjected to cyclic redundancy check calculation, the check calculation result is obtained and written to the preset check value storage location in the data spare area.
[0012] In this embodiment, after successful verification, the current timestamp is written to the data backup area and the status flag of the data backup area is set to valid. Updating the pointing information of the data active area to point to the data backup area specifically includes: After the verification is successful, the second-level timestamp of the current real-time clock is read as the write timestamp; Write the timestamp to the preset timestamp storage location in the data spare area; Perform word writing at the preset offset position of the data spare area and set the area status flag of the data spare area to valid; Update the active area pointer in the active area pointer information to the code corresponding to the spare area.
[0013] In this embodiment, erasing the active data area and resuming the suspended processing task specifically includes: Perform FLASH page erasure on the active data area and read the erasure status flag; When the erase status flag indicates that the erase was successful, the hot-swap is confirmed to be complete, and the active data area becomes the new data backup area; When the erase status flag indicates that the erase has failed, keep the zone status flag of the active data zone unchanged, increment the fault count and record the erase failure log. Resume suspended processing tasks after erasure is complete.
[0014] In this embodiment, updating the cache with parameter data from the data backup area and triggering version synchronization specifically includes: Update the cache with the parameter data in the data standby area; Read the write source identifier and write timestamp from the current execution buffer; A parameter version number is generated based on the write timestamp and the write source identifier, and the parameter version number is written to the third parameter area of the FLASH. Set the synchronization flag in the third parameter area to valid, and clear the retry synchronization count in the third parameter area to zero; Version update events are sent to network tasks via an event notification mechanism, and the network tasks then execute the version synchronization process.
[0015] The technical solutions provided by the embodiments disclosed in this application have the following beneficial effects: The status flags in the FLASH memory of the transmission tower monitoring terminal are read and their validity corrected. The active area of the FLASH memory is determined, and the parameter data in the active area is loaded into the cache. When the battery voltage of the transmission tower monitoring terminal is not lower than a preset voltage threshold, the processing task is in a blocked state, and the MQTT channel is connected, the write-ready flag is set to valid. When a parameter write request is received and the write-ready flag is valid, the data backup area is determined based on the pointer information of the active area. The current processing task is suspended, and the write-ready flag is confirmed to be valid again after suspension. After confirmation, the data backup area is erased, written, and verified. After successful verification, the current timestamp is written to the data backup area, the status flag of the data backup area is set to valid, the pointer information of the active area is updated to point to the data backup area, the active area is erased, the suspended processing task is resumed, the cache is updated with the parameter data of the data backup area, and version synchronization is triggered.
[0016] Therefore, this application demonstrates that the cache can be updated with parameter data from the data backup area, triggering version synchronization. Firstly, by reading the status flags, correcting their validity, and determining the active area in the FLASH memory of the transmission tower monitoring terminal, and loading the parameter data from the active area into the cache, a valid parameter baseline can be established before parameter updates. This ensures the terminal prioritizes reading parameters from the data area with a clear status that can serve as the basis for current operation, avoiding the impact of invalid status flags caused by power outages or abnormal writes on parameter loading after terminal restart. Secondly, by setting the battery voltage not lower than a preset voltage threshold, the processing task being in a blocked state, and the MQTT channel being connected as valid preconditions for write readiness, parameter writing can be restricted to an operating window where power supply conditions are met, task preemption risk is low, and the communication link has synchronization capabilities. This reduces low-voltage programming failures, interrupted writing of data acquisition tasks, and the inability to synchronize versions in a timely manner after writing. The problem is that, upon receiving a parameter write request and confirming the write-ready flag, the system determines the data backup area based on the data active area's pointer information. After suspending the current processing task, it reconfirms the write-ready flag, avoiding direct overwriting of the currently valid parameter area. This allows the backup area to handle the erasure, write, and verification operations during the new parameter write process. Simultaneously, task suspension and secondary confirmation reduce the impact of runtime status changes on FLASH write integrity. Finally, after successful verification, the system writes a timestamp, sets a valid status flag, updates the active area pointer, erases the original data active area, resumes the suspended processing task, updates the cache, and triggers version synchronization. This ensures that the newly written parameters only take over the terminal's runtime configuration after verification, and that cached parameters and remote version status are updated accordingly. This reduces the risk of data corruption, version inconsistencies, and runtime interruptions during parameter updates in unattended outdoor scenarios, improving the integrity and continuous operation of the terminal parameter update process.
[0017] In summary, the technical solution adopted in this application can realize the safe hot-switching configuration of parameters under the constraints of the operating status of the transmission tower monitoring terminal. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only for this embodiment of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is an exemplary flowchart of a method for hot-switching configuration of transmission tower monitoring terminal parameters provided in this application; Figure 2 This is a flowchart illustrating the process of determining the data reserve area based on the information provided in this application. Detailed Implementation
[0020] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0021] This application provides a method for configuring hot-switching parameters of a transmission tower monitoring terminal. The core of this method involves reading and correcting the status flags of the FLASH memory in the transmission tower monitoring terminal, determining the active area of the FLASH memory to obtain the data active area, and loading the parameter data in the data active area into the cache. When the battery voltage of the transmission tower monitoring terminal is not lower than a preset voltage threshold, the processing task is in a blocked state, and the MQTT channel is connected, the write-ready flag is set to valid. When a parameter write request is received and the write-ready flag is valid, a data backup area is determined based on the pointing information of the data active area. The current processing task is suspended, and the write-ready flag is confirmed to be valid again after suspension. After confirmation, the data backup area is erased, written, and verified. After successful verification, the current timestamp is written to the data backup area, the status flag of the data backup area is set to valid, the pointing information of the data active area is updated to point to the data backup area, the data active area is erased, the suspended processing task is resumed, the cache is updated with the parameter data of the data backup area, and version synchronization is triggered.
[0022] Example 1: To better understand the above technical solution, the following will provide a detailed description of the technical solution in conjunction with the accompanying drawings and specific implementation methods. (Refer to...) Figure 1 As shown in the figure, this is an exemplary flowchart of a method for hot-switching configuration of transmission tower monitoring terminal parameters according to this embodiment of the present application, including the following steps: In step S1, the status flag of the FLASH in the transmission tower monitoring terminal is read and its validity is corrected, and the active area of the FLASH is determined to obtain the data active area. The parameter data in the data active area is loaded into the cache.
[0023] In this embodiment, the status flag reading and validity correction of the FLASH in the transmission tower monitoring terminal can be achieved by the following steps: Read the word data at the preset offset positions of the first and second parameter areas of the FLASH in the transmission tower monitoring terminal, and extract the area status flag from the word data; The validity of the zone status flags of the first parameter zone and the second parameter zone is checked. If the zone status flag is not within the preset valid value range, the zone status flag is forcibly set to the first preset value. Words are written to the preset offset positions of the first parameter area and the second parameter area, respectively.
[0024] It should be noted that, in this application, the zone status flag represents a flag field used to identify the current storage state of the FLASH parameter zone; the first parameter zone represents a parameter storage area in the FLASH used to store a set of terminal parameter data; the second parameter zone represents a parameter storage area in the FLASH that alternates with the first parameter zone in parameter hot switching; the preset offset position represents a fixed address position in the FLASH zone used to store the zone status flag and the write source identifier; the word data represents four bytes of stored data read from the preset offset position at one time; the preset valid value range represents the range of state values that the zone status flag is allowed to take during normal operation and abnormal recovery; the first preset value represents a flag value used to restore the abnormal zone status flag to its initial identifiable state; and the validity correction represents the state correction process of restoring the zone status flag that does not belong to the preset valid value range to the first preset value.
[0025] In specific implementation, firstly, after the transmission tower monitoring terminal is powered on, the memory management task accesses the first and second parameter areas of the FLASH memory and reads four-byte words of data at offset 0x000 in each parameter area. The first byte of the four-byte word data is used as the area status flag, the second byte is used as the write source identifier, the padding value of the last two bytes is retained, and the extracted first byte is used as the area status flag for each of the first and second parameter areas. Secondly, the memory management task compares the area status flags of the first and second parameter areas with the preset valid value range consisting of 0x00, 0x01, 0x02, and 0x03. When the area status flag is 0xFF or other values that do not belong to the preset valid value range, 0x00 is written as the first preset value to the corresponding area status flag position. Finally, the memory management task performs four-byte word writing at the preset offset positions of the first and second parameter areas according to the FLASH word programming requirements.
[0026] In this embodiment, the active area of the FLASH memory is determined to obtain the active data area, and the parameter data in the active data area is loaded into the cache, which can be achieved by the following steps: When the status flag of the first parameter area of the FLASH is the second preset value and the status flag of the second parameter area of the FLASH is not the second preset value, the first parameter area is determined to be the data active area, and the FLASH page is erased in the second parameter area. When the status flag of the second parameter area of the FLASH is the second preset value and the status flag of the first parameter area of the FLASH is not the second preset value, the second parameter area is determined to be the data active area, and the FLASH page is erased on the first parameter area. When the status flags of the first parameter area and the second parameter area of the FLASH are both the second preset value, the write timestamp of the first parameter area and the write timestamp of the second parameter area are read, the area with the larger write timestamp is determined as the data active area, and the FLASH page is erased for the inactive area. When the status flags of the first parameter area and the second parameter area of the FLASH are not both the second preset value, the factory default parameter restoration procedure is executed. Perform cyclic redundancy check on the parameter data starting from a preset offset position in the data active area; After the cyclic redundancy check passes, the parameter data starting from the preset offset position in the data active area is read back character by character, and the read-back value is compared character by character with the data used during the cyclic redundancy check. After the character-by-character comparison is successful, all parameter data starting from the preset offset position in the active data area is copied to the cache.
[0027] It should be noted that, in this application, the second preset value represents the zone status flag value used to identify that the parameter data in the FLASH parameter area is in a valid and loadable state; the active data area represents the FLASH parameter area currently selected by the transmission tower monitoring terminal and used to provide operating parameters; the inactive area represents the FLASH parameter area not selected by the current parameter reading process and can be used as a backup write object in the subsequent hot switching process; the write timestamp represents the second-level time information recorded by the real-time clock when the parameter area completes a valid write; the factory default parameter recovery step represents the protection process of restoring basic parameters from the factory default parameter area when neither the first parameter area nor the second parameter area can provide valid parameters; the cyclic redundancy check represents the CRC32 check process used to check the logical integrity of the parameter data; the readback value represents the four-byte stored value reread from the active data area; and the cache represents the SRAM parameter cache used for reading parameter data by various functional modules of the transmission tower monitoring terminal.
[0028] In specific implementation, firstly, the memory management task reads the zone status flags of the first and second parameter zones after validity correction. When the zone status flag of the first parameter zone is 0x02 and the zone status flag of the second parameter zone is not 0x02, the first parameter zone is designated as the active data zone, and the second parameter zone is designated as the inactive zone for FLASH page erasure. After erasure, the erase status flag returned by the FLASH controller is read. Secondly, when the zone status flag of the second parameter zone is 0x02 and the zone status flag of the first parameter zone is not 0x02, the second parameter zone is designated as the active data zone, and the first parameter zone is designated as the inactive zone for FLASH page erasure. The erase status flag is then read. When an error bit exists, the original status flag of the first parameter area remains unchanged, and the accumulated fault count is used as an abnormal record for erasing inactive areas. Next, when the status flags of both the first and second parameter areas are 0x02, the write timestamps at offset 0x004 in the first and second parameter areas are read respectively. The area with the larger write timestamp is designated as the active data area, and the other parameter area is designated as the inactive area for FLASH page erasure. If the two write timestamps are the same, the first parameter area is designated as the active data area, the second parameter area is designated as the inactive area for FLASH page erasure, and the synchronization flag is set to valid. Then, when the... When the status flags of both the first and second parameter areas are not 0x02, the memory management task reads 2036 bytes of factory default parameters and the CRC32 checksum stored at offset 0x7FC from the factory default parameter area. It then recalculates the checksum of the factory default parameters using the CRC32-MPEG2 rule. If the calculated value matches the stored value, the factory default parameters are written to the first parameter area, and the first parameter area is designated as the recovered active data area. Next, the memory management task uses 2036 bytes of parameter data starting at offset 0x008 in the active data area as the verification object, performs cyclic redundancy check according to the CRC32-MPEG2 rule, and compares the calculated checksum with... The checksum stored at offset 0x7FC in the active data region is compared with the checksum. If the two are consistent, the result is taken as the result of passing the logical integrity check of the active data parameter data. Subsequently, after passing the cyclic redundancy check, the memory management task performs word-by-word readback starting from offset 0x008 in the active data region, reading a total of 509 words. Each readback value is compared word-by-word with the corresponding four-byte data used during the cyclic redundancy check. If all readback values are consistent, the result is taken as the result of passing the physical integrity check of the FLASH. Finally, after passing the word-by-word comparison, the memory management task copies the 2036 bytes of parameter data starting from offset 0x008 in the active data region to the SRAM parameter cache.
[0029] In step S2, when the battery voltage of the transmission tower monitoring terminal is not lower than the preset voltage threshold, the processing task is in a blocked state, and the MQTT channel status is connected, the write ready flag is set to valid.
[0030] In this embodiment, when the battery voltage of the transmission tower monitoring terminal is not lower than a preset voltage threshold, the processing task is in a blocked state, and the MQTT channel status is connected, setting the write ready flag to valid can be achieved using the following steps: When the battery voltage value of the transmission tower monitoring terminal is not lower than the preset voltage threshold, the voltage normal flag is set to valid; when the battery voltage value is lower than the preset voltage threshold, the voltage normal flag is set to invalid. When the processing task of the transmission tower monitoring terminal is in a blocked state, the current value of the idle flag is used as the acquisition window state. When the processing task is in a suspended or deleted state, the acquisition window state is forcibly set to valid. Query the running status of network tasks. When a network task is in a blocked state, use the state maintained by the network task as the MQTT channel status. When a network task is in a suspended or deleted state, force the MQTT channel status to be valid. Read the voltage normal flag, the acquisition window status, and the MQTT channel status. When all three are valid, set the write ready flag to valid. When any one of the three is invalid, set the write ready flag to invalid.
[0031] It should be noted that, in this application, the battery voltage value represents the battery power supply voltage obtained and converted by the transmission tower monitoring terminal through the battery voltage sampling circuit; the preset voltage threshold represents the battery voltage safety threshold used to ensure the atomic completion of FLASH word programming operations; the voltage normal flag represents the status flag indicating whether the battery voltage value meets the FLASH write power supply conditions; the processing task represents the task in the transmission tower monitoring terminal that performs sensor acquisition scheduling; the acquisition idle flag represents the flag indicating whether the processing task is in a suspendable window within the current acquisition cycle; the acquisition window status represents the window status indicating whether the current processing task status allows the parameter writing process to enter the FLASH operation stage; the network task represents the task of maintaining the MQTT channel connection status and version synchronization communication; the MQTT channel status represents the MQTT connection availability status maintained by the network task; and the write ready flag represents the joint admission flag formed when the voltage normal flag, the acquisition window status, and the MQTT channel status all meet the write conditions.
[0032] In specific implementation, firstly, when the battery voltage value of the transmission tower monitoring terminal is not lower than a preset voltage threshold, the voltage normal flag is set to valid; when the battery voltage value is lower than the preset voltage threshold, the voltage normal flag is set to invalid. Secondly, the system status monitoring task reads the running status of the processing task through the task status query interface. When the processing task is in a blocked state, it reads the current value of the acquisition idle flag and uses the current value of the acquisition idle flag as the acquisition window status; when the processing task is in a suspended or deleted state, it uses the valid value as the acquisition window status. Next, the system status monitoring task reads the running status of the network task through the task status query interface. When the network task is in a blocked state, it reads the network task maintenance... The current connection value is used as the MQTT channel status. When the network task is suspended or deleted, the valid value is used as the MQTT channel status. Finally, the system status monitoring task reads the voltage normal flag, the acquisition window status, and the MQTT channel status. When all three are valid, the write ready flag is set to valid, and a ready event notification is sent to the write queue scheduling task when the write ready flag changes from invalid to valid. When any of the three is invalid, the write ready flag is set to invalid, and a not ready event notification is sent to the write queue scheduling task when the write ready flag changes from valid to invalid. The current value of the write ready flag is used as the joint determination result for whether the parameter write request can enter the hot switching process.
[0033] It should be noted that in this embodiment, the preset monitoring period is set to 1500ms. This value is set according to the default trigger period of 1000ms for the sensor acquisition and processing task, ensuring that the execution time of the system status monitoring task falls within the interval from the completion of the sensor acquisition and processing task to the trigger of the next acquisition. The battery voltage sampling channel uses channel CH4 of the main control chip ADC0. The voltage division ratio of the battery voltage sampling circuit is 2 / 3, the ADC reference voltage is 3300mV, and the ADC sampled value is converted to the battery voltage value according to the voltage division conversion relationship. The ADC conversion waiting time limit is set to 100ms, which is greater than the ADC single conversion time of 25μs, to reserve a margin for hardware anomaly identification outside the normal conversion time. The effective sampling range is set to 820 to 3475 to exclude raw sampling values caused by open circuits, short circuits, or abnormalities in the sampling circuit. The preset voltage threshold is set to 3000mV, which is jointly set by the voltage regulator chip's input undervoltage protection threshold of 2500mV, the switching device's on-state voltage drop of 100mV, the battery's internal resistance voltage drop of 100mV, and a 300mV power supply margin. This ensures that the main control chip's operating voltage meets the minimum operating voltage requirement for FLASH word programming operations when the battery voltage is not lower than 3000mV. The low voltage alarm threshold is set to 2200mV, which retains a 200mV warning margin based on the battery termination voltage of 2000mV. This is used to trigger a low voltage alarm before the battery voltage approaches the termination voltage.
[0034] In step S3, when a parameter write request is received and the write ready flag is valid, the data spare area is determined according to the data active area pointing information, the current processing task is suspended, and the write ready flag is confirmed to be valid again after suspension. After confirmation, the data spare area is erased, written, and verified.
[0035] Preferably, in this embodiment, when a parameter write request is received and the write-ready flag is valid, the data spare area is determined based on the data active area pointing information, referring to... Figure 2 As shown in the figure, this is a schematic flowchart of the process for determining the data spare area in some embodiments of this application. In this embodiment, the determination of the data spare area can be achieved by the following steps: In step S31, when a parameter write request is received and the write ready flag is valid, the pointer information of the active data area is read, and the active area pointer is obtained from the pointer information. In step S32, when the active area pointer is the first code, the second parameter area of the FLASH is determined as the data spare area; In step S33, when the active area pointer is the second code, the first parameter area of the FLASH is determined as the data spare area; In step S34, when the active area pointer is other than other values, the area status flags of the first and second parameter areas of the FLASH are reread, the data active area is re-determined according to the area status flags, and the inactive area is determined as the data spare area.
[0036] It should be noted that in this application, the parameter write request refers to a write request used to trigger the transmission tower monitoring terminal to update parameters; the write ready flag refers to a joint access flag that allows the parameter write request to enter the FLASH hot-switching process; the data active area pointer information refers to the FLASH control field information used to record the current valid parameter area position; the active area pointer refers to the parameter area encoding value read from the data active area pointer information; the first code refers to the encoding value pointing to the first parameter area in the current active state; the second code refers to the encoding value pointing to the second parameter area in the current active state; other values refer to abnormal pointer values that do not belong to the first code and the second code; the data spare area refers to the FLASH parameter area used to receive new parameter data in the hot-switching write process without affecting the reading of the current operating parameters.
[0037] In practice, firstly, upon receiving a parameter write request, the write queue scheduling task reads the write-ready flag. When the write-ready flag is valid, the memory management task reads the pointer information of the active data area and uses the encoded value obtained from the pointer information as the active area pointer. Secondly, when the active area pointer is the first encoded value, the memory management task, assuming that the first parameter area is providing valid parameter data, uses the second parameter area of the FLASH as the data backup area. Next, when the active area pointer is the second encoded value, the memory management task, assuming that the second parameter area is providing valid parameter data, uses the first parameter area of the FLASH as the data backup area. Finally, when the active area pointer is any other value, the memory management task rereads the area status flags of the first and second parameter areas of the FLASH and re-determines the active data area according to the area status flags, using the parameter area other than the re-determined active data area as the data backup area. If neither the first nor the second parameter area can be determined as the active data area, the current parameter write request is terminated, and the system exception response is taken as the result of the failure to select the data backup area.
[0038] It should be noted that, in this embodiment, the pointer information of the active data area can be stored using the Ptr_active field in the INT parameter area, which is located at a preset offset position in the INT parameter area; the first code can be set to 0x01, when the active area pointer is 0x01, it indicates that the first parameter area is the current active data area, and the second parameter area is selected as the data reserve area; the second code can be set to 0x02, when the active area pointer is 0x02, it indicates that the second parameter area is the current active data area, and the first parameter area is selected as the data reserve area; when the active area pointer is neither 0x01 nor 0x02, the memory management task rereads the area status flags of the first and second parameter areas respectively, and if the area status flag of the first parameter area is 0x02 and the area status flag of the second parameter area is not 0... If the status flag of the second parameter area is 0x02, then the first parameter area is designated as the active data area, the second parameter area as the backup data area, and Ptr_active is written back to 0x01. If the status flag of the second parameter area is 0x02 and the status flag of the first parameter area is not 0x02, then the second parameter area is designated as the active data area, the first parameter area as the backup data area, and Ptr_active is written back to 0x02. If the status flags of both parameter areas are 0x02, then the write timestamps of the two parameter areas are read, the area with the larger write timestamp is designated as the active data area, and the other parameter area is designated as the backup data area. If the write timestamps are equal, the second parameter area is designated as the backup data area by default. If the status flags of both parameter areas are not 0x02, then a system exception response is returned to the source of the parameter write request, and the current parameter write request is removed.
[0039] In this embodiment, suspending the current processing task and then confirming the write-ready flag is valid again, followed by erasing, writing, and verifying the data spare area, can be achieved through the following steps: After suspending the processing task, read the write ready flag again, and after confirming that the write ready flag is valid, perform FLASH page erasure on the data spare area; Read the erase status flag of the FLASH page eraser, and after confirming that there are no error bits in the erase status flag, write the parameter data in the current execution buffer into the data spare area; Perform cyclic redundancy check calculation on the parameter data starting from the preset offset position in the data spare area, and write the check calculation result into the preset check value storage location in the data spare area; The parameter data starting from the preset offset position in the data spare area is read back word by word, and the cyclic redundancy check value is recalculated and recorded as the read-back check value. At the same time, the check value stored in the preset check value storage position in the data spare area is read and recorded as the flash check value. The readback check value is compared with the check calculation result, the readback check value is compared with the flash memory check value, and all word-by-word readback values are compared word-by-word with the parameter data in the current execution buffer.
[0040] It should be noted that in this application, the current processing task refers to the terminal processing task that may preempt the memory management task during FLASH programming; the write-ready flag refers to the joint admission flag that allows the parameter writing process to enter the FLASH operation stage; the data spare area refers to the inactive FLASH parameter area used to receive the parameter data in this parameter write request; the erase status flag refers to the error bit status returned by the FLASH controller after the FLASH page is erased; the current execution buffer refers to the SRAM buffer used to temporarily store the parameter data in this parameter write request; the verification calculation result refers to the verification value obtained after performing cyclic redundancy check calculation on the parameter data written to the data spare area; the preset verification value storage location refers to the fixed storage location in the data spare area used to store the verification calculation result; the read-back verification value refers to the verification value obtained by re-performing cyclic redundancy check calculation after reading back the parameter data from the data spare area; the flash verification value refers to the verification value read from the preset verification value storage location in the data spare area; and word-by-word comparison refers to the comparison method of verifying the consistency of the read-back data and the parameter data in the current execution buffer at FLASH word programming units.
[0041] In specific implementation, firstly, the memory management task suspends the current processing task through a task suspension operation, preventing the processing task from preempting the memory management task during FLASH programming, and then reads the write-ready flag again after suspension. If the write-ready flag is still valid, FLASH page erasure is performed on the data spare area, and the write-ready flag that remains valid after suspension is used as a safe confirmation result for entering the erasure phase. If the write-ready flag becomes invalid, the current processing task is resumed, and the current parameter write request is returned to the waiting queue as a write delay result. Secondly, the memory management task reads the erase status flag after FLASH page erasure. If the erase status flag has no error bits, the data spare area is set to the writing state, and the parameter data body is read from the current execution buffer, executing FLASH word writing according to the write address order starting from the preset offset position in the data spare area. If the erase status flag has error bits, the current processing task is resumed, and the accumulated fault count is used as a record of data spare area erasure failure. Next, a cyclic redundancy check (CRC) calculation is performed on the parameter data starting from a preset offset position in the data backup area, and the CRC calculation result is written to the preset CRC value storage location in the data backup area. Then, the memory management task reads back the parameter data word by word from the preset offset position in the data backup area, and recalculates the CRC value based on the read-back parameter data. The recalculated CRC value is used as the read-back CRC value, and the CRC value stored in the preset CRC value storage location in the data backup area is read as the flash memory CRC value. Finally, the memory management task compares the read-back CRC value with the CRC calculation result, compares the read-back CRC value with the flash memory CRC value, and compares all word-by-word read-back values with the parameter data in the current execution buffer word by word. The result where all three comparisons are consistent is taken as the data backup area erasure, writing, and verification pass result. If any comparison result is inconsistent, the data backup area is set to a write failure state, the accumulated failure count is used as the write verification failure record, and the current processing task is resumed.
[0042] It should be noted that in this embodiment, the current processing task can be the sensor acquisition and processing task. The memory management task is suspended before FLASH programming to avoid the processing task being preempted by the timer during FLASH programming. The writing status of the data spare area can be achieved by setting the area status flag of the data spare area to 0x01. The preset offset position in the data spare area can be set to offset 0x008, the parameter data body size can be set to 2036 bytes, and it is written sequentially in units of 4 bytes, for a total of 509 words. The preset check value storage position can be set to offset 0x7FC in the data spare area, which is used to save the check calculation result obtained by performing cyclic redundancy check calculation on 2036 bytes of parameter data. The error bits in the erase status flag include write protection error bits and programming error bits. When neither type of error bit is set, it is considered that the erase status flag has no error bits. The execution time of the FLASH programming operation is controlled within the preset safe execution time limit. When the maximum operating current of the terminal and the internal resistance voltage drop of the battery meet the power supply margin conditions, the suspended FLASH programming operation can be completed under the condition that the battery voltage meets the preset voltage threshold.
[0043] In this embodiment, performing cyclic redundancy check calculations on the parameter data starting from a preset offset position in the data spare area and writing the check calculation results into the preset check value storage location in the data spare area can be achieved through the following steps: Read the parameter data that has been written to the data spare area starting from the preset offset position; Perform a write consistency check on the parameter data to obtain the write consistency check result; When the write consistency check result is passed, the parameter data is subjected to cyclic redundancy check calculation, the check calculation result is obtained and written to the preset check value storage location in the data spare area.
[0044] It should be noted that, in this application, the parameter data written to the data spare area starting from the preset offset position represents the parameter content that has been written from the current execution buffer to the parameter data body area of the data spare area; write consistency check represents the verification process used to check whether the parameter data written to the data spare area is consistent with the parameter data in the current execution buffer; write consistency check result represents the verification result of whether the parameter data in the data spare area remains complete and consistent after being written to FLASH; cyclic redundancy check calculation represents the CRC check process used to perform logical integrity verification on the parameter data that has passed the write consistency check; check calculation result represents the check value obtained after performing cyclic redundancy check calculation on the parameter data; preset check value storage location represents the fixed storage location in the data spare area used to save the check calculation result; current execution buffer represents the SRAM buffer used to temporarily store the parameter data in this parameter write request.
[0045] In practice, firstly, after the memory management task completes the sequential writing of parameter data in the data spare area, it reads the written parameter data from the preset offset position in the data spare area according to the FLASH read operation timing, and uses the read parameter data as the data to be verified for write consistency check. Secondly, the memory management task compares the data to be verified with the parameter data in the current execution buffer word by word in the same word order. When all words of data are consistent, the result is taken as the write consistency check result. When any word of data is inconsistent, the result is taken as the write consistency check result, and the writing of the current verification calculation result is stopped. Finally, when the write consistency check result is successful, the memory management task continuously performs verification calculations on the data to be verified according to the cyclic redundancy check rule, uses the obtained verification value as the verification calculation result, and writes the verification calculation result to the preset verification value storage location in the data spare area.
[0046] It should be noted that, in this embodiment, the preset offset position in the data spare area can be set to offset 0x008, and the size of the parameter data body can be set to 2036 bytes; the write consistency check can be performed in units of 4 bytes, and a total of 509 words are compared word by word; the cyclic redundancy check calculation can adopt the CRC32-MPEG2 check rule, and the check object is the 2036 bytes of parameter data starting from offset 0x008 in the data spare area; the preset check value storage location can be set to offset 0x7FC in the data spare area, which is used to store the check calculation result obtained after performing CRC32-MPEG2 check on the parameter data.
[0047] In step S4, after the verification is successful, the current timestamp is written to the data backup area and the status flag of the data backup area is set to valid. The pointing information of the data active area is updated to point to the data backup area. The data active area is erased, the suspended processing task is resumed, the cache is updated to the parameter data of the data backup area, and version synchronization is triggered.
[0048] In this embodiment, after successful verification, the current timestamp is written to the data backup area and the status flag of the data backup area is set to valid. The following steps can be used to update the pointing information of the data active area to point to the data backup area: After the verification is successful, the second-level timestamp of the current real-time clock is read as the write timestamp; Write the timestamp to the preset timestamp storage location in the data spare area; Write a word to the preset offset position of the data spare area and set the area status flag of the data spare area to valid; Update the active area pointer in the active area pointer information to the code corresponding to the spare area.
[0049] It should be noted that, in this application, "verification passed" indicates that the parameter data in the data backup area has completed cyclic redundancy check and word-by-word readback comparison and meets the consistency requirements; "current real-time clock" indicates the RTC timing unit of the transmission tower monitoring terminal used to provide the current running time; "second-level timestamp" indicates the time value recorded at the second granularity when the parameter writing is completed; "write timestamp" indicates the time mark written to the data backup area and used for subsequent active area determination; "preset timestamp storage location" indicates the fixed address location in the data backup area used to store the write timestamp; "word write" indicates the operation of writing the status field to the data backup area according to the FLASH word programming unit; "data backup area status flag set to valid" indicates that the parameter data in the data backup area is ready to participate in subsequent reading as a data active area; "data active area pointer information" indicates the FLASH control field information used to record the current valid parameter area position; "active area pointer" indicates the encoded value read from the data active area pointer information and used to point to the current valid parameter area; "data backup area corresponding encoding" indicates the parameter area encoding value used to point to the data backup area in the active area pointer.
[0050] In specific implementation, firstly, after the parameter data in the data backup area passes verification, the memory management task reads the second-level timestamp output by the current real-time clock and uses the read second-level timestamp as the write timestamp. Secondly, the memory management task writes the write timestamp to the preset timestamp storage location in the data backup area according to the terminal's preset time field storage order, and sets the data backup area with the completed timestamp writing as a valid target parameter area. Next, the memory management task performs word writing at the preset offset position in the data backup area, sets the area status flag of the data backup area to valid, and uses the data backup area with the completed valid flag writing as a new valid parameter area. Finally, the memory management task reads the code corresponding to the data backup area, updates the active area pointer in the data active area pointer information to the code corresponding to the data backup area, and uses the updated active area pointer as the basis for subsequent parameter reading and backup area selection.
[0051] It should be noted that, in this embodiment, the write timestamp can be the current second-level timestamp of the RTC. The preset timestamp storage location in the data spare area can be set to offset 0x004 in the data spare area, the storage length can be set to 4 bytes, and big-endian order is used for writing. The preset offset location of the data spare area can be set to offset 0x000 in the data spare area. The 4-byte word corresponding to this location includes the area status flag and the write source identifier. When the area status flag of the data spare area is set to valid, 0x02 can be written to indicate that the parameter data in the data spare area has been verified and can be used as a new active data area. The pointer information of the active data area can be the Ptr_active field in the INT parameter area. The Ptr_active field can be set to offset 0x000 in the INT parameter area. When the data spare area is the first parameter area, the code corresponding to the data spare area can be set to 0x01. When the data spare area is the second parameter area, the code corresponding to the data spare area can be set to 0x02.
[0052] In this embodiment, erasing the active data area and resuming the suspended processing task can be achieved through the following steps: Perform FLASH page erasure on the active data area and read the erasure status flag; When the erase status flag indicates that the erase was successful, the hot-swap is confirmed to be complete, and the active data area becomes the new data backup area; When the erase status flag indicates that the erase has failed, keep the zone status flag of the active data zone unchanged, increment the fault count and record the erase failure log. Resume suspended processing tasks after erasure is complete.
[0053] It should be noted that in this application, the active data area refers to the FLASH parameter area used to provide the current operating parameters before hot switching; FLASH page erasure refers to the operation of clearing the original stored content on a unit basis, based on the FLASH page where the parameter area is located; the erasure status flag indicates the error bit status returned by the FLASH controller after FLASH page erasure; hot switching completion indicates that the data spare area has become a new valid parameter area and the original active data area has completed the spare processing; the new data spare area refers to the subsequent spare write area obtained after the original active data area is successfully erased; the fault count refers to the count field used to record the number of FLASH erase, write, or verification exceptions; the erase failure log refers to the operation log used to record abnormal situations during the erasure of the active data area; and the suspended processing task refers to the terminal processing task that is temporarily suspended during hot switching to avoid preempting FLASH operations.
[0054] In practice, firstly, after the data spare area's zone status flag is set to valid and the active area pointer is updated to point to the data spare area, the memory management task performs a FLASH page erase on the original active data area and reads the erase status flag returned by the FLASH controller, using the erase status flag as the erase result of the original active data area. Secondly, when the erase status flag indicates successful erasure, the memory management task uses the successful erasure result of the original active data area as the hot-swap completion result and uses the original active data area as the new data spare area. Next, when the erase status flag indicates erase failure, the memory management task keeps the zone status flag of the original active data area unchanged, uses the accumulated fault count as an erase exception record, and records the erase failure log. Finally, after the data active area erase operation is completed, the memory management task resumes the suspended processing task through a task recovery operation, using the completion of the processing task recovery as the result of exiting the FLASH exclusive phase of the hot-swap process.
[0055] It should be noted that, in this embodiment, the active data area is the original parameter area that provides operating parameters before the active area pointer is updated; the erase status flag may include a write protection error bit and a programming error bit. When neither type of error bit is set, it is considered that the erase was successful; when either error bit is set, it is considered that the erase failed; when the erase fails, the area status flag of the original active data area remains valid, so that both the original active data area and the data spare area that has been written remain valid. After the terminal restarts, the parameter area with the larger write timestamp can be selected as the active data area by comparing the write timestamps; the fault count can be accumulated using the Fault_cnt field in the INT parameter area; the erase failure log can be written to the terminal's local log storage medium to retain the parameter area information and current time information corresponding to the erase failure; the suspended processing task can be a sensor acquisition processing task. Regardless of whether the active data area is erased successfully or fails, the processing task will be resumed through the task recovery operation after the erase operation is completed.
[0056] In this embodiment, updating the cache with parameter data from the data backup area and triggering version synchronization can be achieved through the following steps: Update the cache with the parameter data in the data standby area; Read the write source identifier and write timestamp from the current execution buffer; A parameter version number is generated based on the write timestamp and the write source identifier, and the parameter version number is written to the third parameter area of the FLASH. Set the synchronization flag in the third parameter area to valid, and clear the retry synchronization count in the third parameter area to zero; Version update events are sent to network tasks via an event notification mechanism, and the network tasks then execute the version synchronization process.
[0057] It should be noted that, in this application, the cache refers to the SRAM parameter cache used by various functional modules of the transmission tower monitoring terminal to read parameter data; the parameter data in the data spare area refers to parameter data that has passed write verification and can be used as currently valid parameters; the write timestamp refers to the time stamp recorded by the current real-time clock when the parameter data is written; the write source identifier refers to the identifier field used to distinguish the source of the parameter write request; the parameter version number refers to the parameter update version record generated based on the write timestamp and the write source identifier; the third parameter area refers to the parameter area in FLASH used to store version synchronization related control fields; the synchronization flag refers to the persistent flag used to instruct the network task to execute the version synchronization process; the retry synchronization count refers to the count field used to record the number of retries of the version synchronization message; the event notification mechanism refers to the notification method that triggers the subsequent processing process through inter-task events; and the version update event refers to the event that notifies the network task to read the parameter version number and execute the version synchronization process.
[0058] In specific implementation, firstly, after the data active area erasure operation is completed, the memory management task reads the verified parameter data from the data spare area and writes the read parameter data into the cache. The updated cache is then used as the cache for subsequent parameter data reading by the transmission tower monitoring terminal during operation. Secondly, the memory management task reads the write timestamp and write source identifier from the current execution buffer, generates a parameter version number according to a preset version number combination method, and writes the parameter version number into the third parameter area of the FLASH. The written parameter version number is used as the version record for this parameter hot switch. Next, the memory management task sets the synchronization flag in the third parameter area to valid and clears the retry synchronization count in the third parameter area. The result of valid synchronization flag and cleared retry synchronization count is used as the trigger state of the version synchronization process. Finally, the memory management task sends a version update event to the network task through an event notification mechanism. The network task reads the synchronization flag and parameter version number in the third parameter area and executes the version synchronization process when the MQTT channel meets the sending conditions. The execution result of the version synchronization process is used as the result of this parameter version release.
[0059] It should be noted that, in this embodiment, the cache can be an SRAM parameter cache, and the cache update content is the parameter data body that has passed verification in the data spare area; the third parameter area can be the INT parameter area in FLASH, the synchronization flag in the third parameter area can be set at offset 0x012 in the INT parameter area, the parameter version number can be set at offset 0x013 in the INT parameter area, and the retry synchronization count can be set at offset 0x018 in the INT parameter area; the parameter version number can be obtained by concatenating the four big-endian bytes of the written timestamp and the one byte of the written source identifier to form a five-byte version field; when the synchronization flag is set to valid, 0x01 can be written, and when the retry synchronization count is cleared, 0x00 can be written; the event notification mechanism can be the EVENT_SYNC event. After receiving the EVENT_SYNC event, the network task reads the synchronization flag. If the synchronization flag is valid, it reads the parameter version number, the retry synchronization count, and the version synchronization failure count, and sends a version synchronization message to the operation and maintenance platform when the MQTT channel status meets the sending conditions.
[0060] Therefore, this application demonstrates that the cache can be updated with parameter data from the data backup area, triggering version synchronization. Firstly, by reading the status flags, correcting their validity, and determining the active area in the FLASH memory of the transmission tower monitoring terminal, and loading the parameter data from the active area into the cache, a valid parameter baseline can be established before parameter updates. This ensures the terminal prioritizes reading parameters from the data area with a clear status that can serve as the basis for current operation, avoiding the impact of invalid status flags caused by power outages or abnormal writes on parameter loading after terminal restart. Secondly, by setting the battery voltage not lower than a preset voltage threshold, the processing task being in a blocked state, and the MQTT channel being connected as valid preconditions for write readiness, parameter writing can be restricted to an operating window where power supply conditions are met, task preemption risk is low, and the communication link has synchronization capabilities. This reduces low-voltage programming failures, interrupted writing of data acquisition tasks, and the inability to synchronize versions in a timely manner after writing. The problem is that, upon receiving a parameter write request and confirming the write-ready flag, the system determines the data backup area based on the data active area's pointer information. After suspending the current processing task, it reconfirms the write-ready flag, avoiding direct overwriting of the currently valid parameter area. This allows the backup area to handle the erasure, write, and verification operations during the new parameter write process. Simultaneously, task suspension and secondary confirmation reduce the impact of runtime status changes on FLASH write integrity. Finally, after successful verification, the system writes a timestamp, sets a valid status flag, updates the active area pointer, erases the original data active area, resumes the suspended processing task, updates the cache, and triggers version synchronization. This ensures that the newly written parameters only take over the terminal's runtime configuration after verification, and that cached parameters and remote version status are updated accordingly. This reduces the risk of data corruption, version inconsistencies, and runtime interruptions during parameter updates in unattended outdoor scenarios, improving the integrity and continuous operation of the terminal parameter update process.
[0061] In summary, the technical solution adopted in this application can realize the safe hot-switching configuration of parameters under the constraints of the operating status of the transmission tower monitoring terminal.
[0062] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0063] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-Erasable Programmable Read-Only Memory (EEPROM), compactdisc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.
[0064] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
Claims
1. A method for hot-switching configuration of parameters for a transmission tower monitoring terminal, characterized in that, Includes the following steps: The status flags in the FLASH of the transmission tower monitoring terminal are read and validity is corrected. The active area of the FLASH is determined to obtain the data active area, and the parameter data in the data active area is loaded into the cache. When the battery voltage of the transmission tower monitoring terminal is not lower than the preset voltage threshold, the processing task is in a blocked state, and the MQTT channel status is connected, the write ready flag will be set to valid. When a parameter write request is received and the write ready flag is valid, the data spare area is determined based on the data active area pointer information. The current processing task is suspended, and the write ready flag is confirmed to be valid again after suspension. After confirmation, the data spare area is erased, written, and verified. After successful verification, the current timestamp is written to the data backup area and the status flag of the data backup area is set to valid. The pointer information of the data active area is updated to point to the data backup area. The data active area is erased, the suspended processing tasks are resumed, the cache is updated with the parameter data of the data backup area, and version synchronization is triggered.
2. The method for hot-switching configuration of transmission tower monitoring terminal parameters as described in claim 1, characterized in that, The specific steps for reading and correcting the status flags in the FLASH memory of the transmission tower monitoring terminal include: Read the word data at the preset offset positions of the first and second parameter areas of the FLASH in the transmission tower monitoring terminal, and extract the area status flag from the word data; The validity of the zone status flags of the first parameter zone and the second parameter zone is checked. If the zone status flag is not within the preset valid value range, the zone status flag is forcibly set to the first preset value. Words are written to the preset offset positions of the first parameter area and the second parameter area, respectively.
3. The method for hot-switching configuration of transmission tower monitoring terminal parameters as described in claim 1, characterized in that, The process of determining the active area of the FLASH memory, identifying the active data area, and loading the parameter data from the active data area into the cache specifically includes: When the status flag of the first parameter area of the FLASH is the second preset value and the status flag of the second parameter area of the FLASH is not the second preset value, the first parameter area is determined to be the data active area, and the FLASH page is erased in the second parameter area. When the status flag of the second parameter area of the FLASH is the second preset value and the status flag of the first parameter area of the FLASH is not the second preset value, the second parameter area is determined to be the data active area, and the FLASH page is erased on the first parameter area. When the status flags of the first parameter area and the second parameter area of the FLASH are both the second preset value, the write timestamp of the first parameter area and the write timestamp of the second parameter area are read, the area with the larger write timestamp is determined as the data active area, and the FLASH page is erased for the inactive area. When the status flags of the first parameter area and the second parameter area of the FLASH are not both the second preset value, the factory default parameter restoration procedure is executed. Perform cyclic redundancy check on the parameter data starting from a preset offset position in the data active area; After the cyclic redundancy check passes, the parameter data starting from the preset offset position in the data active area is read back character by character, and the read-back value is compared character by character with the data used during the cyclic redundancy check. After the character-by-character comparison is successful, all parameter data starting from the preset offset position in the active data area is copied to the cache.
4. The method for hot-switching configuration of transmission tower monitoring terminal parameters as described in claim 1, characterized in that, When the battery voltage of the transmission tower monitoring terminal is not lower than the preset voltage threshold, the processing task is in a blocked state, and the MQTT channel status is connected, the write ready flag will be set to valid. Specifically, this includes: When the battery voltage value of the transmission tower monitoring terminal is not lower than the preset voltage threshold, the voltage normal flag is set to valid; when the battery voltage value is lower than the preset voltage threshold, the voltage normal flag is set to invalid. When the processing task of the transmission tower monitoring terminal is in a blocked state, the current value of the idle flag is used as the acquisition window state. When the processing task is in a suspended or deleted state, the acquisition window state is forcibly set to valid. Query the running status of network tasks. When a network task is in a blocked state, use the state maintained by the network task as the MQTT channel status. When a network task is in a suspended or deleted state, force the MQTT channel status to be valid. Read the voltage normal flag, the acquisition window status, and the MQTT channel status. When all three are valid, set the write ready flag to valid. When any one of the three is invalid, set the write ready flag to invalid.
5. The method for hot-switching configuration of transmission tower monitoring terminal parameters as described in claim 1, characterized in that, Upon receiving a parameter write request and with the write-ready flag valid, the specific data spare area is determined based on the data active area pointer information, including: When a parameter write request is received and the write ready flag is valid, the pointer information of the active data area is read, and the active area pointer is obtained from the pointer information. When the active area pointer is the first code, the second parameter area of the FLASH is determined as the data spare area; When the active area pointer is the second code, the first parameter area of the FLASH is determined as the data spare area; When the active area pointer is other than a certain value, the area status flags of the first and second parameter areas of the FLASH are reread, the data active area is re-determined based on the area status flags, and the inactive area is determined as the data spare area.
6. The method for hot-switching configuration of transmission tower monitoring terminal parameters as described in claim 1, characterized in that, Suspend the current processing task and, after suspension, reconfirm that the write-ready flag is valid. After confirmation, erase, write, and verify the data spare area, specifically including: After suspending the processing task, read the write ready flag again, and after confirming that the write ready flag is valid, perform FLASH page erasure on the data spare area; Read the erase status flag of the FLASH page eraser, and after confirming that there are no error bits in the erase status flag, write the parameter data in the current execution buffer into the data spare area; Perform cyclic redundancy check calculation on the parameter data starting from the preset offset position in the data spare area, and write the check calculation result into the preset check value storage location in the data spare area; The parameter data starting from the preset offset position in the data spare area is read back word by word, and the cyclic redundancy check value is recalculated and recorded as the read-back check value. At the same time, the check value stored in the preset check value storage position in the data spare area is read and recorded as the flash check value. The readback check value is compared with the check calculation result, the readback check value is compared with the flash memory check value, and all word-by-word readback values are compared word-by-word with the parameter data in the current execution buffer.
7. The method for hot-switching configuration of transmission tower monitoring terminal parameters as described in claim 6, characterized in that, Perform cyclic redundancy check calculations on the parameter data starting from a preset offset position in the data spare area, and write the check calculation results to the preset check value storage location in the data spare area. Specifically, this includes: Read the parameter data that has been written to the data spare area starting from the preset offset position; Perform a write consistency check on the parameter data to obtain the write consistency check result; When the write consistency check result is passed, the parameter data is subjected to cyclic redundancy check calculation, the check calculation result is obtained and written to the preset check value storage location in the data spare area.
8. The method for hot-switching configuration of transmission tower monitoring terminal parameters as described in claim 1, characterized in that, After successful verification, the current timestamp is written to the data backup area, the status flag of the data backup area is set to valid, and the pointing information of the data active area is updated to point to the data backup area. Specifically, this includes: After the verification is successful, the second-level timestamp of the current real-time clock is read as the write timestamp; Write the timestamp to the preset timestamp storage location in the data spare area; Perform word writing at the preset offset position of the data spare area and set the area status flag of the data spare area to valid; Update the active area pointer in the active area pointer information to the code corresponding to the spare area.
9. The method for hot-switching configuration of transmission tower monitoring terminal parameters as described in claim 1, characterized in that, Erasing the active data area and resuming suspended processing tasks specifically includes: Perform FLASH page erasure on the active data area and read the erasure status flag; When the erase status flag indicates that the erase was successful, the hot-swap is confirmed to be complete, and the active data area becomes the new data backup area; When the erase status flag indicates that the erase has failed, keep the zone status flag of the active data zone unchanged, increment the fault count and record the erase failure log. Resume suspended processing tasks after erasure is complete.
10. The method for hot-switching configuration of transmission tower monitoring terminal parameters as described in claim 1, characterized in that, Updating the cache to the parameter data in the data standby area and triggering version synchronization specifically includes: Update the cache with the parameter data in the data standby area; Read the write source identifier and write timestamp from the current execution buffer; A parameter version number is generated based on the write timestamp and the write source identifier, and the parameter version number is written to the third parameter area of the FLASH. Set the synchronization flag in the third parameter area to valid, and clear the retry synchronization count in the third parameter area to zero; Version update events are sent to network tasks via an event notification mechanism, and the network tasks then execute the version synchronization process.
