张世豪
昨天 03b0fb0ba2de86bcfff277778826547c0e37a93f
src/publicway/ProtocolParser01.java
@@ -1,6 +1,8 @@
package publicway;
import java.util.ArrayList;
import java.util.List;
import chuankou.SerialPortService;
import chushihua.SlotManager;
public class ProtocolParser01 {
@@ -114,9 +116,9 @@
            String receivedCRC = hexData.substring(hexData.length() - 6);
            byte[] cmdBytes = HexUtil.hexStringToBytes(hexData.replace(receivedCRC,""));
            String crc = HexUtil.calculate(cmdBytes)+"00"; 
            System.out.println("收到的完整数据是:"+hexData);
            System.out.println("收到数据校验码是:"+receivedCRC);
            System.out.println("校验码是:"+crc);
            //System.out.println("收到的完整数据是:"+hexData);
            //System.out.println("收到数据校验码是:"+receivedCRC);
            //System.out.println("校验码是:"+crc);
            return receivedCRC.equalsIgnoreCase(crc);            
        } catch (Exception e) {
            System.err.println("CRC校验异常: " + e.getMessage());
@@ -513,7 +515,7 @@
            sb.append("9. 电压: ").append(String.format("%.2f", voltage));
            sb.append("10. 电流: ").append(String.format("%.2f", current));
            sb.append("数据长度: ").append(dataLength).append(" 字节"); 
//            System.out.println(sb.toString());
//            //System.out.println(sb.toString());
            return sb.toString();           
        }
        
@@ -526,7 +528,9 @@
                    String.format("%.2f", voltage),      // 电压
                    String.format("%.2f", current),       // 电流
                    getFaultsString()        // 故障1插卡错误;2过流;3,门控故障;4过压;5欠压;
                    );
                    );
           
        }
    }