Reading responses from Modem.

Discussion in 'Python' started by Etienne Labuschagne, Jul 22, 2004.

  1. 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
    Etienne Labuschagne, Jul 22, 2004
    #1
    1. Advertising

  2. Etienne Labuschagne

    Peter Hansen Guest

    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
    Peter Hansen, Jul 22, 2004
    #2
    1. Advertising

  3. On Thu, 22 Jul 2004 09:48:31 -0400, Peter Hansen <>
    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.

    --
    > ============================================================== <
    > | Wulfraed Dennis Lee Bieber KD6MOG <
    > | Bestiaria Support Staff <
    > ============================================================== <
    > Home Page: <http://www.dm.net/~wulfraed/> <
    > Overflow Page: <http://wlfraed.home.netcom.com/> <
    Dennis Lee Bieber, Jul 22, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tigerhillside
    Replies:
    3
    Views:
    487
    Joe Smith
    Feb 23, 2004
  2. PJ

    Watch Http Request/Responses

    PJ, Aug 16, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    2,356
    Ken Cox [Microsoft MVP]
    Aug 16, 2003
  3. Steven Livingstone

    http pipline, ihttpmodule and filtering responses

    Steven Livingstone, Oct 16, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    447
  4. Etienne Labuschagne

    FW: Reading responses from Modem.

    Etienne Labuschagne, Jul 23, 2004, in forum: Python
    Replies:
    1
    Views:
    367
    yaipa h.
    Jul 24, 2004
  5. sp
    Replies:
    1
    Views:
    817
    Steven Cheng [MSFT]
    Aug 28, 2008
Loading...

Share This Page