A 485 bus-based upgrading method, device, equipment and storage medium

CN116827783BActive Publication Date: 2026-08-11SHENZHEN FANHAI SANJIANG ELECTRONICS CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-22
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0005]升级失败后或者升级过程种断电,从机无法恢复

Benefits of technology

[0042]1、升级过程中待升级从机通过主机的多次轮询,可以将自身状态都正常上报给主机,不会影响其他从机的正常业务。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116827783B_ABST
    Figure CN116827783B_ABST
Patent Text Reader

Abstract

This invention relates to the field of computer technology and provides an upgrade method based on the 485 bus. The method includes: a host sending an upgrade preparation command to a slave device via broadcast; when the slave device to be upgraded has completed upgrade preparation, the host broadcasts an upgrade packet to the slave device; the slave device to be upgraded receives the upgrade packet and performs the upgrade; if the upgrade fails, it remains in the upgrade preparation completed state; the host obtains the upgrade result through polling and re-upgrades the slave device that failed the upgrade. This invention solves the problems of long cycles, low efficiency, and easy impact on other slave device services that do not need to be upgraded when using a one-to-one transmission method for upgrades by broadcasting the upgrade preparation command and upgrade packet and obtaining the slave device status through polling.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer technology, and in particular relates to an upgrade method, apparatus, device and storage medium based on the 485 bus. Background Technology

[0002] RS-485 bus communication is a master-slave based bus communication method. Traditional RS-485 communication, when upgrading the slave device, typically uses a one-to-one file transfer method, which is prone to the following problems:

[0003] During the upgrade process, the bus is occupied by the upgrade transmission task, and other slave devices on the bus cannot get communication time slices, which affects the service.

[0004] The upgrade process is lengthy, employing a one-to-one file transfer method. When upgrading multiple slave devices, the overall upgrade cycle is quite long.

[0005] If the upgrade fails or a power outage occurs during the upgrade process, the slave device cannot be restored. Summary of the Invention

[0006] The purpose of this invention is to provide an upgrade method, apparatus, device, and storage medium based on the 485 bus, aiming to solve the following problems:

[0007] During the upgrade process, the bus is occupied by the upgrade transmission task, and other slave devices on the bus cannot get communication time slices, which affects the service.

[0008] The upgrade process is lengthy, employing a one-to-one file transfer method. When upgrading multiple slave devices, the overall upgrade cycle is quite long.

[0009] If the upgrade fails or a power outage occurs during the upgrade process, the slave device cannot be restored.

[0010] On one hand, the present invention provides an upgrade method based on the 485 bus, the method comprising the following steps:

[0011] The host obtains the list of addresses of the slave devices to be upgraded;

[0012] The host broadcasts an upgrade preparation command to the slave, the upgrade preparation command including the address list;

[0013] After receiving the upgrade preparation command, the slave device checks whether the address list contains its own address.

[0014] If so, switch to upgrade mode and enter the upgrade preparation completed state; if not, continue normal operation.

[0015] The host machine uses polling to determine if any slave devices are in an upgrade preparation state.

[0016] If not, the host will re-execute the steps within a limited number of times and determine by polling whether there is a slave device in the upgrade preparation state that needs to be upgraded.

[0017] If so, the host broadcasts an upgrade package containing file validity and integrity verification codes to the slave device to be upgraded, which is in the upgrade preparation completed state;

[0018] The slave device to be upgraded receives the upgrade package and performs file validity and integrity checks on it to determine whether the file validity and integrity checks pass.

[0019] If successful, proceed with the upgrade and switch to normal mode after the upgrade is complete.

[0020] If it fails, the system will remain in the upgrade preparation complete state.

[0021] The host obtains the upgrade results of the slave devices to be upgraded by polling, and determines whether there are any slave devices that have failed to be upgraded.

[0022] If so, the host executes the above steps and broadcasts an upgrade package containing file validity and integrity verification codes to the slave device to be upgraded, which is in the upgrade preparation completed state.

[0023] If not, the process ends.

