def __init__(self, port=DEFAULT_PORT, incomingcallback=None):
import threading<EOL>self.port = port<EOL>self.incomingcallnotificationfunc =incomingcallback or self._placeholdercallback<EOL>self._state = self.STATE_FAILED<EOL>self.cmd_callerid = DEFAULT_CMD_CALLERID<EOL>self.cmd_response = '<STR_LIT>'<EOL>self.cmd_responselines = []<EOL>self.cid_time = <NUM_LIT:0><EOL>self.cid_name = '<STR_LIT>'<EOL>self.cid_number = '<STR_LIT>'<EOL>self.ser = None<EOL>_LOGGER.debug('<STR_LIT>', self.port)<EOL>try:<EOL><INDENT>self.ser = serial.Serial(port=self.port)<EOL><DEDENT>except serial.SerialException:<EOL><INDENT>_LOGGER.error('<STR_LIT>', self.port)<EOL>self.ser = None<EOL>return<EOL><DEDENT>threading.Thread(target=self._modem_sm, daemon=True).start()<EOL>try:<EOL><INDENT>self.sendcmd('<STR_LIT>')<EOL>if self.get_response() == '<STR_LIT>':<EOL><INDENT>_LOGGER.error('<STR_LIT>', self.port)<EOL>self.ser.close()<EOL>self.ser = None<EOL>return<EOL><DEDENT>self.sendcmd(self.cmd_callerid)<EOL>if self.get_response() in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>_LOGGER.error('<STR_LIT>')<EOL>self.ser.close()<EOL>self.ser = None<EOL>return<EOL><DEDENT><DEDENT>except serial.SerialException:<EOL><INDENT>_LOGGER.error('<STR_LIT>',<EOL>self.port)<EOL>self.ser = None<EOL><DEDENT>self.set_state(self.STATE_IDLE)<EOL>
Initialize internal variables.