467,116 Members | 1,165 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,116 developers. It's quick & easy.

Reading responses from Modem.

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

Jul 18 '05 #1
  • viewed: 2350
Share:
2 Replies
Etienne Labuschagne wrote:
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
Jul 18 '05 #2
On Thu, 22 Jul 2004 09:48:31 -0400, Peter Hansen <pe***@engcorp.com>
declaimed the following in comp.lang.python:

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.

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Etienne Labuschagne | last post: by
21 posts views Thread by JoKur | last post: by
3 posts views Thread by Arne Beruldsen | last post: by
8 posts views Thread by stephane8@gmail.com | last post: by
3 posts views Thread by Nutshell | last post: by
2 posts views Thread by muruganyuva | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.