faucamp / python-gsmmodem

Python module to control a GSM modem attached to the system: send/receive SMS messages, handle calls, etc
GNU Lesser General Public License v3.0
384 stars 302 forks source link

SIM card PIN required (SIM without PIN) #37

Open johnnytardin opened 10 years ago

johnnytardin commented 10 years ago

I have Huawei E173 modem and when running identify-modem.py i have the output:

root@abudhabi:/home/jtardin/Documents/python-gsmmodem/tools# ./identify-modem.py -b 115200 /dev/ttyUSB2 args: Namespace(baud='115200', debug=False, pin=None, port='/dev/ttyUSB2') Connecting to GSM modem on /dev/ttyUSB2... Error: SIM card PIN required. Please specify a PIN with the -p argument.

This SIM don't have PIN enabled. I enable the PIN via smartphone and have the output now:

root@abudhabi:/home/jtardin/Documents/python-gsmmodem/tools# ./identify-modem.py -b 115200 /dev/ttyUSB2 -p 1010 args: Namespace(baud='115200', debug=False, pin='1010', port='/dev/ttyUSB2') Connecting to GSM modem on /dev/ttyUSB2... Traceback (most recent call last): File "./identify-modem.py", line 88, in main() File "./identify-modem.py", line 49, in main modem.connect(args.pin) File "/usr/local/lib/python2.7/dist-packages/gsmmodem/modem.py", line 198, in connect self._unlockSim(pin) File "/usr/local/lib/python2.7/dist-packages/gsmmodem/modem.py", line 368, in _unlockSim self.write('AT+CPIN="{0}"'.format(pin)) File "/usr/local/lib/python2.7/dist-packages/gsmmodem/modem.py", line 398, in write responseLines = SerialComms.write(self, data + writeTerm, waitForResponse=waitForResponse, timeout=timeout, expectedResponseTermSeq=expectedResponseTermSeq) File "/usr/local/lib/python2.7/dist-packages/gsmmodem/serial_comms.py", line 135, in write raise TimeoutException() gsmmodem.exceptions.TimeoutException

Any idea?

Thanks.

babca commented 8 years ago

I think you should have to use /dev/ttyUSB0 instead of /dev/ttyUSB2. If no other serial device is connected to your system, AFAIK, /dev/ttyUSB0 port is the main command channel and the /dev/ttyUSB2 port is the notification channel. You can watch notifications /dev/ttyUSB2 with simple screen command screen /dev/ttyUSB0 115200