def read_pdu
      loop do
        header = @io.read(7)
        if header
          trn = header[0,2].unpack('n')[0]
          len = header[4,2].unpack('n')[0]
          msg = @io.read(len-1)

          log "Rx (#{(header + msg).size} bytes): " + logging_bytes(header + msg)

          if trn == @transaction
            return msg
          else
            log "Transaction number mismatch. A packet is ignored."
          end
        end
      end
    end
def read_pdu
      loop do
        header = @io.read(7)
        if header
          trn = header[0,2].unpack('n')[0]
          len = header[4,2].unpack('n')[0]
          msg = @io.read(len-1)

          log "Rx (#{(header + msg).size} bytes): " + logging_bytes(header + msg)

          if trn == @transaction
            return msg
          else
            log "Transaction number mismatch. A packet is ignored."
          end
        end
      end
    end
overide method for RTU over TCP implamentaion
 @see Slave#query