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;