From ec8c6028d44e730885fd9a03994732baee260e94 Mon Sep 17 00:00:00 2001 From: endian11 <Dana_Lee1016@126.com> Date: 星期一, 30 十二月 2019 17:23:25 +0800 Subject: [PATCH] 添加消息对象(初步) --- app/src/main/java/safeluck/drive/evaluation/bean/DriveExamProtocol.java | 48 +++++++++++++++++++++++++++++++++--------------- 1 files changed, 33 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/safeluck/drive/evaluation/bean/DriveExamProtocol.java b/app/src/main/java/safeluck/drive/evaluation/bean/DriveExamProtocol.java index 527c20c..06af76c 100644 --- a/app/src/main/java/safeluck/drive/evaluation/bean/DriveExamProtocol.java +++ b/app/src/main/java/safeluck/drive/evaluation/bean/DriveExamProtocol.java @@ -18,11 +18,13 @@ 鏍囪瘑浣� 娑堟伅澶� 娑堟伅浣� 鏍¢獙鐮� 鏍囪瘑浣� 0x7E 0x7E ======================**/ - // 鏍囪瘑浣� + // 鏍囪瘑浣�(瀛楄妭娴佸紑濮嬶級 private byte MESSAGE_HEAD = 0x7e; - //鏍囪瘑浣� + //鏍囪瘑浣嶏紙瀛楄妭娴佺粨鏉燂級 private byte MESSAGE_TAIL = 0x7e; -//鏍¢獙鐮� 鍏堟殏鏃跺啓姝� + + //鏍¢獙鐮佹寚浠庢秷鎭ご寮�濮嬶紝鍚屽悗涓�瀛楄妭寮傛垨锛岀洿鍒版牎楠岀爜鍓嶄竴涓瓧鑺傦紝鍗犵敤涓�涓瓧鑺� +//鏍¢獙鐮� 鍏堟殏鏃跺啓姝� todo private byte checkCode = 0x78; @@ -32,20 +34,32 @@ //娑堟伅ID private short msg_id; - //娑堟伅浣撳睘鎬� - private int msg_property; - //缁堢鎵嬫満鍙� 瀛楃涓查暱搴﹀繀椤讳负16 + /**銆�娑堟伅浣撳睘鎬ф牸寮忕粨鏋勮〃 +15 14 13 | 12 11 10 | 9 8 7 6 5 4 3 2 1 0 + 淇濈暀 鏁版嵁鍔犲瘑鏂瑰紡 娑堟伅浣撻暱搴� +**/ + //娑堟伅浣撳睘鎬� + private short msg_property =2; + + /** + * 缁堢鎵嬫満鍙� 瀛楃涓查暱搴﹀繀椤讳负16 + **/ private String phoneOnTerminal = "0008618513021245"; -//13 娑堟伅娴佹按鍙� WORD 鎸夊彂閫侀『搴忎粠0寮�濮嬪惊鐜疮鍔� + + /** + * + * 13 娑堟伅娴佹按鍙� WORD 鎸夊彂閫侀『搴忎粠0寮�濮嬪惊鐜疮鍔� + * + */ public static short msg_serial_num=0; //15 棰勭暀 BYTE 棰勭暀 - private byte reserve; + private byte reserve = 0x00; /***===========娑堟伅澶寸粨鏉�=============***/ /** - * 娑堟伅浣� + * 娑堟伅浣� 闇�瑕佸瓙绫诲疄鐜� */ protected abstract byte[] createMessageBody(); @@ -57,6 +71,10 @@ this.msg_id = msg_id; } + /** + * 娑堟伅杞负byte鏁扮粍 7E......7E + * @return + */ public byte[] toBytes(){ byte[] desBytes = new byte[1+16+2+1+1]; int pos = 0; @@ -72,25 +90,25 @@ System.arraycopy(protoVersion,0,desBytes,pos,protoVersion.length); pos +=protoVersion.length; - //娑堟伅ID + //娑堟伅ID byte[] msgIdBytes = ByteUtil.shortGetBytes(msg_id); System.arraycopy(msgIdBytes,0,desBytes,pos,msgIdBytes.length); pos+=msgIdBytes.length; - //娑堟伅浣撳睘鎬� - byte[] msg_pro_bytes = ByteUtil.shortGetBytes((short)2); + //娑堟伅浣撳睘鎬� + byte[] msg_pro_bytes = ByteUtil.shortGetBytes(msg_property); System.arraycopy(msg_pro_bytes,0,desBytes,pos,msg_pro_bytes.length); pos+=msg_pro_bytes.length; //缁堢鎵嬫満鍙� byte[] phoneBytes = ByteUtil.str2Bcd(phoneOnTerminal); System.arraycopy(phoneBytes,0,desBytes,pos,phoneBytes.length); pos+=phoneBytes.length; - //娑堟伅娴佹按鍙� + //娑堟伅娴佹按鍙� byte[] msg_serialNum = ByteUtil.shortGetBytes(msg_serial_num++); System.arraycopy(msg_serialNum,0,desBytes,pos,msg_serialNum.length); pos+=msg_serialNum.length; - //淇濈暀 - desBytes[pos] = 0; + //淇濈暀byte + desBytes[pos] = reserve; pos++; //娑堟伅浣� -- Gitblit v1.8.0