[0024] Furthermore, the step of the host obtaining the address list of the slave devices to be upgraded includes:

[0025] The host performs a routine inspection of all slave devices, obtains the device information of the slave devices, determines whether the slave devices need to be upgraded based on the device information, identifies the slave devices that need to be upgraded as slave devices to be upgraded, obtains the addresses of the slave devices to be upgraded, and generates an address list.

[0026] Furthermore, the device information includes a version number and a device type.

[0027] Furthermore, the step of switching to upgrade mode includes the following specific steps:

[0028] Set the upgrade flag on the slave device to be upgraded;

[0029] Reboot into BOOT;

[0030] After the BOOT detects the upgrade indicator, the upgrade preparation is complete.

[0031] Waiting for the upgrade, while responding to any commands sent to the host with an update that the upgrade is ready.

[0032] Furthermore, the upgrade package includes multiple upgrade file packages arranged in an orderly manner. The first upgrade file package includes the host number information for the upgrade, the number of upgrade file packages to be split, and the slice format. The second and subsequent upgrade file packages send upgrade file slice information according to the packet header information of the upgrade file package.

[0033] Furthermore, the last upgrade package includes a file validity and integrity check code.

[0034] Furthermore, the step of the slave device to be upgraded receiving the upgrade package and performing file validity and integrity verification includes performing file validity and integrity verification on the slave device to be upgraded after receiving the last upgrade file package.

[0035] On the other hand, the present invention provides an upgrade device based on the 485 bus, the device comprising:

[0036] The host module is used to obtain the status of the slave device to be upgraded by polling, and broadcast upgrade preparation instructions and upgrade packages to the slave device to be upgraded according to the status of the slave device to be upgraded.

[0037] The slave module is used to receive upgrade preparation instructions and upgrade packages sent from the master, respond to the master's polling, prepare for the upgrade, and complete the upgrade.

[0038] The 485 bus module is used for communication connection between the master module and the slave module.

[0039] On the other hand, the present invention also provides an apparatus including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps described in the 485 bus-based upgrade method.

[0040] On the other hand, the present invention also provides a readable storage medium storing a computer program that, when executed by a processor, implements the steps described in the 485 bus-based upgrade method.

[0041] The beneficial effects of this invention are:

[0042] 1. During the upgrade process, the slave device to be upgraded can report its status to the master through multiple polls, which will not affect the normal business of other slave devices.

[0043] 2. The host sends upgrade packages to multiple slave devices to be upgraded via broadcast. Multiple slave devices can receive upgrade packages simultaneously and work in parallel, resulting in a short overall upgrade cycle and high efficiency.

[0044] 3. If the upgrade fails, the slave device to be upgraded will remain in upgrade mode. The master device will obtain the status of the slave device to be upgraded by polling and can upgrade the slave device again until the upgrade is successful, thus avoiding the situation where there is no way to recover after the upgrade fails. Attached Figure Description

[0045] Figure 1 This is a flowchart of an upgrade method based on the 485 bus provided in an embodiment of the present invention;

[0046] Figure 2 This is a schematic diagram of the structure of the upgrade device based on the 485 bus provided in an embodiment of the present invention;

[0047] Figure 3 This is a schematic diagram of the device provided in an embodiment of the present invention. Detailed Implementation

[0048] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0049] The specific implementation of the present invention will be described in detail below with reference to specific embodiments:

[0050] Example 1:

[0051] Figure 1 The implementation flow of the upgrade method based on the 485 bus provided in Embodiment 1 of the present invention is shown. For ease of explanation, only the parts related to the embodiments of the present invention are shown, and are described in detail below:

[0052] The steps include:

[0053] Step S1: The host obtains the address list of the slave devices to be upgraded;

[0054] Step S2: The host broadcasts an upgrade preparation command to the slave, which includes an address list;

[0055] Step S3: After receiving the upgrade preparation command, the slave device checks whether the address list contains its own address.

[0056] Step S4: If yes, switch to upgrade mode and enter the upgrade preparation completed state; if no, continue normal operation.

