whyclj
2020-10-15 95c0c2e94d390650d3954c30c6a7c805fe9c714c
src/com/modbus/data/MyModbusUtils.java
@@ -147,10 +147,18 @@
 
   public static BatchResults<Integer> readMutilRegisters(BatchRead<Integer> batch,MyModbusMaster master){
      batch.setContiguousRequests(false);
      boolean isSuccess = true;
      try {
         return master.getMaster().send(batch);
      } catch (ModbusTransportException | ErrorResponseException e) {
         e.printStackTrace();
         //e.printStackTrace();
         isSuccess = false;
      } finally {
         if(isSuccess) {
            master.clearError();
         }else{
            master.addErrorCount();
         }
      }
      return null;
   }
@@ -379,6 +387,11 @@
      //System.out.println(results.getValue(1));
   }
   
   public static float readFloat(Object obj) {
      return (float)obj;
   }
   /**
    *    读取float类型数据
    * @param obj   Short类型