From cb092284f0856302e61a9f38e650e722152653cc Mon Sep 17 00:00:00 2001 From: xinfengkun Date: Mon, 18 Apr 2022 14:08:31 +0800 Subject: [PATCH] =?UTF-8?q?[change]=E5=B0=86InvalidProtocolBufferException?= =?UTF-8?q?=E6=8D=95=E8=8E=B7=E6=9B=B4=E6=94=B9=E4=B8=BAException=E3=80=82?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E4=B8=9A=E5=8A=A1=E8=B0=83=E7=94=A8=E6=97=B6?= =?UTF-8?q?=E4=BA=A7=E7=94=9F=E5=BC=82=E5=B8=B8=E5=BC=95=E8=B5=B7websocket?= =?UTF-8?q?=E6=96=AD=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/zhidao/support/adas/high/AdasChannel.java | 5 +++-- .../com/zhidao/support/adas/high/common/CupidLogUtils.java | 7 +++++++ .../com/zhidao/support/adas/high/common/DigitalTrans.java | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java index 289021db91..411dd18b8d 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java @@ -18,6 +18,7 @@ import com.zhidao.support.adas.high.common.Base64; import com.zhidao.support.adas.high.common.Constants; import com.zhidao.support.adas.high.common.CupidLogUtils; import com.zhidao.support.adas.high.common.Define; +import com.zhidao.support.adas.high.common.DigitalTrans; import com.zhidao.support.adas.high.common.IPCFixationIPHelper; import com.zhidao.support.adas.high.common.MessageType; import com.zhidao.support.adas.high.common.ProtocolStatus; @@ -331,9 +332,9 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec callError(raw.getProtocolStatus(), bytes); } } - } catch (InvalidProtocolBufferException e) { + } catch (Exception e) { callError(ProtocolStatus.BUSINESS_DATA_PARSE_FAILED, bytes); - e.printStackTrace(); + CupidLogUtils.e(TAG, "原始数据:" + DigitalTrans.byte2hex(bytes), e); } } diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/CupidLogUtils.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/CupidLogUtils.java index b63454a790..cd49fb305f 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/CupidLogUtils.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/CupidLogUtils.java @@ -35,6 +35,13 @@ public class CupidLogUtils { Log.w("[tag=" + tag + "]", "[data=" + msg + "]"); } + public static void e(String tag, String msg, Throwable throwable) { + if (!mIsEnableLog) { + return; + } + Log.e("[tag=" + tag + "]", "[data=" + msg + "]", throwable); + } + public static void e(String tag, String msg) { if (!mIsEnableLog) { return; diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/DigitalTrans.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/DigitalTrans.java index daf476edb1..bca5d7a9d2 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/DigitalTrans.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/DigitalTrans.java @@ -315,8 +315,7 @@ public class DigitalTrans { */ public static final String byte2hex(byte b[]) { if (b == null) { - throw new IllegalArgumentException( - "Argument b ( byte array ) is null! "); + return ""; } String hs = ""; String stmp = ""; @@ -571,6 +570,7 @@ public class DigitalTrans { } return value; } + public static byte[] set8bitUnsignedValue(int num) { return new byte[]{(byte) (num)}; }