Reading responses from Modem.

  • Thread starter Etienne Labuschagne
  • Start date
E

Etienne Labuschagne

Assuming the modem is on COM5:

m = open('COM5','wb+')
m.write('+++\r\n')
m.flush()
m.write('ATQ0V1E0\r\n')
m.flush()
m.write('ATDT5551234;\r\n')
m.flush()
response = m.read()

The above program works fine when running it AFTER looking at the modem
diagnostics under the modem's properties in Windows 2000. If the machine is
restarted and the diagnostics is not run, the program blocks at the response
= m.read() and I never get a response from the modem.

Obviously the windows diagnostics tool does something to initialise the
modem for responses - everything else works (the modem dials, etc.)

Any suggestions on how to "wake up" the modem without doing the diagnostics
every time?

Thanks
Etienne
 
P

Peter Hansen

Etienne said:
Assuming the modem is on COM5:

m = open('COM5','wb+')
m.write('+++\r\n')
m.flush()
m.write('ATQ0V1E0\r\n')
m.flush()
m.write('ATDT5551234;\r\n')
m.flush()
response = m.read()

The above program works fine when running it AFTER looking at the modem
diagnostics under the modem's properties in Windows 2000. If the machine is
restarted and the diagnostics is not run, the program blocks at the response
= m.read() and I never get a response from the modem.

Obviously the windows diagnostics tool does something to initialise the
modem for responses - everything else works (the modem dials, etc.)

Any suggestions on how to "wake up" the modem without doing the diagnostics
every time?

It's strongly recommended (by me, anyway) to use PySerial to
talk to things on serial ports, especially on Windows, rather
than trying to treat them like files. In the case of your
particular problem, you can at least take advantage of a
read timeout to avoid problems where you might have a
partial command already in the buffer, etc.

Note: the +++ string is typically required to have delays
with *no* data transmitted on either side of it for one
second or it might not work. Just sending +++ in the middle
of a stream of data will not work.

-Peter
 
D

Dennis Lee Bieber

Note: the +++ string is typically required to have delays
with *no* data transmitted on either side of it for one

Which means NO \r\n wanted...

Safest would probably be a sequence (not in Python here)

flush, sleep, write, flush, sleep

I also note that the original posted code does not seem to be
testing for the modem prompt or confirmation after any outputs.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top