A device upgrading method and apparatus, an electronic device, and a storage medium
By determining the optimal baud rate and data frame length before upgrading RS485 communication equipment, the problem of low upgrade efficiency of RS485 communication equipment is solved, and more efficient program upgrade is achieved.
Patent Information
- Application Number
- CN202310749102.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-21
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2043-06-21
AI Technical Summary
During the program upgrade process, devices using RS485 communication experience shorter program upgrade file data packets due to the lower communication baud rate, resulting in longer upgrade times and reduced upgrade efficiency.
Before upgrading the equipment, conduct communication quality tests to determine the optimal target baud rate and target data frame length, and use this target baud rate and target data frame length to send program upgrade segments during the formal equipment upgrade process.
It improves communication efficiency and data transmission reliability during equipment upgrades, and increases program upgrade efficiency.
Smart Images

Figure CN116781211B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of equipment, in particular to an equipment upgrading method and device, an electronic equipment and a storage medium. BACKGROUND
[0002] RS485 communication is widely used in various industrial equipment due to its simple interface and protocol, long communication distance, strong anti-interference, and less communication wire. The engineering environment of the equipment varies, for example, noise reasons, performance reasons, etc., which require program updating of the equipment program, or due to the bug in the controller program when the equipment is shipped, the program needs to be updated to correct the bug, thus there is a need to upgrade the program of the equipment.
[0003] For equipment using RS485 communication, long-distance communication of the equipment needs to be considered, and the communication data frame is usually short. For example, the baud rate of the air conditioning equipment network using RS485 communication is usually low, mostly about 9600bps.
[0004] For the above, the program upgrade of the equipment using RS485 communication will face the following problems: due to the low communication baud rate, the length of the program upgrade file data packet sent at a time is short, which will lengthen the program upgrade time and reduce the program upgrade efficiency. SUMMARY
[0005] The present application provides an equipment upgrading method and device, an electronic equipment and a storage medium to solve the problem of low program upgrade efficiency.
[0006] In a first aspect, the present application provides an equipment upgrading method, which comprises:
[0007] obtaining multiple candidate baud rates and multiple candidate data frame lengths of test data;
[0008] determining an optimal test scheme according to the candidate baud rates and the candidate data frame lengths according to a preset communication quality test strategy, wherein the product value of the target baud rate and the target data frame length of the test data in the optimal test scheme is maximum;
[0009] sending a program upgrade segment to the equipment to be upgraded at the target baud rate and the target data frame length.
[0010] Further, the determining of the optimal test scheme according to the candidate baud rates and the candidate data frame lengths according to the preset communication quality test strategy comprises:
[0011] determining an ordered sequence according to the candidate baud rates and the candidate data frame lengths, wherein each data in the ordered sequence is a baud rate-data frame length combination, and each baud rate-data frame length combination is arranged in order according to a product value of a corresponding candidate baud rate and a candidate data frame length;
[0012] selecting a middle baud rate-data frame length combination in the middle of the ordered sequence;
[0013] sending test data to the device to be upgraded according to the middle baud rate-data frame length combination;
[0014] if the response information sent by the device to be upgraded is received, then determining a neighboring baud rate-data frame length combination of the middle baud rate-data frame length combination in an ascending order of the ordered sequence;
[0015] sending test data to the device to be upgraded according to the neighboring baud rate-data frame length combination;
[0016] if the response information sent by the device to be upgraded is received, then sending test data according to a next neighboring baud rate-data frame length combination in the ascending order until the response information is not received, wherein the baud rate-data frame length combination corresponding to the last response information is the optimal test scheme.
[0017] Further, after sending test data to the device to be upgraded according to the middle baud rate-data frame length combination, or after sending test data to the device to be upgraded according to the neighboring baud rate-data frame length combination, the method further comprises:
[0018] if the response information sent by the device to be upgraded is not received, then determining a descending order of the ordered sequence;
[0019] selecting a neighboring baud rate-data frame length combination from the middle baud rate-data frame length combination in the descending order to send test data;
[0020] if the response information sent by the device to be upgraded is not received, then sending test data according to a next neighboring baud rate-data frame length combination in the descending order until the response information is received, wherein the baud rate-data frame length combination corresponding to the response information is the optimal test scheme.
[0021] Further, determining an ordered sequence according to the candidate baud rates and the candidate data frame lengths comprises:
[0022] determining an ascending order sequence according to the candidate baud rates from low to high and the candidate data frame lengths corresponding to the same candidate baud rate from short to long; or,
[0023] determining a descending sequence according to the order of the candidate baud rates from high to low and the candidate data frame lengths corresponding to the same candidate baud rate from long to short.
[0024] Further, the determining the optimal test scheme according to the candidate baud rates and the candidate data frame lengths according to the preset communication quality test strategy comprises:
[0025] determining an ascending sequence according to the order of the candidate baud rates from low to high and the candidate data frame lengths corresponding to the same candidate baud rate from short to long, wherein each data in the ascending sequence is a baud rate-data frame length combination;
[0026] sending test data to the device to be upgraded according to the first baud rate-data frame length combination in the ascending sequence;
[0027] if the reply information sent by the device to be upgraded is received, sending test data to the device to be upgraded according to the next baud rate-data frame length combination, wherein the baud rate-data frame length combination corresponding to the last reply information is the optimal test scheme.
[0028] Further, before the determining the optimal test scheme according to the candidate baud rates and the candidate data frame lengths according to the preset communication quality test strategy, the method further comprises:
[0029] obtaining an initial baud rate of the device to be upgraded, wherein the initial baud rate is different from the candidate baud rate;
[0030] sending a data frame to the device to be upgraded according to the initial baud rate;
[0031] if the reply information fed back by the device to be upgraded is received within a preset time length, switching the initial baud rate to the candidate baud rate.
[0032] Further, the device to be upgraded comprises at least one sub-device of the same device type, and after the sending of the program upgrade fragment to the device to be upgraded according to the target baud rate and the target data frame length, the method further comprises:
[0033] if the upgrade confirmation information fed back by all the sub-devices is not received, resending the program upgrade fragment according to the target baud rate and the target data frame length;
[0034] if the upgrade confirmation information fed back by all the sub-devices is received, sending the next program upgrade fragment according to the target baud rate and the target data frame length.
[0035] In a second aspect, a device upgrading apparatus is provided, and the apparatus comprises:
[0036] an obtaining module, configured to obtain a plurality of candidate baud rates and a plurality of candidate data frame lengths of test data;
[0037] a determining module, configured to determine an optimal test scheme according to the candidate baud rates and the candidate data frame lengths according to a preset communication quality test strategy, wherein a product value of a target baud rate and a target data frame length of test data in the optimal test scheme is maximum;
[0038] a sending module, configured to send a program upgrade fragment to a device to be upgraded at the target baud rate and the target data frame length.
[0039] In a third aspect, the present application provides a device upgrade terminal / device / server, comprising: at least one communication interface; at least one bus connected with the at least one communication interface; at least one processor connected with the at least one bus; and at least one memory connected with the at least one bus, wherein the processor is configured to:
[0040] obtain a plurality of candidate baud rates and a plurality of candidate data frame lengths of test data;
[0041] determine an optimal test scheme according to the candidate baud rates and the candidate data frame lengths according to a preset communication quality test strategy, wherein a product value of a target baud rate and a target data frame length of test data in the optimal test scheme is maximum;
[0042] send a program upgrade fragment to a device to be upgraded at the target baud rate and the target data frame length.
[0043] Further, the determining an optimal test scheme according to the candidate baud rates and the candidate data frame lengths according to a preset communication quality test strategy comprises:
[0044] determining an ordered sequence according to the candidate baud rates and the candidate data frame lengths, wherein each data in the ordered sequence is a baud rate-data frame length combination, and each baud rate-data frame length combination is arranged in order according to a product value of a corresponding candidate baud rate and candidate data frame length;
[0045] selecting a middle baud rate-data frame length combination located in a middle position in the ordered sequence;
[0046] sending test data to the device to be upgraded according to the middle baud rate-data frame length combination;
[0047] if receiving response information sent by the device to be upgraded, determining a neighboring baud rate-data frame length combination of the middle baud rate-data frame length combination in an ascending order direction of the ordered sequence;
[0048] sending test data to the device to be upgraded according to the adjacent baud rate-data frame length combination in the ascending order until the response information is received, wherein the baud rate-data frame length combination corresponding to the last response information is the optimal test scheme.
[0049] If the response information sent by the device to be upgraded is received, test data is sent according to the next adjacent baud rate-data frame length combination in the ascending order until the response information is not received, wherein the baud rate-data frame length combination corresponding to the last response information is the optimal test scheme.
[0050] Further, after sending test data to the device to be upgraded according to the intermediate baud rate-data frame length combination, or after sending test data to the device to be upgraded according to the adjacent baud rate-data frame length combination, the method further comprises:
[0051] If the response information sent by the device to be upgraded is not received, the descending order of the ordered sequence is determined.
[0052] Adjacent baud rate-data frame length combinations are selected to send test data in the descending order from the intermediate baud rate-data frame length combination.
[0053] If the response information sent by the device to be upgraded is not received, test data is sent according to the next adjacent baud rate-data frame length combination in the descending order until the response information is received, wherein the baud rate-data frame length combination corresponding to the response information is the optimal test scheme.
[0054] Further, determining an ordered sequence according to the candidate baud rate and the candidate data frame length comprises:
[0055] An ascending order sequence is determined according to the order of candidate baud rates from low to high and the order of candidate data frame lengths corresponding to the same candidate baud rate from short to long; or,
[0056] A descending order sequence is determined according to the order of candidate baud rates from high to low and the order of candidate data frame lengths corresponding to the same candidate baud rate from long to short.
[0057] Further, determining the optimal test scheme according to the candidate baud rate and the candidate data frame length according to the preset communication quality test strategy comprises:
[0058] An ascending order sequence is determined according to the order of candidate baud rates from low to high and the order of candidate data frame lengths corresponding to the same candidate baud rate from short to long, wherein each data in the ascending order sequence is a baud rate-data frame length combination.
[0059] Test data is sent to the device to be upgraded according to the first baud rate-data frame length combination in the ascending order sequence.
[0060] If the response information sent by the device to be upgraded is received, test data is sent to the device to be upgraded according to a next baud rate-data frame length combination, wherein the baud rate-data frame length combination corresponding to the last response information is the optimal test scheme.
[0061] Further, before determining the optimal test scheme according to the candidate baud rate and the candidate data frame length according to the preset communication quality test strategy, the method further comprises:
[0062] acquiring an initial baud rate of the device to be upgraded, wherein the initial baud rate is different from the candidate baud rate;
[0063] sending a data frame to the device to be upgraded according to the initial baud rate;
[0064] If the reply information fed back by the device to be upgraded is received within a preset time length, the initial baud rate is switched to the candidate baud rate.
[0065] Further, the device to be upgraded comprises at least one sub-device of the same device type, and after the program upgrade fragment is sent to the device to be upgraded according to the target baud rate and the target data frame length, the method further comprises:
[0066] If the upgrade confirmation information fed back by all the sub-devices is not received, the program upgrade fragment is re-sent according to the target baud rate and the target data frame length;
[0067] If the upgrade confirmation information fed back by all the sub-devices is received, the next program upgrade fragment is sent according to the target baud rate and the target data frame length.
[0068] In a third aspect, the present application also provides an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus; the memory is used for storing a computer program; and the processor is used for executing the program stored in the memory to implement the method described above.
[0069] In a fourth aspect, the present application also provides a computer storage medium storing computer executable instructions, wherein the computer executable instructions are used for executing the device upgrade method described above.
[0070] Compared with the prior art, the technical scheme provided by the embodiment of the present application has the following advantages: the communication quality is tested before the device is upgraded, the optimal target baud rate and target data frame length are determined, and during the formal device upgrading process, the program upgrade segment is sent by using the target baud rate and target data frame length, so that the communication efficiency and data transmission reliability are considered during the device upgrading process, and the program upgrading efficiency is improved. BRIEF DESCRIPTION OF DRAWINGS
[0071] The drawings incorporated into the specification and forming a part thereof, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the application.
[0072] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced as follows, and obviously, other drawings can also be obtained by those skilled in the art without any creative effort on the basis of these drawings.
[0073] One or more embodiments are exemplarily illustrated by the pictures in the drawings corresponding thereto, and these exemplary illustrations do not constitute a limitation on the embodiments, and the elements with the same reference numerals in the drawings represent similar elements, unless otherwise specified, and the drawings do not constitute a proportional limitation.
[0074] Figure 1 A device upgrading method flowchart is provided for the embodiments of the present application.
[0075] Figure 2 An RS485 communication unit network diagram of an air conditioning device is provided for the embodiments of the present application.
[0076] Figure 3 A program upgrading efficiency improvement flowchart of an RS485 communication air conditioning unit is provided for the embodiments of the present application.
[0077] Figure 4 A device upgrading apparatus structure diagram is provided for the embodiments of the present application.
[0078] Figure 5 An electronic device structure diagram is provided for the embodiments of the present application. DETAILED DESCRIPTION
[0079] In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0080] The following disclosure provides many different embodiments or examples for implementing different structures of the present application. For the purpose of simplifying the present application, the components and settings of specific examples are described in the following. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeatedly refer to numbers and / or letters in different examples. Such repetition is for the purpose of simplification and clarity, and does not indicate the relationship between the various embodiments and / or settings discussed.
[0081] The present application provides a device upgrading method, which is applied to a program upgrading device, such as Figure 1 As shown in the figure, the method comprises:
[0082] Step 101: Obtain multiple candidate baud rates of test data and multiple candidate data frame lengths.
[0083] There is only one master device in the communication network of the RS485 communication unit, and the program upgrading device is only connected when the unit has a program upgrading demand, and the connection is as a slave device. Figure 2 The schematic diagram of the RS485 communication unit network of the air conditioning device is shown, in which the line controller or outdoor unit is the master device.
[0084] When it is necessary to solve the problem by upgrading the program of the device to be upgraded, the technician will store the upgrading program file into the program upgrading device, which can be the program file of a certain type of device to be upgraded, or the program file of multiple types of devices to be upgraded.
[0085] The program upgrading device is connected to the RS485 communication network through communication, obtains the communication parameters of the communication network, including baud rate, polarity, etc. The upgrading tool sends the program upgrading instruction to the RS485 communication network according to the device type of the device to be upgraded, and the device to be upgraded of the device type will feedback its own device address to the RS485 communication network, so as to facilitate the program upgrading device to accurately send the test data and program upgrading segment according to the device address in the future. The program upgrading device selects the upgrading program file required by the device to be upgraded according to the device type of the device to be upgraded.
[0086] The to-be-upgraded device is a controller with an IAP (In Application Programming) function, and the program thereof is composed of two parts, namely, a bootloader and an application part program. The bootloader is a boot loader, controls initialization operation after chip reset, provides a function of programming a Flash memory, and the boot code can reprogram a chip that has been programmed in advance. The application part program implements specific logical functions of the controller.
[0087] The test data needs to be sent at a certain baud rate and a certain data frame length. The program upgrading device first acquires multiple candidate baud rates and multiple candidate data frame lengths of the test data.
[0088] Step 102: According to a preset communication quality test strategy, the optimal test scheme is determined according to the candidate baud rates and the candidate data frame lengths.
[0089] The product of the target baud rate and the target data frame length of the test data in the optimal test scheme is the maximum.
[0090] The program upgrading device determines the target baud rate and the target data frame length according to the preset communication quality test strategy. Among all the candidate baud rates and the candidate data frame lengths, the product of the target baud rate and the target data frame length is the maximum. In this way, the communication efficiency and the data transmission reliability can be considered at the same time.
[0091] Step 103: The program upgrading segment is sent to the to-be-upgraded device at the target baud rate and the target data frame length.
[0092] In the actual program upgrading process, the program upgrading device sends the program upgrading segment to the to-be-upgraded device at the target baud rate and the target data frame length.
[0093] In the present application, the communication quality is tested before the device is upgraded, and the optimal target baud rate and the target data frame length are determined. In the formal device upgrading process, the program upgrading segment is sent at the target baud rate and the target data frame length, so that the communication efficiency and the data transmission reliability can be considered at the same time in the device upgrading process, and the program upgrading efficiency is improved.
[0094] The entire process of the present application is between the program upgrading device and the to-be-upgraded device, and does not need to connect to the Internet and a server, and is particularly suitable for program upgrading of a single-chip microcomputer chip with limited chip resources.
[0095] According to the preset communication quality test strategy, the optimal test scheme is determined according to the candidate baud rates and the candidate data frame lengths, including at least three embodiments.
[0096] For the first embodiment:
[0097] The program upgrading device determines a baud rate-data frame length combination according to the selected baud rate and the selected data frame length. For example, there are three selected baud rates: baudrate1, baudrate2, baudrate3, and three selected data frame lengths: L1, L2, L3, so there are nine baud rate-data frame length combinations: baudrate1-L1, baudrate1-L2, baudrate1-L3, baudrate2-L1, baudrate2-L2, baudrate2-L3, baudrate3-L1, baudrate3-L2, baudrate3-L3.
[0098] Due to the characteristics of the program address space, L1-L3 are preferably multiples of 128, and can also be other values. Here, L1-L3 are the lengths of the data segments of the program file, and the actual data frame needs to add header code, address information, data frame length information, function code, frame code, and check information.
[0099] The program upgrading device sends test data to the device to be upgraded according to each baud rate-data frame length combination. If the response information from the device to be upgraded is received, the product value of the baud rate and the data frame length in the baud rate-data frame length combination corresponding to the response information is selected as the target baud rate and the target data frame length.
[0100] For each baud rate-data frame length combination, n (n>=3) times of test data are sent to the device to be upgraded to improve the test accuracy. If the device to be upgraded does not receive the response information, the baud rate-data frame length combination is directly cancelled.
[0101] For the second embodiment:
[0102] The program upgrading device determines an ordered sequence according to the selected baud rate and the selected data frame length. Each data in the ordered sequence is a baud rate-data frame length combination, and each baud rate-data frame length combination is arranged in order according to the product value of the corresponding selected baud rate and selected data frame length.
[0103] The ordered sequence includes an ascending sequence or a descending sequence. The ascending sequence is determined in order according to the selected baud rate from low to high and the data frame length corresponding to the selected baud rate from short to long. The descending sequence is determined in order according to the selected baud rate from high to low and the data frame length corresponding to the selected baud rate from long to short.
[0104] The program upgrading device selects a middle baud rate-data frame length combination in the ordered sequence, and determines the target baud rate and the target data frame length based on the middle baud rate-data frame length combination.
[0105] If the ordered sequence contains an odd number of combinations, the middle position is the middle baud rate-data frame length combination; if the ordered sequence contains an even number of combinations, any one of the combinations near the middle position is the middle baud rate-data frame length combination.
[0106] Specifically, the program upgrading device sends test data to the device to be upgraded according to the middle baud rate-data frame length combination. For one case, if the program upgrading device does not receive the response information sent by the device to be upgraded, it indicates that the product value of the baud rate and the data frame length in the middle baud rate-data frame length combination is too large, and thus the product value needs to be reduced. Therefore, the program upgrading device selects the adjacent baud rate-data frame length combination of the middle baud rate-data frame length combination in the descending order of the ordered sequence to send test data. If the response information is still not received, the next baud rate-data frame length combination is selected in the descending order to send test data, until the response information is received. Then, the baud rate-data frame length combination corresponding to the response information is the target baud rate and the target data frame length, i.e., the optimal test scheme.
[0107] For another case, if the program upgrading device receives the response information sent by the device to be upgraded, it indicates that the device to be upgraded can use the baud rate-data frame length combination, and the product value of the baud rate and the data frame length can be further increased to achieve better communication efficiency and data transmission reliability. Therefore, the program upgrading device continues to send test data according to the next adjacent baud rate-data frame length combination in the ascending order of the ordered sequence, until the response information is not received. Then, the baud rate-data frame length combination corresponding to the last response information is the optimal test scheme.
[0108] For a third embodiment:
[0109] The program upgrading device determines an ascending sequence according to the order of the low-to-high baud rate, and the short-to-long data frame length corresponding to the same baud rate, wherein each data in the ascending sequence is a baud rate-data frame length combination. The program upgrading device sends test data to the device to be upgraded according to the first baud rate-data frame length combination in the ascending sequence. If the program upgrading device receives the response information sent by the device to be upgraded, it indicates that the product value of the baud rate and the data frame length can be further increased. Therefore, test data is sent to the device to be upgraded according to the next baud rate-data frame length combination. The baud rate-data frame length combination corresponding to the last response information is the optimal test scheme.
[0110] Compared with the first embodiment, the second and third embodiments can only need to send test data according to part of the baud rate-data frame length combinations to determine the optimal test scheme, thereby improving the efficiency of determining the optimal test scheme.
[0111] As an optional implementation, before determining the optimal test scheme according to the selected baud rate and the selected data frame length according to the preset communication quality test strategy, the method further includes: obtaining an initial baud rate of the device to be upgraded, wherein the initial baud rate is different from the selected baud rate; sending a data frame to the device to be upgraded according to the initial baud rate; and if reply information fed back by the device to be upgraded is received within a preset time length, switching the initial baud rate to the selected baud rate.
[0112] When the baud rate changes, the program upgrade device needs to confirm according to the initial baud rate before sending the test data, and the initial baud rate can be the baud rate used by the device to be upgraded in daily work. For example, when the initial baud rate of the slave group is switched to baudrate1, the program upgrade device sends a baud rate data frame at the initial baud rate. After the program upgrade device sends the data frame, a certain time length is reserved to wait for the reply of the device to be upgraded. If the program upgrade device receives the reply information fed back by the device to be upgraded within the preset time length, it indicates that the device to be upgraded can normally communicate, and the initial baud rate is switched to the selected baud rate of the test data, and the communication quality test is started.
[0113] As an optional implementation, the device to be upgraded includes at least one sub-device of the same device type. After sending the program upgrade segment to the device to be upgraded at the target baud rate and the target data frame length, the method further includes: if the upgrade confirmation information fed back by all the sub-devices is not received, the program upgrade segment is re-sent at the target baud rate and the target data frame length; and if the upgrade confirmation information fed back by all the sub-devices is received, the next program upgrade segment is sent at the target baud rate and the target data frame length.
[0114] After the program upgrade device sends the program upgrade segment to the device to be upgraded at the target baud rate and the target data frame length, since the program upgrade segment is sent to multiple sub-devices of the same device type, if the program upgrade device does not receive the upgrade confirmation information fed back by all the sub-devices, it indicates that some sub-devices fail to upgrade, and the program upgrade segment needs to be re-sent at the target baud rate and the target data frame length.
[0115] The to-be-upgraded device receives all program upgrade files, checks for no errors, and then performs erasing, burning, checking, etc. The program upgrade device sends a device start running instruction according to the original machine group communication baud rate, the to-be-upgraded device runs according to the updated program, at this time the program upgrade device exits the master device role, and the original master device is switched from the slave device to the master device role to perform normal communication of the machine group.
[0116] Figure 3 A program upgrade efficiency improvement flowchart for an RS485 communication air conditioning unit.
[0117] Based on the same technical concept, the application further provides a device upgrading apparatus, such as Figure 4 The apparatus comprises:
[0118] The obtaining module 401 is configured to obtain multiple to-be-selected baud rates and multiple to-be-selected data frame lengths of test data.
[0119] The determining module 402 is configured to determine an optimal test scheme according to the to-be-selected baud rates and the to-be-selected data frame lengths according to a preset communication quality test strategy, wherein a product value of a target baud rate and a target data frame length of test data in the optimal test scheme is maximum.
[0120] The sending module 403 is configured to send a program upgrade segment to the to-be-upgraded device at the target baud rate and the target data frame length.
[0121] Further, the determining module 402 is configured to:
[0122] determine an ordered sequence according to the to-be-selected baud rates and the to-be-selected data frame lengths, wherein each data in the ordered sequence is a baud rate-data frame length combination, and each baud rate-data frame length combination is arranged in order according to a product value of a corresponding to-be-selected baud rate and to-be-selected data frame length.
[0123] select a middle baud rate-data frame length combination located at a middle position in the ordered sequence.
[0124] send test data to the to-be-upgraded device according to the middle baud rate-data frame length combination.
[0125] If the response information sent by the to-be-upgraded device is received, then adjacent baud rate-data frame length combinations of the middle baud rate-data frame length combination are determined in an ascending order direction of the ordered sequence.
[0126] send test data to the to-be-upgraded device according to the adjacent baud rate-data frame length combinations.
[0127] If the response information sent by the device to be upgraded is received, the test data is sent to the device to be upgraded according to the next adjacent baud rate-data frame length combination in the ascending order until the response information is not received, wherein the baud rate-data frame length combination corresponding to the last response information is the optimal test scheme.
[0128] Further, the apparatus is further configured to:
[0129] If the response information sent by the device to be upgraded is not received, the descending order sequence is determined.
[0130] The test data is sent to the device to be upgraded according to the adjacent baud rate-data frame length combination starting from the middle baud rate-data frame length combination in the descending order.
[0131] If the response information sent by the device to be upgraded is not received, the test data is sent to the device to be upgraded according to the next adjacent baud rate-data frame length combination in the descending order until the response information is received, wherein the baud rate-data frame length combination corresponding to the response information is the optimal test scheme.
[0132] Further, the determining module 402 is configured to:
[0133] determine an ascending sequence according to the order of the candidate baud rates from low to high and the candidate data frame lengths corresponding to the same candidate baud rate from short to long; or
[0134] determine a descending sequence according to the order of the candidate baud rates from high to low and the candidate data frame lengths corresponding to the same candidate baud rate from long to short.
[0135] Further, the determining module 402 is configured to:
[0136] determine the ascending sequence according to the order of the candidate baud rates from low to high and the candidate data frame lengths corresponding to the same candidate baud rate from short to long, wherein each data in the ascending sequence is a baud rate-data frame length combination.
[0137] send the test data to the device to be upgraded according to the first baud rate-data frame length combination in the ascending sequence.
[0138] If the response information sent by the device to be upgraded is received, the test data is sent to the device to be upgraded according to the next baud rate-data frame length combination, wherein the baud rate-data frame length combination corresponding to the last response information is the optimal test scheme.
[0139] Further, the apparatus is further configured to:
[0140] obtain the initial baud rate of the device to be upgraded, wherein the initial baud rate is different from the candidate baud rate.
[0141] sending a data frame to the device to be upgraded according to an initial baud rate;
[0142] If reply information fed back by the device to be upgraded is received within a preset time length, the initial baud rate is switched to a candidate baud rate.
[0143] Further, the device is also used for:
[0144] If all the upgrade confirmation information fed back by the sub-devices is not received, the program upgrade segment is re-sent according to the target baud rate and the target data frame length;
[0145] If all the upgrade confirmation information fed back by the sub-devices is received, the next program upgrade segment is sent according to the target baud rate and the target data frame length.
[0146] As shown in Figure 5 The embodiment of the present application provides an air conditioner control device, which comprises a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502 and the memory 503 complete mutual communication through the communication bus 504,
[0147] The memory 503 is used for storing a computer program;
[0148] In an embodiment of the present application, the processor 501 is used for executing the program stored in the memory 503, and the method for upgrading the device provided by any one of the preceding method embodiments is realized, comprising the following steps:
[0149] Obtaining multiple candidate baud rates and multiple candidate data frame lengths of test data;
[0150] According to a preset communication quality test strategy, determining an optimal test scheme according to the candidate baud rates and the candidate data frame lengths, wherein a product value of a target baud rate and a target data frame length in the optimal test scheme is maximum;
[0151] Sending a program upgrade segment to the device to be upgraded according to the target baud rate and the target data frame length.
[0152] Further, according to the preset communication quality test strategy, determining the optimal test scheme according to the candidate baud rates and the candidate data frame lengths comprises the following steps:
[0153] Determining an ordered sequence according to the candidate baud rates and the candidate data frame lengths, wherein each data in the ordered sequence is a baud rate-data frame length combination, and each baud rate-data frame length combination is arranged in order according to a product value of a corresponding candidate baud rate and a candidate data frame length;
[0154] Selecting a middle baud rate-data frame length combination located in a middle position in the ordered sequence;
[0155] sending test data to the device to be upgraded according to the intermediate baud rate-data frame length combination;
[0156] If the response information sent by the device to be upgraded is received, then the adjacent baud rate-data frame length combination of the intermediate baud rate-data frame length combination is determined in the ascending order of the ordered sequence;
[0157] sending test data to the device to be upgraded according to the adjacent baud rate-data frame length combination;
[0158] If the response information sent by the device to be upgraded is not received, then test data is sent according to the next adjacent baud rate-data frame length combination in the ascending order until the response information is received, wherein the baud rate-data frame length combination corresponding to the last response information is the optimal test scheme.
[0159] Further, after sending test data to the device to be upgraded according to the intermediate baud rate-data frame length combination, or after sending test data to the device to be upgraded according to the adjacent baud rate-data frame length combination, the method further comprises:
[0160] If the response information sent by the device to be upgraded is not received, then the descending order of the ordered sequence is determined;
[0161] The adjacent baud rate-data frame length combination is selected to send test data in the descending order starting from the intermediate baud rate-data frame length combination;
[0162] If the response information sent by the device to be upgraded is not received, then test data is sent according to the next adjacent baud rate-data frame length combination in the descending order until the response information is received, wherein the baud rate-data frame length combination corresponding to the response information is the optimal test scheme.
[0163] Further, determining an ordered sequence according to the candidate baud rate and the candidate data frame length comprises:
[0164] An ascending order sequence is determined according to the order of the candidate baud rate from low to high and the candidate data frame length corresponding to the same candidate baud rate from short to long; or,
[0165] A descending order sequence is determined according to the order of the candidate baud rate from high to low and the candidate data frame length corresponding to the same candidate baud rate from long to short.
[0166] Further, determining the optimal test scheme according to the candidate baud rate and the candidate data frame length according to the preset communication quality test strategy comprises:
[0167] determine the ascending sequence according to the order from low to high of the to-be-selected baud rate, and from short to long of the to-be-selected data frame length corresponding to the same to-be-selected baud rate, wherein each data in the ascending sequence is a baud rate-data frame length combination;
[0168] send the test data to the device to be upgraded according to the first baud rate-data frame length combination in the ascending sequence;
[0169] if the response information sent by the device to be upgraded is received, send the test data to the device to be upgraded according to the next baud rate-data frame length combination, wherein the baud rate-data frame length combination corresponding to the last response information is the optimal test scheme.
[0170] Further, according to the preset communication quality test strategy, before determining the optimal test scheme according to the to-be-selected baud rate and the to-be-selected data frame length, the method further comprises:
[0171] obtain the initial baud rate of the device to be upgraded, wherein the initial baud rate is different from the to-be-selected baud rate;
[0172] send a data frame to the device to be upgraded according to the initial baud rate;
[0173] if the reply information fed back by the device to be upgraded is received within a preset time length, switch the initial baud rate to the to-be-selected baud rate.
[0174] Further, the device to be upgraded comprises at least one sub-device of the same device type, and after sending the program upgrade fragment to the device to be upgraded according to the target baud rate and the target data frame length, the method further comprises:
[0175] if the upgrade confirmation information fed back by all the sub-devices is not received, resend the program upgrade fragment according to the target baud rate and the target data frame length;
[0176] if the upgrade confirmation information fed back by all the sub-devices is received, send the next program upgrade fragment according to the target baud rate and the target data frame length.
[0177] Embodiments of the present application also provide a computer readable storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement the steps of the device upgrading method provided by any one of the preceding method embodiments.
[0178] The device embodiments described above are only schematic, wherein the units shown as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple network units. According to actual needs, part or all of the modules can be selected to achieve the purpose of the embodiments.
[0179] Those skilled in the art can clearly understand the implementation of the embodiments by the description of the above embodiments. The embodiments can be implemented by means of software plus a general hardware platform, and of course, can also be implemented by hardware. Based on such understanding, the above technical solutions can be embodied in the form of a software product, and the computer software product can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, and the like, and includes a plurality of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments.
[0180] It is to be understood that the terminology used herein is for the purpose of describing particular example embodiments only and is not intended to be limiting. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. The terms "comprises", "comprising", "includes", "including" and "has", "having" are inclusive and therefore specify the presence of stated features, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, and / or groups thereof. The method steps, processes, and operations described herein are not to be construed as necessarily requiring their performance in the particular order in which they are described unless specifically indicated as such. It is also to be understood that additional or alternative steps can be employed.
[0181] The above description is merely that of specific embodiments of the present application, and thus is not intended to limit the present application. From the above description, one skilled in the art can clearly understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the generic principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the application. Accordingly, the present application is not to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for upgrading equipment, characterized in that, The method includes: Obtain multiple candidate baud rates and multiple candidate data frame lengths for the test data; According to the preset communication quality test strategy, the optimal test scheme is determined based on the candidate baud rate and the candidate data frame length, wherein the product of the target baud rate and the target data frame length of the test data is maximized in the optimal test scheme; The program upgrade fragment is sent to the device to be upgraded at the target baud rate and target data frame length; The step of determining the optimal test scheme according to the selected baud rate and the selected data frame length in accordance with the preset communication quality test strategy includes: An ordered sequence is determined based on the candidate baud rate and the candidate data frame length, wherein each data in the ordered sequence is a baud rate-data frame length combination, and each baud rate-data frame length combination is arranged in order according to the product of the corresponding candidate baud rate and candidate data frame length. Select the middle baud rate-data frame length combination located in the middle position of the ordered sequence; Test data is sent to the device to be upgraded according to the intermediate baud rate-data frame length combination; If a response message is received from the device to be upgraded, then the adjacent baud rate-data frame length combinations of the intermediate baud rate-data frame length combination are determined along the ascending direction of the ordered sequence. Test data is sent to the device to be upgraded according to the adjacent baud rate-data frame length combination; If a response message is received from the device to be upgraded, test data is sent along the ascending direction according to the next adjacent baud rate-data frame length combination until no response message is received. The baud rate-data frame length combination corresponding to the last response message is the optimal test scheme.
2. The method according to claim 1, characterized in that, After sending test data to the device to be upgraded according to the intermediate baud rate-data frame length combination, or after sending test data to the device to be upgraded according to the adjacent baud rate-data frame length combination, the method further includes: If no response is received from the device to be upgraded, the descending order of the ordered sequence is determined. Starting from the middle baud rate-data frame length combination and proceeding in descending order, select adjacent baud rate-data frame length combinations to send test data; If no response information is received from the device to be upgraded, test data is sent in the descending order according to the next adjacent baud rate-data frame length combination until a response information is received, wherein the baud rate-data frame length combination corresponding to the response information is the optimal test scheme.
3. The method according to claim 1, characterized in that, Before determining the optimal test scheme based on the candidate baud rate and the candidate data frame length according to the preset communication quality test strategy, the method further includes: Obtain the initial baud rate of the device to be upgraded, wherein the initial baud rate is different from the selected baud rate; Data frames are sent to the device to be upgraded at the initial baud rate. If a response is received from the device to be upgraded within a preset time period, the initial baud rate is switched to the candidate baud rate.
4. The method according to claim 1, characterized in that, The device to be upgraded includes at least one sub-device of the same device type. After sending the program upgrade fragment to the device to be upgraded at the target baud rate and target data frame length, the method further includes: If upgrade confirmation information is not received from all sub-devices, the program upgrade segment is resent according to the target baud rate and target data frame length. If upgrade confirmation information is received from all sub-devices, the next program upgrade segment is sent according to the target baud rate and target data frame length.
5. An equipment upgrade device, characterized in that, The device includes: The acquisition module is used to acquire multiple candidate baud rates and multiple candidate data frame lengths for the test data; The determination module is used to determine the optimal test scheme according to the candidate baud rate and the candidate data frame length in accordance with the preset communication quality test strategy, wherein the product of the target baud rate and the target data frame length of the test data is maximized in the optimal test scheme; The sending module is used to send the program upgrade fragment to the device to be upgraded at the target baud rate and target data frame length; The step of determining the optimal test scheme according to the selected baud rate and the selected data frame length in accordance with the preset communication quality test strategy includes: An ordered sequence is determined based on the candidate baud rate and the candidate data frame length, wherein each data in the ordered sequence is a baud rate-data frame length combination, and each baud rate-data frame length combination is arranged in order according to the product of the corresponding candidate baud rate and candidate data frame length. Select the middle baud rate-data frame length combination located in the middle position of the ordered sequence; Test data is sent to the device to be upgraded according to the intermediate baud rate-data frame length combination; If a response message is received from the device to be upgraded, then the adjacent baud rate-data frame length combinations of the intermediate baud rate-data frame length combination are determined along the ascending direction of the ordered sequence. Test data is sent to the device to be upgraded according to the adjacent baud rate-data frame length combination; If a response message is received from the device to be upgraded, test data is sent along the ascending direction according to the next adjacent baud rate-data frame length combination until no response message is received. The baud rate-data frame length combination corresponding to the last response message is the optimal test scheme.
6. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the method of any one of claims 1-4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method described in any one of claims 1-4.
Citation Information
Patent Citations
A device update, a debugger, a network device and a network system
CN108989103A
Automatic testing device and system for communication terminal of Internet of Things
CN213521918U