home *** CD-ROM | disk | FTP | other *** search
/ World of Ham Radio 1997 / WOHR97_AmSoft_(1997-02-01).iso / packet / pak_14 / amsoft.iii next >
Text File  |  1997-02-01  |  13KB  |  383 lines

  1.  
  2.  
  3.  
  4.                 GPRI - The Graphic Packet Remote-Interface
  5.  
  6.                                 Version 1.0
  7.  
  8.                      (C) Ulf Saran, DH1DAE, 1990-1993
  9.  
  10.  
  11.                        This document was written by
  12.        Stefan Pfeiffer, DD9EP@DB0IZ, 930401, last modification 930422
  13.  
  14.  
  15.  
  16.                         S P E C I F I C A T I O N
  17.                         -------------------------
  18.  
  19.  
  20.  
  21. 0. Overview
  22.  
  23.  
  24.   1. Introduction
  25.  
  26.   2. Interrupt-Functions of Interrupt 2Fh
  27.     2.1. Function FFh - Get Version Number
  28.     2.2. Function 00h - Register as Remoteprogramme
  29.     2.3. Function 01h - Get FileTransfer-Address
  30.     2.4. Function 02h - Get QSO-Data-Address
  31.  
  32.   3. GPRI-Routines
  33.     3.1. The GPRI-Transmitting-Routine
  34.     3.2. The GPRI-FileTransfer-Routine
  35.     3.3. The GPRI-QSO-Data-Routine
  36.  
  37.   4. Required Routines of the Remote-Programme
  38.     4.1. The Initialisation-Routine
  39.     4.2. The Receiving-Routine
  40.     4.3. The Strategy-Routine
  41.     4.4. The Exit-Routine
  42.  
  43.   5. Schematic Structure of a GPRI-Programme
  44.  
  45.   6. Hints & Clues
  46.  
  47.  
  48.  
  49. 1. Introduction
  50.  
  51.   The GPRI is a collection of functions which allow external DOS-programmes to
  52.   communicate with GP and to control it in a restricted way.
  53.   This allows the remote-programme to transmit and receive texts directly from
  54.   its execution. It has not to care for the handling of the TNC, as this task
  55.   is completely done by GP.
  56.  
  57.   When executing a interactive remote-programme (that uses the GPRI), GPRI loads  the programme in the memory and, after the remote-programme has "registered"
  58.   itself, executes a initialisation-routine, in which the programme can send
  59.   a startup-message, for example.
  60.   Then GPRI will call a specific routine in the remote-programme whenever a
  61.   text was received on that channel. In this routine the remote-programme can
  62.   react on the text and send back an answer.
  63.   GPRI will unload the program from memory when the remote-programme
  64.   requests GPRI to do so.
  65.   So the GPRI is completely based on a client/server-structure between GP and
  66.   the remote-programme, as the remote-programme requests services like "send
  67.   string", "send file" and "get QSO-data" directly from the GPRI.
  68.  
  69.   This allows to operate remote-programmes via PR like DOS-programmes, that is
  70.   per a interactive communication with the program. This offers much more
  71.   possibilities for remote-programmes as before.
  72.  
  73.   This document describes the interface between GP and the interactive remote
  74.   -programme. It is independent of the used programming-language, but it should
  75.   be able to call interrupts and imbed assembler-commands. I presuppose some
  76.   knowledge on programming, as the GPRI and its programming are relatively
  77.   complex and susceptible to errors.
  78.  
  79.   This is caused by the fact that a GPRI-programme has no real main routine,
  80.   and that nearly all actions are done in the routines which are called by
  81.   the GPRI.
  82.  
  83. 2. Interrupt-Functions of Interrupt 2Fh
  84.  
  85.   To get in touch with GPRI, the remote-programme uses the interrupt 2Fh.
  86.   By this interrupt it is able to determine if it is running under GPRI and
  87.   which version of the GPRI is supported. It can also get the address of the
  88.   transmitting-routine and can "register" its own routines at the GPRI.
  89.  
  90.   To attract GPRI, the remoteprogramme has to load the value DFh into the
  91.   register AH, the functionnumber will be loaded in AL.
  92.  
  93.  
  94.   2.1. Function FFh - Get Version Number
  95.  
  96.     By this function the remoteprogramme can determine if it is running under
  97.     GPRI and which version of GPRI is supported.
  98.  
  99.     Input:
  100.       AH: DFh    (Code to attract the GPRI)
  101.       AL: FFh    (Functionnumber)
  102.  
  103.     Output:
  104.       If AX contains the value 4750h,the remote-programme is running under GPRI
  105.       (4750h is equal to 'GP' in ASCII).
  106.       Then the following values are valid:
  107.         BH: Versionnumber
  108.         BL: Revisionnumber
  109.  
  110.       When running under GPRI version 1.0, BH is 1 and BL is 0.
  111.  
  112.       If AX is unequal 4750h, the remote-programme runs under DOS and the GPRI
  113.       is not active.
  114.  
  115.  
  116.   2.2. Function 00h - Register as Remoteprogramme
  117.  
  118.     By this function the remote-programme registers itself at GPRI, and gets
  119.     the address of the GPRI-transmitting-routine and a handle which
  120.     identifies the programme while communicating with the GPRI.
  121.     This function has to be called before calling any other GPRI-routine.
  122.  
  123.     Input:
  124.       AH: DFh    (Code to attract the GPRI)
  125.       AL: 00h    (Functionnumber)
  126.       ES: Segment of the following structure
  127.       BX: Offset of the following structure
  128.  
  129.         PrefixSegment of the remote-programme : WORD
  130.         Address of the initialisation-routine : POINTER
  131.         Address of the receiving-routine      : POINTER
  132.         Address of the strategy-routine       : POINTER
  133.         Address of the exit-routine           : POINTER
  134.  
  135.     Output:
  136.       If AX is unequal 4750h ('GP'), an error has occured.
  137.       if AX contains 4750h, the following values are valid:
  138.         ES: Segment of the GPRI-transmitting-routine
  139.         BS: Offset of the GPRI-transmitting-routine
  140.         CL: Handle of the remote-programme
  141.  
  142.     Description of the transmitting-routine:  3.1.
  143.     Description of the routines in the structure:  4.
  144.  
  145.  
  146.   2.3. Function 01h - Get FileTransfer-Address
  147.  
  148.     By this function the remote-programme can get the address of the GPRI
  149.     -routine to send a file.
  150.  
  151.     Input:
  152.       AH: DFh    (Code to attract the GPRI)
  153.       AL: 01h    (Functionnumber)
  154.  
  155.     Output:
  156.       If AX is unequal 4750h ('GP'), an error has occured.
  157.       If AX contains 4750h, the following values are valid:
  158.         ES: Segment of the filetransfer-routine
  159.         BX: Offset of the filetransfer-routine
  160.  
  161.     Description of the filetransfer-routine:  3.2.
  162.  
  163.  
  164.   2.4. Function 02h - Get QSO-Data-Address
  165.  
  166.     By this function the remote-programme gets the address of the GPRI-routine
  167.     to get the actual QSO-data.
  168.  
  169.     Input:
  170.       AH: DFh    (Code to attract the GPRI)
  171.       AL: 02h    (Functionnumber)
  172.  
  173.     Output:
  174.       If AX is unequal 4750h ('GP'), an error has occured.
  175.       If AX contains 4750h, the following values are valid:
  176.         ES: Segment of the QSO-data-routine
  177.         BX: Offset of the QSO-data-routine
  178.  
  179.     Description of the QSO-data-routine:  3.3.
  180.  
  181.  
  182. 3. GPRI-Routines
  183.  
  184.  
  185.   3.1. The GPRI-Transmitting-Routine
  186.  
  187.     The Address of this routine can be obtained by the interrupt-function
  188.     00h. It must be called with a FAR CALL, like all GPRI-routines.
  189.  
  190.     The registers have to following meaning:
  191.  
  192.     BL: Handle of the remote-programme
  193.     BH: Prompt-flag (1 -> Flush sendbuffer, 0 -> Do not flush sendbuffer)
  194.     CL: Macro-flag (1 -> Expand macros, 0 -> Do not expand macros)
  195.     ES: Segment of the string to send
  196.     DX: Offset of the string to send
  197.  
  198.     This string is a pascal-string with a leading lengthbyte. It is not
  199.     terminated by a binary 0.
  200.     If the string coudn't be sent by GP (e.g. no TNC buffers), AX contains
  201.     0, else 1.
  202.  
  203.   3.2. The GPRI-FileTransfer-Routine
  204.  
  205.     This routine allows the remote-programme to transmit any file. First the
  206.     address of this routine has to  be obtained with the interrupt-function 01h.    This routine has to be called with a FAR CALL, too.
  207.  
  208.     Meaning of the registers:
  209.  
  210.     BL: Handle of the remote-programme
  211.     BH: Mode of the filetransfer
  212.         0: Textfile
  213.         1: Binary file, no AutoBin
  214.         2: AutoBin
  215.  
  216.     ES: Segment of the filename
  217.     DX: Offset of the filename
  218.  
  219.     Please notice that the filename is a pascal-like string with a leading
  220.     lengthbyte and without a terminating 0.
  221.  
  222.     After calling this function, AX contains 1, if no error occured, else 0.
  223.  
  224.     The strategy-routine will NOT be called during a filetransfer.
  225.  
  226.  
  227.   3.3. The GPRI-QSO-Data-Routine
  228.  
  229.     By this routine, the remote-programme can get information about the actual
  230.     QSO. The address of the routine has to be obtained by the function 02h,
  231.     it has to be called by a FAR CALL.
  232.  
  233.     Meaning of the registers:
  234.  
  235.     BL: Handle of the remote-programme
  236.     ES: Segment of the following structure
  237.     DX: Offset of the following structure
  238.  
  239.       MyCall : String[9]     (Mycall on the actual channel)
  240.       Call   : String[9]     (Call of the remote station)
  241.       Name   : String[80]    (Name of the remote station)
  242.       Path   : String[255]   (Connect-path to the remote-station)
  243.  
  244.     Please take again care of the strings being pascal-strings with a leading
  245.     lengthbyte. So the MyCall-string is 10 bytes long: 1 lengthbyte and 9
  246.     databytes. The length of the structure is 357 bytes due to this fact.
  247.     If the function call succeeded and the structure contains the QSO data,
  248.     AX contains 1, else 0.
  249.  
  250.  
  251. 4. Required Routines of the Remote-Programme
  252.  
  253.   The addresses of the following routines have to be made public to the GPRI
  254.   via the function 00h. All these routines have to be compiled FAR!
  255.  
  256.   4.1. The Initialisiation-Routine
  257.  
  258.     Input:
  259.       No
  260.  
  261.     Output:
  262.       BL: Flag to end programme (0 -> No, 1 -> Yes)
  263.  
  264.     This routine will be called by the GPRI after the remote-programme has been
  265.     loaded into memory. Here you can, for example, transmit a startup-
  266.     message.
  267.  
  268.     NOTICE: Do not use a GPRI-routine in the main-routine of the remote-
  269.     programme, as this might cause some problems. Please send the startup-
  270.     message in the initialisation-routine, not earlier!
  271.  
  272.  
  273.   4.2. The Receiving-Routine
  274.  
  275.     Input:
  276.       ES: Segment of the received string
  277.       DX: Offset of the received string
  278.  
  279.       This is again a pascal-like string with a leading lengthbyte.
  280.  
  281.     Output:
  282.       BL: Flag to end programme (0 -> No, 1 -> Yes)
  283.  
  284.  
  285.     This routine will be called whenever GP has received a text on the actual
  286.     channel. The routine can evaluate the received text, send back a text or
  287.     a file and perhaps set BL to 0 to end itself.
  288.  
  289.  
  290.   4.3. The Strategy-Routine
  291.  
  292.     Input:
  293.       No
  294.  
  295.     Output:
  296.       BL: Flag to end programme (0 -> No, 1 -> Yes)
  297.  
  298.     This routine will be called by GP periodically, except during file-
  299.     transfers. This routine can be used as a timer or to determine the end
  300.     of a filetransfer.
  301.  
  302.  
  303.   4.4. The Exit-Routine
  304.  
  305.     Input:
  306.       No
  307.  
  308.     Output:
  309.       No
  310.  
  311.     This routine will be called before GPRI removes the remote-programme from
  312.     the memory. This will happen in the following cases:
  313.     a) The programme has set BL to 1 to request its termination.
  314.     b) The QSO has been interrupted by an re- or disconnect.
  315.     c) GP has been left.
  316.  
  317.  
  318. 5. Schematic Structure of a GPRI-Programme
  319.  
  320.   To make the GPRI-principle a bit more clearly, I will describe the
  321.   schematic structure of a GPRI-programme in the following.
  322.   It is recommended that your remote-programmes are executable under GPRI and
  323.   DOS. So your programme should accept input from the keyboard and display
  324.   its texts on the screen when realizing that it is NOT running under GPRI.
  325.   But there is also the possibility that your program simply stops execution.
  326.  
  327.   Now the scheme of a GPRI-programme:
  328.  
  329.   PROCEDURE Init      (FAR!)
  330.   {
  331.     Send startup-message via transmitting-routing
  332.     Set BL to 0 (No termination of programme)
  333.   }
  334.  
  335.   PROCEDURE Receive   (FAR!)
  336.   {
  337.     Analyze received text
  338.     Send back text or file
  339.     Set BL to 1 if the programme should be terminated, else set BL to 0
  340.   }
  341.  
  342.   PROCEDURE Exit      (FAR!)
  343.   {
  344.     Deallocate memory and do other tiding-up-actions
  345.   }
  346.  
  347.   PROCEDURE Main      (The real main routine)
  348.   {
  349.     Get version of GPRI
  350.  
  351.     If an error occured, then normally work under DOS or terminate
  352.  
  353.     Register adresses of the routines Init,Receive and Exit and also
  354.     the prefix-segment to GPRI, save address of transmitting-routine and the
  355.     handle
  356.  
  357.     Save addresses of the QSO-data-routine and the filetransfer-routine, if
  358.     needed
  359.  
  360.     Terminate programme but stay resident in memory (by command of the
  361.     programming language or by interrupt 21h, function 31h)
  362.   }
  363.  
  364.  
  365. 6. Hints & Clues
  366.  
  367.   You are asked to restrict the heap- und stacksize of your programme, as it
  368.   stays resident in the memory. You can also lower the stacksize, as the
  369.   programme will use the stack of GP.
  370.  
  371.  
  372.  
  373.  
  374.   Enjoy the unbelievable possibilities of interactive remote-programmes and
  375.   the programming of the GPRI.
  376.  
  377.  
  378.  
  379.                                               Vy 73, Stefan Pfeiffer, DD9EP
  380.  
  381.  
  382. This text has been checked and corrected by Pete, PE1MHO. THANKS!
  383.