def write_multiple_coils(addr, vals)
      nbyte = ((vals.size-1) >> 3) + 1
      sum = 0
      (vals.size - 1).downto(0) do |i|
        sum = sum << 1
        sum |= 1 if vals[i] > 0
      end

      s_val = ""
      nbyte.times do
        s_val << (sum & 0xff).chr
        sum >>= 8
      end

      query("\xf" + addr.to_word + vals.size.to_word + nbyte.chr + s_val)
      self
    end
def write_multiple_coils(addr, vals)
      nbyte = ((vals.size-1) >> 3) + 1
      sum = 0
      (vals.size - 1).downto(0) do |i|
        sum = sum << 1
        sum |= 1 if vals[i] > 0
      end

      s_val = ""
      nbyte.times do
        s_val << (sum & 0xff).chr
        sum >>= 8
      end

      query("\xf" + addr.to_word + vals.size.to_word + nbyte.chr + s_val)
      self
    end
Write multiple coils

 @example
  write_multiple_coils(1, [0,1,0,1]) => self

 @param [Integer] addr address first coil
 @param [Array] vals written coils