Comments (12)
I found a problem that could be causing this.
Line 50, serial_comms.py. The modem is opened with dstcts=true and dsrdtr=true. As I didn't connect dts and rts, the messages were not flowing to the device.
Removing this initialization solved it for me.
from python-gsmmodem.
Without having tried: From a pyserial
perspective, using "COM1"
(or whatever COM-port is actually in action) instead of "/dev/ttyS0"
should work on Windows. Other than that, I do not think that here are linux-only methods in use. As I am at the moment not able to test it on Windows in the next days, I would be curious about your result.
from python-gsmmodem.
It seems to have issues, but I am not sure if it is Windows related. For my test, I am using a USB GSM modem with a SIM800C chip. The device shows up in Windows as a standard serial device on a COM port that I have assigned to COM10. A serial connection to the device using PuTTY works just fine, I am able to issue AT commands with appropriate responses. No PIN is required to connect.
I have also been able to talk to the device using PySerial commands (simple class code below):
GsmBasic class definition
import serial
import time
import serial.tools.list_ports as port_list
class GsmBasic:
def init(self, port, baud):
self.port = port
self.baud = baud
self.isOpen = False
self.gsm = serial.Serial()
self.gsm.port = port
self.gsm.baudrate = baud
def connect(self):
self.gsm.open()
self.isOpen = self.gsm.isOpen()
if self.isOpen == False:
print("error opening gsm!")
return
def disconnect(self):
self.gsm.close()
self.isOpen = False
def reset(self):
if self.isOpen == False:
print("error, modem not active")
return
command = "ATZ\n"
self.gsm.write(command.encode())
# assume echo
self.gsm.readline() # assume echo for command
print(command)
response = self.gsm.readline()
print(response.decode("Ascii"))
def get_model_info(self):
if self.isOpen == False:
print("error, modem not active")
return
command = "AT+GSV\n"
self.gsm.write(command.encode())
# assume echo
self.gsm.readline() # assume echo for command
print(command)
response = self.gsm.readline()
print(response.decode("Ascii"))
response = self.gsm.readline()
print(response.decode("Ascii"))
response = self.gsm.readline()
print(response.decode("Ascii"))
def check_sig_strength(self):
if self.isOpen == False:
print("error, modem not active")
return
command = "AT+CSQ\n"
self.gsm.write(command.encode())
# assume echo
self.gsm.readline() # assume echo for command
print(command)
response = self.gsm.readline()
print(response.decode("Ascii"))
The following sequence times out, not sure why:
gsmModem = GsmModem("COM10",115200)
gsmModem.connect()
Here is the timeout exception:
Traceback (most recent call last):
File "main.py", line 20, in
modem.connect()
File "C:\DATA\Developer\gsmProject\venv\lib\site-packages\gsmmodem\modem.py", line 210, in connect
self.write('ATZ') # reset configuration
File "C:\DATA\Developer\gsmProject\venv\lib\site-packages\gsmmodem\modem.py", line 458, in write
responseLines = super(GsmModem, self).write(data + writeTerm, waitForResponse=waitForResponse, timeout=timeout, expectedResponseTermSeq=e
xpectedResponseTermSeq)
File "C:\DATA\Developer\gsmProject\venv\lib\site-packages\gsmmodem\serial_comms.py", line 144, in write
raise TimeoutException()
gsmmodem.exceptions.TimeoutException: None
Incidentally, running "python identify-modem.py -b 115200 COM10" yields the same timeout result.
from python-gsmmodem.
Hi @rtrahms !
Your issue is quite similar to that one: #94
I still cannot figure out, what is the difference between sending ATZ
from gsmmodem and your sample code.
Do you have some tools to check for differences (like USB-UART converters)?
Could you verify that if you send ATZ\r
, the sample code still works?
from python-gsmmodem.
Incidentally, running "python identify-modem.py -b 115200 COM10" yields the same timeout result.
Can you run python identify-modem.py -d -b 115200 COM10
and post the output? Thanks!
from python-gsmmodem.
@rtrahms I'm having the same issue running on ubuntu so not a windows problem. As far as I can tell the script isn't writing the initial ATZ command until after the timeout exception is raised. Its possibly an issue with the version of python, pyserial we are both using as with this noted behavior the program would never have worked, which seems contrary as people have obviously been using it successfully.
from python-gsmmodem.
I am running 5c816ba (pip3 install git+https://github.com/babca/python-gsmmodem@5c816ba
) successfully on Ubuntu 20.04.1 LTS with Python 3.8.5.
from python-gsmmodem.
I remember that I had problems when installing from PyPI - but I do not recall if it was this timeout behavior, or rather something else. Can you try installing from GitHub (as per my previous comment) and report back if there was a change in behavior?
from python-gsmmodem.
I am running 5c816ba (
pip3 install git+git://github.com/babca/python-gsmmodem@5c816ba
) successfully on Ubuntu 20.04.1 LTS with Python 3.8.5.
I've just pip3 uninstalled the PyPi install and reinstalled the branch from git as you suggested.
I remember that I had problems when installing from PyPI - but I do not recall if it was this timeout behavior, or rather something else. Can you try installing from GitHub (as per my previous comment) and report back if there was a change in behavior?
Unfortunately the same timeout exception is happening, I've tried on both a laptop running ubuntu and a RPI running raspbian both are having the same issue.
from python-gsmmodem.
Could you dump the list of downloaded packages (pip3 feeeze
)?
Maybe this is something completely irrelevant, but there is a serial
as well as pyserial
package in pip. I remember that only one of them was usable.
from python-gsmmodem.
interesting suggestion I do have both pyserial==3.4 & serial==0.0.97 showing up on the Ubuntu 18.04.5 laptop with PIP3 freeze, but as a bit of a sanity check earlier on I downloaded python-gsmmodem on a RPI and was getting the same error, the PI only has pyserial 3.4 on it, so possibly not the issue. I'm a bit hesitant to remove the serial package (not sure what i downloaded it for or if it's likely to break something else) based on the fact its not on the PI and I'm having the same complications.
from python-gsmmodem.
I found a problem that could be causing this.
Line 50, serial_comms.py. The modem is opened with dstcts=true and dsrdtr=true. As I didn't connect dts and rts, the messages were not flowing to the device.
Removing this initialization solved it for me.
This worked for me too but the parameters at line 50 are dsrdtr
and rtscts
, setting them both to False
solved it for me.
Before:
self.serial = serial.Serial(dsrdtr=True, rtscts=True, port=self.port, baudrate=self.baudrate,
timeout=self.timeout,*self.com_args,**self.com_kwargs)
After:
self.serial = serial.Serial(dsrdtr=False, rtscts=False, port=self.port, baudrate=self.baudrate,
timeout=self.timeout,*self.com_args,**self.com_kwargs)
from python-gsmmodem.
Related Issues (20)
- Question: Support for modems with multiple SIMS ? HOT 1
- dial_polling_demo.py throws gsmmodem.exceptions.TimeoutException: ['NO CARRIER']
- TimeoutException with Sim800 module HOT 1
- Delivery Reports can't be disabled when in PDU mode HOT 2
- Modem working but having Timeout Exception HOT 3
- CMSError: CMS 321 HOT 3
- incompatibility with latest pyserial 3.5
- (removed - useless)
- Sms not receiving
- Support for RFC2217 (serial port over network)
- how best to extend? HOT 1
- Add an example to demonstrate the Sending SMS HOT 2
- Does not work on Python 3.x HOT 2
- Still Alive? HOT 5
- Timeout exception raised for any command. HOT 16
- Error: 'GsmModem' object has no attribute 'rxThread' HOT 3
- sms_handler fails HOT 2
- Instant timeout exception
- PDU Decoding Error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-gsmmodem.