def METHOD_NAME(self, data):
    self.exit_on_fatal_error()
    # prevent writing to a port in error state. This will leave unclosed handles to serial on the system
    if not self.error:
        try:
            if hasattr(data, 'encode'):
                # TODO - Refactor brewpi.py to encode as needed, rather than relying on the class to do so
                self.ser.METHOD_NAME(data.encode(encoding='cp437'))
            else:
                self.ser.METHOD_NAME(data)
        except (IOError, OSError, SerialException) as e:
            BrewPiUtil.logMessage('Serial Error: {0})'.format(str(e)))
            self.error = True