write string to modem, returns number of bytes written.

def write(self, cmd='AT'):
        """write string to modem, returns number of bytes written."""
        self.cmd_response = ''
        self.cmd_responselines = []
        if self.ser is None:
            return 0
        cmd += '\r\n'
        return self.ser.write(cmd.encode())