def login(self, username='<STR_LIT>', userid=<NUM_LIT:0>, password=None):
if password and len(password) > <NUM_LIT:20>:<EOL><INDENT>self.logger.error('<STR_LIT>')<EOL>raise Exception('<STR_LIT>')<EOL><DEDENT>self.send(C1218LogonRequest(username, userid))<EOL>data = self.recv()<EOL>if data != b'<STR_LIT:\x00>':<EOL><INDENT>self.logger.warning('<STR_LIT>')<EOL>return False<EOL><DEDENT>if password is not None:<EOL><INDENT>self.send(C1218SecurityRequest(password))<EOL>data = self.recv()<EOL>if data != b'<STR_LIT:\x00>':<EOL><INDENT>self.logger.warning('<STR_LIT>')<EOL>return False<EOL><DEDENT><DEDENT>self.logged_in = True<EOL>return True<EOL>
Log into the connected device.

:param str username: the username to log in with (len(username) <= 10)
:param int userid: the userid to log in with (0x0000 <= userid <= 0xffff)
:param str password: password to log in with (len(password) <= 20)
:rtype: bool