4

Some AT commands in wvdial return their answers with a delay. This period of time depends on the command. For instance, when you want to scan for available networks, you can use the AT+COPS=? command. The scanning process takes about 30s, but wvdial doesn't wait until it's finished and resend the command. After the second try, wvdial gives up with the following error:

# wvdial info-scan
--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: AT+COPS=?
--> Re-Sending: AT+COPS=?
--> Modem not responding.

After some time (30s), I can issue another command via wvdial, it can be anything, for instance ATZ+CFUN=1, which does nothing when the modem is already on, but after sending the command, I get the output from the previous one:

# wvdial modem-start
--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATZ+CFUN=1
+COPS: (2,"T-Mobile.pl","TM PL","26002",2),(1,"T-Mobile.pl","TM
PL","26002",7),(3,"Plus","PLUS","26001",7),
(3,"Play","Play","26006",7),(3,"Orange","Orange","26003",7),
(3,"Play","Play","26006",2),(3,"Orange","Orange","26003",2),
(3,"Plus","PLUS","26001",2),,(0,1,2,3,4),(0,1,2)
OK

So is there a way to set some kind of timeout for the commands so they could get the delayed answer?

Mikhail Morfikov
  • 10,309
  • 19
  • 69
  • 104

1 Answers1

0

i solved this issue by some trick to create this python script, it will wait for approximately 40seconds or a minute:

import serial
import subprocess
import time

ser = serial.Serial('/dev/modem0', 460800, timeout=2)

cmd = 'AT+COPS=0\r\n'
ser.write(cmd)
ser.sendBreak()

s = []
time_now = time.time()
while(time.time()-time_now)<=40:
    newdata = ser.read()
    if newdata is not None or newdata!="":
            global s
            s.append(newdata)
ser.close
print "".join(s)

subprocess.Popen(["wvdial"])