[0057] Step S5: The host determines by polling whether any slave devices awaiting upgrade are in the upgrade preparation state;

[0058] If not, repeat step S5 within a limited number of attempts;

[0059] Step S6: If yes, the host broadcasts an upgrade package containing file validity and integrity verification codes to the slave device to be upgraded, which is in the upgrade preparation completion state.

[0060] Step S7: The slave device to be upgraded receives the upgrade package and performs file validity and integrity verification on it, and determines whether the file validity and integrity verification passes.

[0061] Step S8: If successful, perform the upgrade and switch to normal mode after the upgrade is complete;

[0062] Step S9: If the upgrade fails, the process remains in the "Upgrade preparation complete" state.

[0063] Step S10: The host obtains the upgrade results of the slave devices to be upgraded by polling, and determines whether there are any slave devices to be upgraded that have failed to be upgraded.

[0064] If so, proceed to step S6;

[0065] If not, the process ends.

[0066] Further, step S1 includes:

[0067] The host performs a routine inspection of all slave devices, obtains device information from the slave devices, determines whether a slave device needs to be upgraded based on the device information, identifies the slave devices that need to be upgraded as slave devices to be upgraded, obtains the addresses of the slave devices to be upgraded, and generates an address list.

[0068] In this embodiment of the invention, the host can also obtain the address list of slave devices to be upgraded through user configuration.

[0069] Furthermore, the device information includes the version number and device type.

[0070] Furthermore, step S4 includes the following specific steps:

[0071] Step S41: Set the upgrade flag on the slave device to be upgraded;

[0072] Step S42: Reboot and enter BOOT;

[0073] Step S43: After BOOT detects the upgrade flag, the upgrade preparation is complete.

[0074] Step S44: Wait for the upgrade, and reply to any commands sent to the host that the upgrade preparation is complete.

[0075] Furthermore, the upgrade package includes multiple upgrade file packages arranged in an orderly manner. The first upgrade file package includes the host number information for the upgrade, the number of upgrade file packages to be split, and the slice format. The second and subsequent upgrade file packages send upgrade file slice information according to the packet header information of the upgrade file package.

[0076] Furthermore, the final upgrade package includes a file validity and integrity check code.

[0077] Furthermore, step S7 includes verifying the validity and integrity of the file after the slave device to be upgraded receives the last upgrade file package.

[0078] Example 2:

[0079] Figure 2 A schematic diagram of an upgrade device based on a 485 bus according to an embodiment of the present invention is shown. For ease of explanation, only the parts related to the embodiment of the present invention are shown, including:

[0080] The host module 201 is used to obtain the status of the slave device to be upgraded and broadcast upgrade preparation instructions and upgrade packages to it according to the status of the slave device to be upgraded.

[0081] The slave module 203 to be upgraded is used to receive upgrade preparation instructions and upgrade packages sent from the master, respond to the polling of the master, prepare for upgrade and complete the upgrade.

[0082] The 485 bus module 203 is used for communication connection between the master module and the slave module.

[0083] In this embodiment of the invention, each module of the upgrade device based on the 485 bus can be implemented by a corresponding hardware or software module. Each module can be an independent software or hardware module, or it can be integrated into a software or hardware module. This is not intended to limit the invention.

[0084] Example 3:

[0085] Figure 3 A schematic diagram of the device provided in an embodiment of the present invention is shown. For ease of explanation, only the parts related to the embodiment of the present invention are shown, including:

[0086] In this embodiment of the invention, a device is provided, including a memory 301, a processor 302, and a computer program 303 stored in the memory and executable on the processor. When executed by the processor, the computer program implements the steps described in the 485 bus-based upgrade method embodiment. For example... Figure 1 The steps S1 to S10 are shown. Alternatively, when the computer program is executed by the processor, it implements the functions of each module in the aforementioned 485 bus-based upgrade device, for example, Figure 2 Modules 201 to 203 are shown.

[0087] Example 4:

