COUR4G3 / python-pppd

Simple library for controlling PPP connections with pppd
MIT License
14 stars 8 forks source link

pppd.PPPConnectionError: Connect script failed #6

Open MatanTubul opened 7 years ago

MatanTubul commented 7 years ago

I try to use the following GSM multiplexer code:

[https://github.com/ya-jeks/gsmmux]()

now my main device is ttyUSB2 after i run the multiplexer i have "mux0" and "mux1" devices which them i can connect the GPRS and get SMS simultaneity. if i try your program directly on ttyUSB2 with the script /usr/sbin/chat -v -f /etc/chatscripts/pap -T *99***1# it is working but when i switch to mux1 device i get Connect script failed. i check mux1 and is working fine (checked using minicom). do you have any other idea what could be the problem?

i just notice that sometimes the connection is succeeded and most time not

COUR4G3 commented 7 years ago

The PPPConnectionError exception has an output property, you should be able see all the messages returned by pppd and most importantly chat, should help a bit.

MatanTubul commented 7 years ago

the only message i get is "pppd.PPPConnectionError: Connect script failed" where i can find the chat error messages?

COUR4G3 commented 7 years ago

Put the connect in a try-except and print the output property. obviously substitute your parameters:

try: pppd.connect(...) except PPPConnection as e: print(e.output)

MatanTubul commented 7 years ago

i already did that but still i am getting the same output this is my code:

from pppd import PPPConnection
import sys

ppp = PPPConnection(sys.argv[1],connect=sys.argv[2])
try:
        ppp.connected()
except PPPConnection as e:
        print(e.output)
print ppp.laddr
print ppp.raddr

and this is the output:

Traceback (most recent call last):
  File "start.py", line 4, in <module>
    ppp = PPPConnection(sys.argv[1],connect=sys.argv[2])
  File "/home/wint/ixt/python-pppd/pppd.py", line 87, in __init__
    raise PPPConnectionError(self.proc.returncode, self.output)
pppd.PPPConnectionError: Connect script failed
COUR4G3 commented 7 years ago

You need to include the line above:

ppp = PPPConnection...

in your try-except block, otherwise it's not catching the error.

MatanTubul commented 7 years ago

still the same, i added the

ppp = PPPConnection...

into the try-catch block, but still the error in the terminal is the same

COUR4G3 commented 7 years ago

Sorry, catching the wrong exception, should be:

except PPPConnectionError as e:

MatanTubul commented 7 years ago

should i pass PPPConnectionError some parameter? i see that it gets "Exception" object