From 552cc4f1aacd10d9cda4b37bd283fe379aafea55 Mon Sep 17 00:00:00 2001 From: yiming Date: Thu, 28 Apr 2022 14:15:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A4=A9=E7=BA=BF=E5=88=87?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/service/RFID/RFIDSocket.java | 41 +++++++------------ 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/web/src/main/java/com/zhehekeji/web/service/RFID/RFIDSocket.java b/web/src/main/java/com/zhehekeji/web/service/RFID/RFIDSocket.java index a1aefa9..595abaa 100644 --- a/web/src/main/java/com/zhehekeji/web/service/RFID/RFIDSocket.java +++ b/web/src/main/java/com/zhehekeji/web/service/RFID/RFIDSocket.java @@ -179,38 +179,27 @@ public class RFIDSocket { if(!running){ break; } + byte []antChanges = new byte[6]; + antChanges[0] = (byte)0xa0; + antChanges[1] = (byte)0x04; + antChanges[2] = (byte)0x22; + antChanges[3] = (byte)0x74; if(i % 2 == 0){ //切换天线 使用天线0 - byte[]bytes = new byte[6]; - bytes[0] = (byte)0xa0; - bytes[1] = (byte)0x04; - bytes[2] = (byte)0x22; - bytes[3] = (byte)0x74; - bytes[4] = (byte)0x00; - bytes[5] = (byte)0xc6; - try { - os.write(bytes); - Thread.sleep(70); - } catch (InterruptedException | IOException e) { - log.error("send cmd error:{}",e); - } + antChanges[4] = (byte)0x00; + antChanges[5] = (byte)0xc6; }else { //切换天线 使用天线1 - byte[]bytes = new byte[6]; - bytes[0] = (byte)0xa0; - bytes[1] = (byte)0x04; - bytes[2] = (byte)0x22; - bytes[3] = (byte)0x74; - bytes[4] = (byte)0x01; - bytes[5] = (byte)0xc5; - try { - os.write(bytes); - Thread.sleep(70); - } catch (InterruptedException | IOException e) { - log.error("send cmd error:{}",e); - } + antChanges[4] = (byte)0x01; + antChanges[5] = (byte)0xc5; } i++; + try { + os.write(antChanges); + Thread.sleep(10); + } catch (InterruptedException | IOException e) { + log.error("send cmd error:{}",e); + } byte[]bytes = new byte[5]; bytes[0] = (byte)0xa0; bytes[1] = (byte)0x03;