babca / python-gsmmodem

Maintained fork of a Python module to control GSM modems attached to the system: send/receive SMS messages in your scripts, handle calls, and more.
GNU Lesser General Public License v3.0
173 stars 105 forks source link

TimeoutException with Sim800 module #102

Open HamidMousavi-git opened 2 years ago

HamidMousavi-git commented 2 years ago

Hi I want to test this library with Sim800 module but it raise timeout exception i test the module with putty and also with below code and every thigs is ok:

`import serial import time

ser = serial.Serial(port='COM3', baudrate=9600, timeout=3) ser.write(b"AT\r\n") time.sleep(1) ser.write(b'AT+CMGF=1\n\r') time.sleep(1) ser.flushInput() ser.flushOutput() command = b'AT+CMGL="ALL"\n\r'#gets incoming sms that has not been read -("REC UNREAD","REC READ","STO UNSENT","STO SENT","ALL") ser.write(command) time.sleep(1) print('ser.inWaiting(): {0}'.format(ser.inWaiting())) print(ser.read_all()) while ser.inWaiting(): print(ser.read_all()) ser.close() `

but when i run identify-modem.py or other examples it raise timeout exception

python.exe c:/Users/Hamid/Desktop/python-gsmmodem-master/tools/identify-modem.py COM3 -b 9600 -d
args: Namespace(port='COM3', baud='9600', pin=None, debug=True, wait=0) Connecting to GSM modem on COM3... Traceback (most recent call last): File "c:\Users\Hamid\Desktop\python-gsmmodem-master\tools\identify-modem.py", line 90, in main() File "c:\Users\Hamid\Desktop\python-gsmmodem-master\tools\identify-modem.py", line 51, in main modem.connect(args.pin, waitingForModemToStartInSeconds=args.wait) File "C:\Users\Hamid\AppData\Local\Programs\Python\Python310\lib\site-packages\gsmmodem\modem.py", line 211, in connect self.write('ATZ') # reset configuration File "C:\Users\Hamid\AppData\Local\Programs\Python\Python310\lib\site-packages\gsmmodem\modem.py", line 464, in write responseLines = super(GsmModem, self).write(data + writeTerm, waitForResponse=waitForResponse, timeout=timeout, expectedResponseTermSeq=expectedResponseTermSeq) File "C:\Users\Hamid\AppData\Local\Programs\Python\Python310\lib\site-packages\gsmmodem\serial_comms.py", line 144, in write raise TimeoutException() gsmmodem.exceptions.TimeoutException: None

t-rekttt commented 1 year ago

I found out that change dsrdtr and/or rtscts to false in this line will fix it. Specifically: dsrdtr = false, rtscts = false: Working dsrdtr = true, rtscts = false: Working dsrdtr = false, rtscts = true: Not working