[0088] In this embodiment of the invention, a readable storage medium is provided, which stores a computer program. When executed by a processor, the computer program implements the steps in the above-described 485 bus-based upgrade method embodiment, for example... Figure 1 The steps S1 to S10 are shown. Alternatively, when the computer program is executed by the processor, it implements the functions of each module in the above-described device embodiments, for example... Figure 2 The functions of each module are shown.

[0089] The computer-readable storage medium in embodiments of the present invention may include any entity or device capable of carrying computer program code, a recording medium, such as ROM / RAM, disk, optical disk, flash memory, etc.

[0090] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. An upgrade method based on the 485 bus, characterized in that, The method includes the following steps: The host performs a routine inspection of all slave devices, obtains the device information of the slave devices, determines whether the slave devices need to be upgraded based on the device information, identifies the slave devices that need to be upgraded as slave devices to be upgraded, obtains the addresses of the slave devices to be upgraded, and generates an address list. The host broadcasts an upgrade preparation command to the slave, the upgrade preparation command including the address list; After receiving the upgrade preparation command, the slave device checks whether the address list contains its own address. If so, switch to upgrade mode and enter the upgrade preparation completed state; if not, continue normal operation. The host machine uses polling to determine if any slave devices are in an upgrade preparation state. If not, the host will re-execute the steps within a limited number of times and determine by polling whether there is a slave device in the upgrade preparation state that needs to be upgraded. If so, the host broadcasts an upgrade package containing file validity and integrity verification codes to the slave device to be upgraded, which is in the upgrade preparation completed state; The slave device to be upgraded receives the upgrade package and performs file validity and integrity checks on it to determine whether the file validity and integrity checks pass. If successful, proceed with the upgrade and switch to normal mode after the upgrade is complete. If it fails, the system will remain in the upgrade preparation complete state. The host obtains the upgrade results of the slave devices to be upgraded by polling, and determines whether there are any slave devices that have failed to be upgraded. If so, the host executes the above steps and broadcasts an upgrade package containing file validity and integrity verification codes to the slave device to be upgraded, which is in the upgrade preparation completion state. If none, end; The steps to switch to upgrade mode include the following: Set the upgrade flag on the slave device to be upgraded; Reboot into BOOT; After the BOOT detects the upgrade indicator, the upgrade preparation is complete. Waiting for the upgrade, while responding to any commands sent to the host with an update that the upgrade is ready.

2. The upgrade method based on the 485 bus according to claim 1, characterized in that, The device information includes the version number and device type.

3. The upgrade method based on the 485 bus according to claim 1, characterized in that, The upgrade package includes multiple upgrade file packages arranged in an orderly manner. The first upgrade file package includes the host number information for the upgrade, the number of upgrade file packages, and the slice format. The second and subsequent upgrade file packages send upgrade file slice information according to the packet header information of the upgrade file package.

4. The upgrade method based on the 485 bus according to claim 3, characterized in that, The last upgrade package includes a file validity and integrity check code.

5. The upgrade method based on the 485 bus according to claim 4, characterized in that, The step of the slave device to be upgraded receiving the upgrade package and performing file validity and integrity verification includes performing file validity and integrity verification on the slave device to be upgraded after receiving the last upgrade file package.

6. An upgrade apparatus for an upgrade method based on a 485 bus, used to implement the method as described in any one of claims 1-5, characterized in that, The device includes: The host module is used to obtain the status of the slave device to be upgraded by polling, and broadcast upgrade preparation instructions and upgrade packages to the slave device to be upgraded according to the status of the slave device to be upgraded. The slave module is used to receive upgrade preparation instructions and upgrade packages sent from the master, respond to the master's polling, prepare for the upgrade, and complete the upgrade. The 485 bus module is used for communication connection between the master module and the slave module.

7. A device for an upgrade method based on a 485 bus, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 5.

8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data acquisition module, firmware upgrading method thereof and storage medium

    CN110597532A

  • Data transmission method and device and multi-connected machine group system unit upgrading method and device

    CN111399878A

  • System and method for quickly upgrading vehicle-mounted electronic controller through CAN (Controller Area Network) transmission

    CN113655737A