home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / MODEM / MNPC12.ZIP / MNPC.DOC < prev    next >
Encoding:
Text File  |  1987-11-30  |  16.4 KB  |  482 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.      
  8.      
  9.      
  10.      
  11.      
  12.                          The Microcom MNP Library
  13.                           (Microsoft C Version)
  14.      
  15.      
  16.      
  17.                            PROGRAMMER'S MANUAL
  18.      
  19.      
  20.      
  21.      
  22.      
  23.      
  24.      
  25.      
  26.      
  27.      
  28.      
  29.      
  30.      
  31.      
  32.                                 Version 1.0
  33.      
  34.                              December 15, 1987
  35.      
  36.      
  37.      
  38.      
  39.      
  40.      
  41.      
  42.      
  43.      
  44.      
  45.      
  46.      
  47.      
  48.      
  49.      
  50.      
  51.      
  52.      
  53.      
  54.      
  55.      
  56.      
  57.      
  58.                               Microcom, Inc.
  59.                           1400 Providence Highway
  60.                             Norwood, MA 02062
  61.  
  62.  
  63.  
  64.  
  65.  
  66.      
  67.      
  68.      The Microcom MNP Library and MNP are trademarks of Microcom, Inc.
  69.      Microsoft and MS-DOS are trademarks of Microsoft Corporation.  
  70.      IBM is a registered trademark of International Business Machines.
  71.      
  72.      
  73.      This manual is not subject to copyright and may be freely copied.
  74.      
  75.      
  76.      
  77.      
  78.      
  79.      
  80.      
  81.      
  82.      
  83.      
  84.      
  85.      
  86.      
  87.      
  88.      
  89.      
  90.      
  91.      
  92.      
  93.      
  94.      
  95.      
  96.      
  97.      
  98.      
  99.      
  100.      
  101.      
  102.      
  103.      
  104.      
  105.      
  106.      
  107.      
  108.      
  109.      
  110.      Questions relating to the Microcom MNP Library should be directed to
  111.      Microcom at:
  112.      
  113.                               Microcom, Inc.
  114.                        15303 Ventura Blvd., Suite 900
  115.                           Sherman Oaks, CA 91403
  116.                                (818)986-4212
  117.  
  118.  
  119.  
  120.  
  121.  
  122.      
  123.      1. INTRODUCTION
  124.      
  125.           The Microcom MNP Library is a set of subroutines which implement the
  126.      stream mode of the link protocol in Microcom Networking Protocol (MNP).
  127.      This mode of the MNP link protocol is appropriate for interworking with MNP
  128.      error-correcting modems or with other software implementations which use
  129.      the Microcom MNP Library or other compatible software.
  130.      
  131.           This version of the library provides a set of C and assembly
  132.      language routines which are designed to be easily integrated into an
  133.      application program written in C and compiled using the Microsoft C
  134.      compiler (version 4.0).  Through the use of these routines, an
  135.      application is able to perform error-free data communications over a
  136.      physical-connection, such as one established on the public switched
  137.      telephone network.
  138.      
  139.           These MNP Library subroutines are especially for the IBM Personal
  140.      Computer family (and compatibles) under PCDOS (MS-DOS).  Hardware
  141.      facilities for asynchronous communications are required.
  142.  
  143.  
  144.  
  145.  
  146.  
  147.      2. LIBRARY MODULES
  148.      
  149.           The Microcom MNP LIbrary is supplied in one of two forms, object
  150.      library only and object library with source.  The source version is de-
  151.      scribed in more detail in a file ('readme.doc') supplied as part of the
  152.      source version distribution.
  153.      
  154.           In the case of the object library only form, the distribution diskette
  155.      contains one file, mnp.lib, which includes the various object modules
  156.      which make up the MNP Library.
  157.      
  158.           When building the executable form of a particular application, the
  159.      mnp.lib file should be specified if the application calls any MNP sub-
  160.      routine described in this document.  The manner in which library modules
  161.      are specified for inclusion varies according to the linkage editor
  162.      employed in building the application program run module.
  163.  
  164.  
  165.  
  166.  
  167.  
  168.      3. LINK MANAGEMENT
  169.      
  170.           In general, the MNP link follows the life of the normal physical-
  171.      connection.  Immediately after the physical-connection is made (e.g. after
  172.      a modem first reports carrier detected), the application must attempt the
  173.      establishment of the Link via the MNPCONNECT subroutine.  MNP-capable
  174.      modems which answer the incoming telephone call, for example, must receive
  175.      the Link establishment sequence within 4 seconds of physical-connection
  176.      establishment.  If a link is not attempted within this period, such modems
  177.      may fall back to a normal connection and it will not be possible to provide
  178.      a reliable connection on that particular call.
  179.      
  180.           Link termination, performed via the MNPDISCONNECT call, should
  181.      immediately precede termination of the physical-connection, i.e. right
  182.      before hanging up the telephone.  Note that the Link is active for the
  183.      entire duration of the physical-connection.
  184.      
  185.           During the data phase of the Link (i.e. after establishment but before
  186.      termination), the Link must be kept running by allowing the Link code to
  187.      execute periodically.  Any of the data phase calls, namely MNPSEND,
  188.      MNPRECEIVE, MNPSTATUS, and MNPBREAK, will accomplish this.  One of these
  189.      routines must be called every 250ms or so which means that the Link code
  190.      gets a chance to run about 4 times per second.  The absolute interval is
  191.      not critical and it may be possible to reduce the frequency as well and
  192.      still get reasonable performance.  Polling the Link code, however, must
  193.      occur with a predictable frequency otherwise the Link may be lost.  When
  194.      the Link is lost, an MNP error-correcting modem may clear the call.
  195.      
  196.           When a Link is in progress, all line I/O is performed via the
  197.      appropriate MNP call rather than by using other C mechanisms.  It 
  198.      may be the case, however, that the com port opened elsewhere in the
  199.      application, must remain open.
  200.      
  201.           Data sent and received on the Link will be "chunked" depending on the
  202.      number of bytes which happen to be sent in a single data message.  The
  203.      maximum amount in a single message is 64 bytes.  This "chunking" is not
  204.      noticeable to the sender but can be perceived by the data receiver.
  205.      Strings of data may be split over more than one data message and some
  206.      messages may have to be sent more than once when there is noise on the
  207.      connection.  Retransmission can be seen by the application as an
  208.      interruption, possibly in the middle of some data string.  The application
  209.      should be examined to see if there are any cases involving timing
  210.      dependencies which could be adversely effected by this kind of 
  211.      irregularity in the data flow.
  212.  
  213.  
  214.  
  215.  
  216.  
  217.      4. LINK INTERFACE SUBROUTINES
  218.      
  219.      4.1  Link Establishment - MNPCONNECT
  220.      
  221.           MNPCONNECT is used to establish a Link.  It is called after the
  222.      physical-connection has been established.  It can take up to 5 seconds
  223.      for an MNPCONNECT call to complete.
  224.      
  225.           MNPCONNECT has the following parameters:
  226.      
  227.                RATE - an integer which indicates the speed of the
  228.                       physical-connection, as follows:
  229.      
  230.                           1 = 110 bps
  231.                           2 = 300 bps
  232.                           4 = 1200 bps
  233.                           5 = 2400 bps
  234.      
  235.                       [Note: Other speeds are not supported in this
  236.                        version of the Microcom MNP Library.]
  237.      
  238.                FORMAT - an integer which indicates the data format,
  239.                         as follows:
  240.      
  241.                          0 = 8 data bits, no parity
  242.                          1 = 7 data bits, even parity
  243.                          2 = 7 data bits, odd parity
  244.                          3 = 7 data bits, mark parity
  245.                          4 = 7 data bits, space parity
  246.      
  247.                       [Note: In this Library version, once the Link
  248.                        is established, it is not possible to change
  249.                        format.]
  250.      
  251.                PORT -  an integer which indicates the communications
  252.                        port, as follows:
  253.      
  254.                          1 = COM1
  255.                          2 = COM2
  256.      
  257.                       [Note: This Library version does not support
  258.                        other comm ports.  Also, COM2 cannot be speci-
  259.                        fied if no COM1 is present in the system.]
  260.      
  261.                MODE - an integer which indicates the role in link
  262.                       establishment, as follows:
  263.      
  264.                          0 = link initiator (caller)
  265.                          1 = link accepter (answerer)
  266.      
  267.  
  268.  
  269.  
  270.            The function returns an integer value, as follows:
  271.  
  272.                RETCODE - an integer returned to the caller which
  273.                          indicates the result of the link
  274.                          establishment attempt, as follows:
  275.      
  276.                          0 = success (link established)
  277.      
  278.                          -64 - failure, no additional info
  279.                          -65 - failure, timeout (no remote response)
  280.                          -66 - failure, physical-connection lost
  281.                                (carrier lost)
  282.                          -70 - failure, incompatible MNP
  283.                          -72 - failure, remote protocol error
  284.      
  285.                       [Note: -70 and -72 should never occur.]
  286.      
  287.      
  288.           MNPCONNECT is called as follows:
  289.      
  290.               RETCODE = MNPCONNECT(RATE,FORMAT,PORT,MODE);
  291.  
  292.  
  293.  
  294.  
  295.  
  296.      4.2  Link Termination - MNPDISCONNECT
  297.      
  298.           MNPDISCONNECT has two functions, to send the appropriate protocol
  299.      message to the other side to indicate Link termination and to reset the PC
  300.      interrupt environment.  MNPDISCONNECT must always be called if MNPCONNECT
  301.      had been called previously.  This is so even for establishment failure or
  302.      for loss of the physical-connection (i.e. carrier lost).
  303.      
  304.           MNPDISCONNECT has no parameters and returns no value.  It is
  305.      called as follows:
  306.      
  307.                             MNPDISCONNECT();
  308.  
  309.  
  310.  
  311.  
  312.  
  313.      4.3  Send Data - MNPSEND
  314.      
  315.           MNPSEND is called to copy data to be sent on the Link from the
  316.      application into the MNP transmit buffer.
  317.      
  318.           MNPSEND has parameters as follows:
  319.      
  320.                SNDBUF - a pointer to the user char buffer from which
  321.                         transmit data is to be copied.
  322.      
  323.                BUFLEN - an integer which indicates the maximum
  324.                         number of data bytes which can be copied
  325.                         from the user buffer
  326.      
  327.            The function returns an integer value, as follows:
  328.  
  329.                RETCODE - an integer returned to the caller which
  330.                          indicates the number of bytes copied
  331.                          or a Link error condition, as follows:
  332.      
  333.                          positive int = number of bytes copied
  334.                                          0=no bytes copied
  335.      
  336.                          -64 = link terminated, retransmission limit
  337.                                exceeded
  338.                          -65 = link terminated, unable to send
  339.                          -66 = link terminated, carrier lost
  340.                          -67 = link terminated, remote disconnected
  341.      
  342.           MNPSEND is called as follows:
  343.      
  344.                   RETCODE = MNPSEND(&SNDBUF,BUFLEN)
  345.  
  346.  
  347.  
  348.  
  349.  
  350.      4.4  Receive Data - MNPRECEIVE
  351.      
  352.           MNPRECEIVE is called to copy data received on the Link into the
  353.      application.  MNPRECEIVE transfers all available data up to the size of the
  354.      application buffer.  MNPRECEIVE returns immediately if no data is
  355.      available.
  356.      
  357.           MNPRECEIVE has the following parameters:
  358.      
  359.                RCVBUF - a pointer to the user char buffer into which
  360.                         received data is to be copied. This buffer must
  361.                         be at least as long as the value of BUFLEN.
  362.      
  363.                BUFLEN - an integer which indicates the maximum
  364.                         number of data bytes which can be copied
  365.                         into the user buffer
  366.  
  367.           The function returns an integer value, as follows:
  368.     
  369.                RETCODE - an integer returned to the caller which
  370.                          indicates the number of bytes copied
  371.                          or a Link error condition, as follows:
  372.      
  373.                          positive int = number of bytes copied
  374.                                         0=no bytes available.
  375.      
  376.                          -64 = link terminated.  retransmission limit
  377.                                exceeded
  378.                          -65 = link terminated, unable to send
  379.                          -66 = link terminated,  carrier lost
  380.                          -67 = link terminated, remote disconnected
  381.      
  382.           MNPRECEIVE is called as follows:
  383.      
  384.                   RETCODE =  MNPRECEIVE(&RCVBUF,BUFLEN);
  385.  
  386.  
  387.  
  388.  
  389.  
  390.      4.5  Link Status - MNPSTATUS
  391.      
  392.           MNPSTATUS is called to return to the application the status of the
  393.      Link and to read parameters which indicate the availability of received
  394.      data or the ability to enqueue data for transmission.
  395.      
  396.           MNPSTATUS has a structure as its parameter, with members
  397.      as follows:
  398.      
  399.                PSTATUS - an integer which indicates the condition of
  400.                          the physical-connection, as follows:
  401.      
  402.                          0 = not connected (carrier not present)
  403.                          1 = connected (carrier present)
  404.      
  405.                LSTATUS - an integer which indicates the condition of
  406.                          Link, as follows:
  407.      
  408.                          0 = link not established (i.e. link
  409.                              terminated)
  410.                          1 = link established
  411.      
  412.                SCOUNT - an integer which indicates the number of
  413.                         bytes free in the Link send buffer.  This is
  414.                         the number of bytes which can be completely
  415.                         copied to the Link transmit code via an
  416.                         MNPSEND call.
  417.      
  418.                RCOUNT - an integer which indicates the number of
  419.                         received data bytes which are available to
  420.                         be copied into the application via MNPRECEIVE
  421.      
  422.                ALLSENT - an integer which indicates whether or not
  423.                          all data passed to the Link code has been
  424.                          successfully sent and acknowledged, as
  425.                          follows:
  426.      
  427.                          0 = all data not sent
  428.                          1 = all data sent
  429.      
  430.      
  431.           MNPSTATUS is called as follows:
  432.      
  433.                       MNPSTATUS(&STATUS_BLOCK);
  434.  
  435.  
  436.  
  437.  
  438.  
  439.      4.6  Send Signal - MNPBREAK
  440.      
  441.           MNPBREAK is called to send a signal to the remote DTE.  When the
  442.      remote side is an MNP error-correcting modem, an MNPBREAK call causes the
  443.      remote modem to send a break signal (continuous spacing) to its attached
  444.      DTE.
  445.      
  446.           MNPBREAK employs the MNP Link Protocol's reliable attention
  447.      mechanism in 'destructive mode'.  That is, when MNPBREAK is called, the
  448.      Link is reset and any data pending transmission on the link is discarded as
  449.      is any received data which has not been read via the MNPRECEIVE subroutine.
  450.      Data may also be discarded at the remote side of the Link.
  451.      
  452.           MNPBREAK has no parameters but returns an integer value,
  453.      as follows:
  454.      
  455.                RETCODE - an integer returned to the caller which
  456.                          indicates the result of the MNPBREAK call
  457.                          or a Link error condition, as follows:
  458.      
  459.                          0 = break initiated
  460.      
  461.                          -64 = link terminated, retransmission limit
  462.                                exceeded
  463.                          -65 = link terminated, unable to send
  464.                          -66 = link terminated, carrier lost
  465.                          -67 = link terminated, remote disconnected
  466.                          -75 = break not supported (remote did not
  467.                                negotiate attention support for this
  468.                                Link)
  469.                          -76 = previous break still in progress
  470.      
  471.      
  472.           MNPBREAK is called as follows:
  473.      
  474.                           RETCODE = MNPBREAK();
  475.      
  476.      
  477.      
  478.           [Note that the MNP Library does not support application
  479.      notification of the receipt of the MNP attention message and
  480.      hence it is assumed that MNPBREAK will only be  employed when the
  481.      remote side of the connection is an MNP error-correcting
  482.      modem.]