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
388 stars 304 forks source link

AttributeError: 'GsmModem' object has no attribute 'serial' #3

Closed dauheeIRL closed 11 years ago

dauheeIRL commented 11 years ago

Hi,

Not sure if its something I am omitting or if an issue, but I get the error in the subject line when attempting to initalise GsmModem.

Basically I copied the GsmModem folder to C:\Python27\Lib and attempted the following call: modem = GsmModem(PORT, BAUDRATE, incomingCallCallbackFunc=handleIncomingCall)

Just wondering what your thoughts are?

Thanks,

David.

faucamp commented 11 years ago

Have you installed pyserial?

I would recommend using pip to install python-gsmmodem (since it will automatically install the needed dependencies), but in your case you can download pyserial and copy it to your python installation's path. If this does not solve your problem, please post the stack trace that you receive from python so I can take a look at it.

dauheeIRL commented 11 years ago

hi Francois,

Thank you very much for responding. I did the python setup.py install for pyserial and also gsmmodem. I am using pyserial directly and it is working. My error trace is: Message File Name Line Position Traceback

C:\Per\Tools\raspberry pi\backup_Dev\scripts-dev\GSM2.py 61 main C:\Per\Tools\raspberry pi\backup_Dev\scripts-dev\GSM2.py 50 write C:\Python27\lib\site-packages\gsmmodem\modem.py 163 write C:\Python27\lib\site-packages\gsmmodem\serial_comms.py 117 AttributeError: 'GsmModem' object has no attribute 'serial' Any suggestions you have would be great. Thanks, David. On Tue, Apr 16, 2013 at 2:32 PM, Francois Aucamp notifications@github.comwrote: > Have you installed pyserial? > > I would recommend using pip to install python-gsmmodem (since it will > automatically install the needed dependencies), but in your case you can > download pyserial and copy it to your python installation's path. If this > does not solve your problem, please post the stack trace that you receive > from python so I can take a look at it. > > — > Reply to this email directly or view it on GitHubhttps://github.com/faucamp/python-gsmmodem/issues/3#issuecomment-16444672 > .
faucamp commented 11 years ago

Thanks for the stack trace. You're seeing the error because something in your GSM2.py script is calling the write() method of the modem object before modem.connect() has been called; in other words, right after:

modem = GsmModem(PORT, BAUDRATE, incomingCallCallbackFunc=handleIncomingCall)

you should add:

modem.connect()

This needs to be called before any read/write attempts are made, since it initializes the modem based on some of the properties set in the modem class. If this does not solve your problem, it may be that you have an older copy of the code? In any case, thanks for the report - I'll add a descriptive error message for this particular case as I suspect more people might run into this.

Please let me know if this resolves your problem so that I can close the issue. Oh, and glad to see you're using a Raspberry Pi - this project was actually originally created for a Pi-based project of mine ;-)

dauheeIRL commented 11 years ago

Hi Francois,

I really appreciate you responding. Yes please close the issue as it was my error. Doing the connect first before attempting to set my SIM PIN worked perfectly. I'm just getting to grips with your fantastic library. Thank you very much for the great work, it will save me lots of head scratching.

Thanks,

David.

On Wed, Apr 17, 2013 at 9:03 AM, Francois Aucamp notifications@github.comwrote:

Thanks for the stack trace. You're seeing the error because something in your GSM2.py script is calling the write() method of the modem object before modem.connect() has been called; in other words, right after:

modem = GsmModem(PORT, BAUDRATE, incomingCallCallbackFunc=handleIncomingCall)

you should add:

modem.connect()

This needs to be called before any read/write attempts are made, since it initializes the modem based on some of the properties set in the modem class. If this does not solve your problem, it may be that you have an older copy of the code? In any case, thanks for the report - I'll add a descriptive error message for this particular case as I suspect more people might run into this.

Please let me know if this resolves your problem so that I can close the issue. Oh, and glad to see you're using a Raspberry Pi - this project was actually originally created for a Pi-based project of mine ;-)

— Reply to this email directly or view it on GitHubhttps://github.com/faucamp/python-gsmmodem/issues/3#issuecomment-16492160 .