code: def write_single_coil(self, bit_addr, bit_value):
          
          # check params
          if not (0 <= int(bit_addr) <= 65535):
              self.__debug_msg('write_single_coil(): bit_addr out of range')
              return None
          # build frame
          bit_value = 0xFF if bit_value else 0x00
          tx_buffer = self._mbus_frame(const.WRITE_SINGLE_COIL, struct.pack('>HBB', bit_addr, bit_value, 0))
          # send request
          s_send = self._send_mbus(tx_buffer)
          # check error
          if not s_send:
              return None
          # receive
          f_body = self._recv_mbus()
          # check error
          if not f_body:
              return None
          # check fix frame size
          if len(f_body) != 4:
              self.__last_error = const.MB_RECV_ERR
              self.__debug_msg('write_single_coil(): rx frame size error')
              self.close()
              return None
          # register extract
          (rx_bit_addr, rx_bit_value, rx_padding) = struct.unpack('>HBB', f_body[:4])
          # check bit write
          is_ok = (rx_bit_addr == bit_addr) and (rx_bit_value == bit_value)
          return True if is_ok else None
docs: Modbus function WRITE_SINGLE_COIL (0x05)
  
          :param bit_addr: bit address (0 to 65535)
          :type bit_addr: int
          :param bit_value: bit value to write
          :type bit_value: bool
          :returns: True if write ok or None if fail
          :rtype: bool or None