From db88628e7bb03f334fa65826bd655c27859a9973 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期日, 03 十一月 2024 16:52:04 +0800 Subject: [PATCH] 1、协议版本号增加到协议解析与命令构造中; 2、增加RTU状态记录功能,为RTU远程升级做准备。 --- pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 44 insertions(+), 1 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java index 2f0c7d6..a42953c 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java @@ -4,7 +4,50 @@ public class ByteUtil { - + + /** + * 灏嗗瓧鑺傛暟缁勫垎鍓� + * @param bytes 琚垎鍓叉暟缁� + * @param fromIndex 鍒嗗壊璧峰浣嶇疆 + * @param len 鍒嗗壊闀垮害 + * @return 杩斿洖 鍒嗗壊鍑烘潵鐨勬暟缁� + */ + public static byte[] bytesSplit(byte[] bytes, int fromIndex, int len){ + if(bytes == null){ + return null ; + }else{ + byte[] bs = new byte[len] ; + if(fromIndex + len > bytes.length){ + System.arraycopy(bytes, fromIndex, bs, 0, bytes.length - fromIndex) ; + }else{ + System.arraycopy(bytes, fromIndex, bs, 0, len) ; + } + return bs ; + } + } + /** + * 灏嗗瓧鑺傛暟缁勫垎鍓� + * @param bytes 琚垎鍓叉暟缁� + * @param fromIndex 鍒嗗壊璧峰浣嶇疆 + * @param len 鍒嗗壊闀垮害 + * @return 杩斿洖 鍒嗗壊鍑烘潵鐨勬暟缁� + */ + public static Object[] bytesSplit_(byte[] bytes, int fromIndex, int len){ + if(bytes == null){ + return null ; + }else{ + int realLen = len ; + byte[] bs = new byte[len] ; + if(fromIndex + len > bytes.length){ + System.arraycopy(bytes, fromIndex, bs, 0, bytes.length - fromIndex) ; + realLen = bytes.length - fromIndex ; + }else{ + System.arraycopy(bytes, fromIndex, bs, 0, len) ; + } + return new Object[]{bs, realLen} ; + } + } + /** * 灏嗗瓧鑺傛暟缁勫悎骞跺埌瀛楄妭鏁扮粍涓� * @param bGroup1 琚悎骞舵暟缁� -- Gitblit v1.8.0