'Write to port, controlling RTS before and after transmitting.'

def write(self, b):

    if (self._alternate_rs485_settings is not None):
        self.setRTS(self._alternate_rs485_settings.rts_level_for_tx)
        if (self._alternate_rs485_settings.delay_before_tx is not None):
            time.sleep(self._alternate_rs485_settings.delay_before_tx)
        super(RS485, self).write(b)
        super(RS485, self).flush()
        if (self._alternate_rs485_settings.delay_before_rx is not None):
            time.sleep(self._alternate_rs485_settings.delay_before_rx)
        self.setRTS(self._alternate_rs485_settings.rts_level_for_rx)
    else:
        super(RS485, self).write(b)
