'read control lines from serial port and compare the last value sent to remote.
send updates on changes.'

def check_modem_lines(self, force_notification=False):

    modemstate = ((((self.serial.getCTS() and MODEMSTATE_MASK_CTS) | (self.serial.getDSR() and MODEMSTATE_MASK_DSR)) | (self.serial.getRI() and MODEMSTATE_MASK_RI)) | (self.serial.getCD() and MODEMSTATE_MASK_CD))
    deltas = (modemstate ^ (self.last_modemstate or 0))
    if (deltas & MODEMSTATE_MASK_CTS):
        modemstate |= MODEMSTATE_MASK_CTS_CHANGE
    if (deltas & MODEMSTATE_MASK_DSR):
        modemstate |= MODEMSTATE_MASK_DSR_CHANGE
    if (deltas & MODEMSTATE_MASK_RI):
        modemstate |= MODEMSTATE_MASK_RI_CHANGE
    if (deltas & MODEMSTATE_MASK_CD):
        modemstate |= MODEMSTATE_MASK_CD_CHANGE
    if ((modemstate != self.last_modemstate) or force_notification):
        if ((self._client_is_rfc2217 and (modemstate & self.modemstate_mask)) or force_notification):
            self.rfc2217_send_subnegotiation(SERVER_NOTIFY_MODEMSTATE, to_bytes([(modemstate & self.modemstate_mask)]))
            if self.logger:
                self.logger.info('NOTIFY_MODEMSTATE:    {}'.format(modemstate))
        self.last_modemstate = (modemstate & 240)
