From ce759f7bdf3f46ce2fbc8d97be4ae95eb947c4be Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期一, 20 一月 2025 16:05:08 +0800
Subject: [PATCH] 在解析RTU升级hex文件的逻辑中,增加去除无效行的判断逻辑

---
 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/parse/HexFileParse.java |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/parse/HexFileParse.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/parse/HexFileParse.java
index 9adc86b..c294fe7 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/parse/HexFileParse.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/parse/HexFileParse.java
@@ -17,6 +17,7 @@
 
     private static final int hexFileMinLine = 4 ;
     private static final int lineHeadEndIndex = 9 ;
+    private static final int lineValidCharCount = 43 ;//姣忚鏈夋晥瀛楃锛堝啋鍙蜂笌鍗佸叚杩涘埗锛変釜鏁帮紝渚嬪:1096C000DC96010010020020203E00000441000052锛屼絾鍊掓暟绗�3琛屼笉鍙楅檺鍒�
     private static final int bytesSplitUnit512 = 512 ;
 
     public static void main(String[] args) throws Exception{
@@ -137,12 +138,16 @@
                         if(!line.startsWith(":")){
                             vo.errors.add("绗�" + counter + "琛屽唴瀹逛笉鏄互:寮�澶�") ;
                         }else{
-                            line = line.substring(lineHeadEndIndex, line.length() - 2) ;
-                            if(vo.bytes.length == 0){
-                                vo.bytes = HexUtil.decodeHex(line) ;
+                            if(counter != vo.totalLines - 3 && line.length() != lineValidCharCount){
+                                //鏃犳晥鏁版嵁锛岃垗寮冩湰琛屾暟鎹�
                             }else{
-                                byte[] bytes = HexUtil.decodeHex(line) ;
-                                vo.bytes = ByteUtil.bytesMerge(vo.bytes, bytes) ;
+                                line = line.substring(lineHeadEndIndex, line.length() - 2) ;
+                                if(vo.bytes.length == 0){
+                                    vo.bytes = HexUtil.decodeHex(line) ;
+                                }else{
+                                    byte[] bytes = HexUtil.decodeHex(line) ;
+                                    vo.bytes = ByteUtil.bytesMerge(vo.bytes, bytes) ;
+                                }
                             }
                         }
                     }

--
Gitblit v1.8.0