code: def writeline(self, data):
          
          try:
              if self.ch_mode:
                  data += "\n"
                  parts = split_by_n(data, self.ch_mode_chunk_size)
                  for split_str in parts:
                      self.port.write(split_str.encode())
                      time.sleep(self.ch_mode_ch_delay)
              else:
                  self.port.write((data + "\n").encode())
          except SerialException as err:
              self.logger.exception("SerialError occured while trying to write data {}.".format(data))
              raise RuntimeError(str(err))
docs: Writes data to serial port.
  
          :param data: Data to write
          :return: Nothing
          :raises: IOError if SerialException occurs.