'Creates, connects to, and boots a GSM Modem. All of the arguments
are optional (although "port=" should almost always be provided),
and passed along to serial.Serial.__init__ verbatim. For all of
the possible configration options, see:
http://pyserial.wiki.sourceforge.net/pySerial#tocpySerial10
Alternatively, a single "device" kwarg can be passed, which overrides
the default proxy-args-to-pySerial behavior. This is useful when testing,
or wrapping the serial connection with some custom logic.'

def __init__(self, *args, **kwargs):

    if ('logger' in kwargs):
        self.logger = kwargs.pop('logger')
    mode = 'PDU'
    if ('mode' in kwargs):
        mode = kwargs.pop('mode')
    if ('device' in kwargs):
        self.device = kwargs.pop('device')
        if (len(args) or len(kwargs)):
            raise TypeError("__init__()    does    not    accept    other    arguments    when    a    'device'    is    given")
    else:
        self.device_args = args
        self.device_kwargs = kwargs
    self.multipart = {}
    self.incoming_queue = []
    if (mode.lower() == 'text'):
        self.smshandler = TextSmsHandler(self)
    else:
        self.smshandler = PduSmsHandler(self)
    self.boot()
