2021与蓝度共同重构项目,服务端
liuhaonan
2022-07-27 f410f265a4ed4ba64cc2b4b4d3700d1ca6be4b2a
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/report/A5LightErrorCodeReportInnerFrame.java
@@ -1,8 +1,10 @@
package com.sandu.ximon.admin.manager.iot.frame.inner.report;
import cn.hutool.core.util.HexUtil;
import cn.hutool.core.util.StrUtil;
import com.sandu.ximon.admin.manager.iot.frame.inner.BaseResponseInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils;
import com.sandu.ximon.admin.utils.LogUtils;
import lombok.Data;
import lombok.ToString;
@@ -23,7 +25,7 @@
    /**
     * 故障码
     */
    private String errorCode;
    private int errorCode;
    @Override
    public A5LightErrorCodeReportInnerFrame transformFrame(String hex) {
@@ -39,11 +41,14 @@
        setDestinationAddress(hex.substring(8, 12));
        setErrorCode(hex.substring(12, 16));
        String errorCodeHex = hex.substring(12, 16);
        errorCode = HexUtil.hexToInt(errorCodeHex);
        System.out.println("故障码:"+ errorCodeHex +" - " + errorCode);
        setCrc32(hex.substring(hex.length() - 8));
        //  校验CRC32
        String frame = getFunctionCode() + getPayloadLength() + getDestinationAddress() + getErrorCode();
        this.setValidate(CRC32Utils.validateFrame(frame, getCrc32()));
        this.setValidate(CRC32Utils.validateFrame(hex.substring(2, hex.length() - 8), getCrc32()));
        return this;
    }
}