home *** CD-ROM | disk | FTP | other *** search
/ NetComm Communications 5 / NetComm.iso / drivers / msmail / inmodem.mdm < prev    next >
Encoding:
Text File  |  1997-09-25  |  11.8 KB  |  504 lines

  1. ;**************************************************************************
  2. ;       Microsoft Mail Script File
  3. ;
  4. ;       Filename: INMODEM
  5. ;       Date    : 09/09/97
  6. ;       Script  : For NetComm InModem Series
  7. ;                 144/288/336/k56flex 
  8. ;
  9. ;     This script file contains the standard modem setup strings used by
  10. ;  the External, Transmit and Listen programs.  There are five procedures
  11. ;  defined in this script file for setting up the modem and for connecting
  12. ;  to a remote External machine.
  13. ;
  14. ;     The modem setup strings used here will be adequate for most people
  15. ;  but there may be some changes required if you are dialing overseas and
  16. ;  require a longer wait for Carrier Detect (S7 register) or if you wish
  17. ;  to change the speaker volume.  Note that if you used the -Innn option 
  18. ;  in version 1.0 or 2.0 that you will have to modify the S7 register and
  19. ;  recompile this script file.
  20. ;
  21. ;     Consult your modem manual for more information on setup options.
  22. ;
  23. ;  Script procedures defined:
  24. ;       INITIALIZE
  25. ;       RESET
  26. ;       CALL
  27. ;       ANSWER
  28. ;       DISCONNECT
  29. ;
  30. ;  Return codes for External, Transmit, Listen:
  31. ;       0  - OK
  32. ;       1  - CONNECT 300
  33. ;       2  - not defined
  34. ;       3  - NO CARRIER
  35. ;       4  - ERROR
  36. ;       5  - CONNECT 1200
  37. ;       6  - not defined
  38. ;       7  - BUSY
  39. ;       8  - NO ANSWER
  40. ;       9  - not defined
  41. ;      10  - CONNECT 2400
  42. ;      11  - not defined
  43. ;      12  - CONNECT 9600 (high speed connection)
  44. ;
  45. ;
  46. ;**************************************************************************
  47.  
  48.  
  49. INITIALIZE:
  50.         title "NetComm InModem 144/288/336/56flex"
  51.  
  52.     baud 57600             ; set the baud rate
  53.     display "   Baud Rate : 57600"
  54.     $attempts = 5
  55.  
  56. init_retry:
  57.         display "Resetting modem" 
  58.     sendln "AT"
  59.     waitrsp 1
  60.         sendln "AT&F"           ; reset modem to default settings
  61.     wait 2
  62.     waitrsp 1
  63.  
  64.     if ("0" isin response)
  65.         display "Successfully reset"
  66.         goto reset_okay
  67.  
  68.     if ("OK" isin response)
  69.         display "Successfully reset"
  70.         {
  71. reset_okay:
  72.             display "Initializing modem"
  73.             sendln "ATE0M1V0W2X3"
  74.         wait 2
  75.         waitrsp 3
  76.  
  77.         if ("0^M" isin response)
  78.             Display "Successfully initialized"
  79.         {
  80.                 Display "S Registers now being set" 
  81.                 sendln "ATS0=0S7=60S95=0&W"
  82.         waitrsp 3
  83.         if (response = "0^M")
  84.                     Display "S Registers set successfully"
  85.             return 0
  86.         }
  87.          }
  88.     dec $attempts
  89.     if ($attempts > 0)
  90.         goto init_retry
  91.  
  92.     return 4
  93.  
  94.  
  95. RESET:
  96.     baud 57600              ; set the baud rate
  97.     display "   Baud Rate : 57600"
  98.  
  99.     clearrsp               ; clear out any ring signals
  100.         display "ATZ being sent to modem"
  101.     sendln "ATZ"           ; reset modem to default settings
  102.     waitrsp 3
  103.  
  104.     if (response = "0^M")
  105.          return 0
  106.     else
  107.          return 4
  108.  
  109.  
  110. CALL:
  111.     $ret = 8               ; set default ret code to "no answer"
  112.  
  113.     clearrsp               ; clear the response buffer 
  114.  
  115.     echo 0                 ; do not display phone number
  116.  
  117.     sendln "ATD" + dial_mode + phone_number  ; execute the dial up 
  118.  
  119.     echo 1                 ; turn echo back on
  120.  
  121.     waitrsp 120            ; wait until the modem responds (max 2 minutes)
  122.  
  123.       if ("179^M" isin response)
  124.       {
  125.         display ">>> CONNECT 60000 <<<"
  126.       $ret = 12
  127.       }
  128.       else if ("178^M" isin response)
  129.       {
  130.         display ">>> CONNECT 58000 <<<"
  131.       $ret = 12
  132.       }
  133.       else if ("177^M" isin response)
  134.       {
  135.         display ">>> CONNECT 56000 <<<"
  136.       $ret = 12
  137.       }
  138.       else if ("176^M" isin response)
  139.       {
  140.         display ">>> CONNECT 54000 <<<"
  141.       $ret = 12
  142.       }
  143.       else if ("175^M" isin response)
  144.       {
  145.         display ">>> CONNECT 52000 <<<"
  146.       $ret = 12
  147.       }
  148.       else if ("174^M" isin response)
  149.       {
  150.         display ">>> CONNECT 50000 <<<"
  151.       $ret = 12
  152.       }
  153.       else if ("173^M" isin response)
  154.       {
  155.         display ">>> CONNECT 48000 <<<"
  156.       $ret = 12
  157.       }
  158.       else if ("172^M" isin response)
  159.       {
  160.         display ">>> CONNECT 46000 <<<"
  161.       $ret = 12
  162.       }
  163.       else if ("171^M" isin response)
  164.       {
  165.         display ">>> CONNECT 44000 <<<"
  166.       $ret = 12
  167.       }
  168.       else if ("170^M" isin response)
  169.       {
  170.         display ">>> CONNECT 42000 <<<"
  171.       $ret = 12
  172.       }
  173.       else if ("169^M" isin response)
  174.       {
  175.         display ">>> CONNECT 40000 <<<"
  176.       $ret = 12
  177.       }
  178.       else if ("168^M" isin response)
  179.       {
  180.         display ">>> CONNECT 38000 <<<"
  181.       $ret = 12
  182.       }
  183.       else if ("167^M" isin response)
  184.       {
  185.         display ">>> CONNECT 36000 <<<"
  186.       $ret = 12
  187.       }
  188.       else if ("166^M" isin response)
  189.       {
  190.         display ">>> CONNECT 34000 <<<"
  191.       $ret = 12
  192.       }
  193.       else if ("165^M" isin response)
  194.       {
  195.         display ">>> CONNECT 32000 <<<"
  196.       $ret = 12
  197.       }
  198.       else if ("84^M" isin response)
  199.       {
  200.         display ">>> CONNECT 33600 <<<"
  201.       $ret = 12
  202.       }
  203.       else if ("91^M" isin response)
  204.       {
  205.         display ">>> CONNECT 31200 <<<"
  206.       $ret = 12
  207.       }
  208.       else if ("64^M" isin response)
  209.       {
  210.       display ">>> CONNECT 28800 <<<"
  211.       $ret = 12
  212.       }
  213.     else if ("63^M" isin response)
  214.       {
  215.       display ">>> CONNECT 26400 <<<"
  216.       $ret = 12
  217.       }
  218.     else if ("62^M" isin response)
  219.       {
  220.       display ">>> CONNECT 24000 <<<"
  221.       $ret = 12
  222.       }
  223.     else if ("61^M" isin response)
  224.       {
  225.       display ">>> CONNECT 21600 <<<"
  226.       $ret = 12
  227.       }
  228.       else if ("16^M" isin response)
  229.       {
  230.         display ">>> CONNECT 19200 <<<"
  231.       $ret = 12
  232.       }
  233.     else if ("59^M" isin response)
  234.       {
  235.       display ">>> CONNECT 16800 <<<"
  236.       $ret = 12
  237.       }
  238.     else if ("15^M" isin response)
  239.       {
  240.       display ">>> CONNECT 14400 <<<"
  241.       $ret = 12
  242.       }
  243.     else if ("14^M" isin response)
  244.       {
  245.       display ">>> CONNECT 12000 <<<"
  246.       $ret = 12
  247.       }
  248.     else if ("12^M" isin response)
  249.       {
  250.       display ">>> CONNECT 9600 <<<"
  251.       $ret = 12
  252.       }
  253.       else if ("13^M" isin response)
  254.       {
  255.         display ">>> CONNECT 7200 <<<"
  256.         $ret = 13
  257.       }
  258.     else if ("11^M" isin response)
  259.       {
  260.       display ">>> CONNECT 4800 <<<"
  261.       $ret = 11
  262.       }
  263.     else if ("10^M" isin response)
  264.       {
  265.       display ">>> CONNECT 2400 <<<"
  266.       $ret = 10
  267.       }
  268.     else if ("7^M" isin response)
  269.       {
  270.       display ">>> BUSY <<<"
  271.       $ret = 7             ; busy
  272.       }
  273.     else if ("5^M" isin response)
  274.       {
  275.       display ">>> CONNECT 1200 <<<"
  276.       $ret = 5
  277.       }
  278.     else if ("3^M" isin response)
  279.       {
  280.       display ">>> NO CARRIER <<<"
  281.       $ret = 8             ; no answer or no connect
  282.       }
  283.     else if ("1^M" isin response)
  284.       {
  285.       display ">>> CONNECT 300 <<<"
  286.       $ret = 1
  287.       }
  288.  
  289.     return $ret            ; return connect baud rate to application 
  290.     
  291.  
  292.  
  293. ANSWER:
  294.     $ret = 8               ; set default ret code to "no answer"
  295.  
  296.     waitrsp 1              ; see if phone is ringing 
  297.  
  298.     if ("2^M" isin response)  ; 2 is numeric form of "RING" 
  299.         {
  300.         if (listen = 1)    ; see if Listen program is running or not
  301.         sendln "ATD"   ; answer phone in originate mode (Listen)
  302.         else
  303.         sendln "ATA"   ; answer the phone normally
  304.  
  305.         waitrsp 120        ; wait for return code from modem (max 2 minutes)
  306.  
  307.  
  308.         if (response = "1^M")
  309.           {
  310.           display ">>> CONNECT 300 <<<"
  311.           $ret = 1
  312.           }
  313.         else if (response = "3^M")
  314.           {
  315.           display ">>> NO CARRIER <<<"
  316.           $ret = 8             ; no answer or no connect
  317.           }
  318.         else if (response = "5^M")
  319.           {
  320.           display ">>> CONNECT 1200 <<<"
  321.           $ret = 5
  322.           }
  323.         else if (response = "10^M")
  324.           {
  325.           display ">>> CONNECT 2400 <<<"
  326.           $ret = 10
  327.           }
  328.         else if (response = "11^M")
  329.           {
  330.           display ">>> CONNECT 4800 <<<"
  331.           $ret = 11
  332.           }
  333.           else if (response = "13^M")
  334.           {
  335.             display ">>> CONNECT 7200 <<<"
  336.             $ret = 13
  337.           }
  338.         else if (response = "12^M")
  339.           {
  340.           display ">>> CONNECT 9600 <<<"
  341.           $ret = 12
  342.           }
  343.         else if (response = "14^M")
  344.           {
  345.             display ">>> CONNECT 12000 <<<"
  346.           $ret = 12
  347.           }
  348.        else if (response = "15^M")
  349.           {
  350.           display ">>> CONNECT 14400 <<<"
  351.           $ret = 12
  352.           }
  353.        else if ("59^M" isin response)
  354.           {
  355.           display ">>> CONNECT 16800 <<<"
  356.           $ret = 12
  357.           }
  358.          else if (response = "16^M")
  359.           {
  360.           display ">>> CONNECT 19200 <<<"
  361.           $ret = 12
  362.           }
  363.        else if ("61^M" isin response)
  364.           {
  365.           display ">>> CONNECT 21600 <<<"
  366.           $ret = 12
  367.           }
  368.        else if ("62^M" isin response)
  369.           {
  370.           display ">>> CONNECT 24000 <<<"
  371.           $ret = 12
  372.           }
  373.        else if ("63^M" isin response)
  374.           {
  375.           display ">>> CONNECT 26400 <<<"
  376.           $ret = 12
  377.           }
  378.        else if ("64^M" isin response)
  379.           {
  380.             display ">>> CONNECT 28800 <<<"
  381.           $ret = 12
  382.           }
  383.          else if ("91^M" isin response)
  384.             {
  385.             display ">>> CONNECT 31200 <<<"
  386.             $ret = 12
  387.             }
  388.          else if ("84^M" isin response)
  389.             {
  390.             display ">>> CONNECT 33600 <<<"
  391.             $ret = 12
  392.             }
  393.         else if ("165^M" isin response)
  394.           {
  395.             display ">>> CONNECT 32000 <<<"
  396.           $ret = 12
  397.           }
  398.         else if ("166^M" isin response)
  399.           {
  400.             display ">>> CONNECT 34000 <<<"
  401.         $ret = 12
  402.         }
  403.       else if ("167^M" isin response)
  404.         {
  405.           display ">>> CONNECT 36000 <<<"
  406.         $ret = 12
  407.         }
  408.         else if ("168^M" isin response)
  409.         {
  410.           display ">>> CONNECT 38000 <<<"
  411.          $ret = 12
  412.         }
  413.         else if ("169^M" isin response)
  414.         {
  415.           display ">>> CONNECT 40000 <<<"
  416.         $ret = 12
  417.         }
  418.         else if ("170^M" isin response)
  419.           {
  420.             display ">>> CONNECT 42000 <<<"
  421.           $ret = 12
  422.           }
  423.         else if ("171^M" isin response)
  424.           {
  425.             display ">>> CONNECT 44000 <<<"
  426.           $ret = 12
  427.           }
  428.         else if ("172^M" isin response)
  429.           {
  430.             display ">>> CONNECT 46000 <<<"
  431.           $ret = 12
  432.           }
  433.         else if ("173^M" isin response)
  434.           {
  435.             display ">>> CONNECT 48000 <<<"
  436.           $ret = 12
  437.           }
  438.         else if ("174^M" isin response)
  439.           {
  440.             display ">>> CONNECT 50000 <<<"
  441.           $ret = 12
  442.           }
  443.         else if ("175^M" isin response)
  444.           {
  445.             display ">>> CONNECT 52000 <<<"
  446.           $ret = 12
  447.           }
  448.         else if ("176^M" isin response)
  449.           {
  450.             display ">>> CONNECT 54000 <<<"
  451.           $ret = 12
  452.           }
  453.         else if ("177^M" isin response)
  454.           {
  455.             display ">>> CONNECT 56000 <<<"
  456.           $ret = 12
  457.           }
  458.         else if ("178^M" isin response)
  459.           {
  460.             display ">>> CONNECT 58000 <<<"
  461.           $ret = 12
  462.           }
  463.         else if ("179^M" isin response)
  464.             {
  465.             display ">>> CONNECT 60000 <<<"
  466.           $ret = 12
  467.           }
  468.  
  469.       if ($ret = 8)            ; if there was no answer, make sure that
  470.           {                    ;   modem goes back on hook.  There seems
  471.           dtr 0                ;   to be a problem with these modems
  472.           wait 1               ;   where the modem can sometimes refuse
  473.           dtr 1                ;   to hang up if ATA fails to establish
  474.           }                    ;   a connection.
  475.        }
  476.  
  477.     return $ret            ; return connect baud rate to application 
  478.     
  479. DISCONNECT:
  480.     wait 2                 ; wait 2 seconds 
  481.  
  482.     send "+++"             ; send escape sequence to put modem back to 
  483.                      ; command state 
  484.     wait 2                 ; wait 2 seconds 
  485.  
  486.     waitrsp 3              ; wait for response from modem
  487.  
  488.     clearrsp               ; clear the response buffer 
  489.  
  490.     sendln "ATH0"          ; hang up the phone 
  491.  
  492.     waitrsp 3              ; wait for a response 
  493.  
  494.     if (response != "0^M") ; if hang up failed, drop DTR to force hang up
  495.         {
  496.         DTR 0              ; drop DTR to reset modem 
  497.         wait 2             ; some modems require a delay here
  498.         DTR 1              ; raise DTR 
  499.         clearrsp           ; clear response buffer
  500.         }
  501.  
  502.     return 0               ; always return OK
  503.  
  504.