Giter VIP home page Giter VIP logo

Comments (12)

lucasmpr avatar lucasmpr commented on August 17, 2024 1

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.

lcnittl avatar lcnittl commented on August 17, 2024

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.

rtrahms avatar rtrahms commented on August 17, 2024

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.

tomchy avatar tomchy commented on August 17, 2024

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.

lcnittl avatar lcnittl commented on August 17, 2024

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.

GarrettIRL avatar GarrettIRL commented on August 17, 2024

@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.

lcnittl avatar lcnittl commented on August 17, 2024

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.

lcnittl avatar lcnittl commented on August 17, 2024

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.

GarrettIRL avatar GarrettIRL commented on August 17, 2024

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.

tomchy avatar tomchy commented on August 17, 2024

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.

GarrettIRL avatar GarrettIRL commented on August 17, 2024

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.

gamberoillecito avatar gamberoillecito commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.