Addressing the modem via pyserial

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Doru-Catalin Togea

    #1

    Addressing the modem via pyserial

    Hi!

    I asked previously how to address the COM port from Python and I was
    directed to pyserial. It is very elegant and I guess it works very well.

    However, it seems that what I try to do is more complicated than I first
    thought. I want to make my modem place a call using the number '1234'. The
    modem is connected to COM3 on my computer. So I tried the following:

    -------------------------------
    import serial

    ser = serial.Serial(2 ) # COM3
    ser.timeout = 2 # otherwise the read(2) which follows blocks for ever
    ser.write("atdt 1234")
    reply = ser.read(2)
    print reply
    ser.close()
    print "ok"
    -------------------------------

    In the HyperTerminal which comes with Win XP Pro, I can set up a
    connection to COM3 and there type the 'atdt1234' command. It works (I get
    a call since I have the modem connected to a device with a phone on it).

    My question is actually: will an at-command like 'atdt1234' translate to
    ser.write('atdt 1234')?

    Secondly, a modem question: I have found a lot of web pages about
    at-commands listing the hayes command set. Still many of them do not seem
    to work on two different modems I have tried. Like '&$' should display an
    overview of the commands supported by the modem. Ii tried this in the
    HyperTerminal where I can place the above mentioned call, and I get
    'ERROR'. I also get 'ERROR' for most other commands I try.

    Any ideas?

    Thanks,
    Catalin

    --

    <<<< =============== =============== ==== >>>>
    << We are what we repeatedly do. >>
    << Excellence, therefore, is not an act >>
    << but a habit. >>
    <<<< =============== =============== ==== >>>>
  • Fredrik Lundh

    #2
    Re: Addressing the modem via pyserial

    Doru-Catalin Togea wrote:
    [color=blue]
    > In the HyperTerminal which comes with Win XP Pro, I can set up a
    > connection to COM3 and there type the 'atdt1234' command. It works (I get
    > a call since I have the modem connected to a device with a phone on it).[/color]

    even without pressing enter?
    [color=blue]
    > My question is actually: will an at-command like 'atdt1234' translate to
    > ser.write('atdt 1234')?[/color]

    try

    ser.write('atdt 1234\r\n')

    or just

    ser.write('atdt 1234\n')

    </F>



    Comment

    • Roel Schroeven

      #3
      Re: Addressing the modem via pyserial

      Doru-Catalin Togea schreef:[color=blue]
      > My question is actually: will an at-command like 'atdt1234' translate to
      > ser.write('atdt 1234')?[/color]

      You'll have to include the end-of-line; I guess 'atdt1234\n' should
      work, otherwise you can try 'atdt1234\r\n' or 'atdt1234\r'.

      Also, don't forget that you have to set the modem into command mode if
      it was not already (using '+++' and a pause before and/or after that
      IIRC), but I guess that's not the problem in this case.
      [color=blue]
      > Secondly, a modem question: I have found a lot of web pages about
      > at-commands listing the hayes command set. Still many of them do not
      > seem to work on two different modems I have tried. Like '&$' should
      > display an overview of the commands supported by the modem. Ii tried
      > this in the HyperTerminal where I can place the above mentioned call,
      > and I get 'ERROR'. I also get 'ERROR' for most other commands I try.[/color]

      Unfortunately the hayes command set is not a well-defined standard
      supported by all modems. There are almost as many variations as there
      are modems. In the good old days the user manual that came with the
      modem had an overview of the available commands for that modem.

      --
      If I have been able to see further, it was only because I stood
      on the shoulders of giants. -- Isaac Newton

      Roel Schroeven

      Comment

      Working...