home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / s / sltpu70a.zip / MODEM.DOC < prev    next >
Text File  |  1992-12-13  |  12KB  |  274 lines

  1.  
  2. ------------------------------------------------------------------------
  3. Searchlight Modem Interface Unit              v2.25           April 1992
  4. ------------------------------------------------------------------------
  5.  
  6. Introduction
  7.  
  8. This unit provides functions which enable a Door program running under 
  9. Searchlight BBS (version 2.15C or later) to access Searchlight's serial port 
  10. drivers directly. While Searchlight supports Door programs indirectly via 
  11. the BIOS level output redirection, the functions provided here are important 
  12. if you wish to perform operations such as:
  13.  
  14.    ■ Output characters directly to the modem without displaying on the
  15.      local screen
  16.    ■ Output control characters or ANSI sequences directly to the modem
  17.    ■ Control the modem input and output buffers
  18.    ■ Perform your own carrier detection
  19.    ■ Hang up on the remote user
  20.  
  21. The modem functions in this unit can be used in two ways. If your door 
  22. program is run with Searchlight BIOS modem redirection active (that is, in 
  23. "Standard" or "Force-Color" mode), you can perform the majority of your 
  24. input and output via standard read and write functions which access the 
  25. BIOS, supplementing these with function calls when a special feature such as 
  26. carrier detection, or hanging up the modem, is required. Alternately, if 
  27. your DOOR program runs with BIOS redirection disabled ("None" mode), you can 
  28. do all of your modem i/o directly through the function calls. For the vast 
  29. majority of programs, the first method is preferable, since it does not 
  30. require major changes to your source code.
  31.  
  32. Because these function calls use Searchlight's drivers directly, there is no 
  33. need to write modem control functions in your application and no need to do 
  34. any kind of direct hardware addressing. In addition, if Searchlight BBS is 
  35. configured to use a FOSSIL driver or a Digiboard, all of the function calls 
  36. in this unit will automatically be routed to the FOSSIL driver or Digiboard 
  37. driver in use. Thus, your program is assured of running correctly on any 
  38. properly configured Searchlight BBS installation, regardless of the serial 
  39. port configuration.  
  40.  
  41. Note that although a Turbo Pascal source file is included, most functions 
  42. resolve to straight 8086 interrupt calls. This means that the functions are 
  43. readily translated to C or assembly language.
  44.  
  45. The Pascal unit also includes a data definition to the Searchlight "public" 
  46. data area and a public data area pointer; these features have been 
  47. documented previously, and will be briefly covered again here.
  48.  
  49.  
  50.  
  51. Functions, Variables & Type Definitions
  52.  
  53.  
  54. Var DriverLoaded: boolean;             { Set if SLBBS drivers available }
  55.  
  56. This global variable is set automatically by the MODEM unit's initialization 
  57. code. It is set to TRUE if Searchlight modem drivers are available, FALSE 
  58. otherwise. A FALSE setting indicates that Searchlight is not loaded into 
  59. memory (ie. your program was not run as a door) or that the version of 
  60. Searchlight in memory is older than 2.15C. Modem control functions cannot be 
  61. used if this variable is FALSE.
  62.  
  63.  
  64. Function CarrierDetect: boolean;       { Check carrier status }
  65.  
  66. This function checks the carrier detect signal on the modem. TRUE is 
  67. returned if carrier is detected, FALSE otherwise.
  68.  
  69.  
  70. Procedure Hangup;                      { Disconnect (hangup) }
  71.  
  72. This procedure causes the modem to disconnect or hang up on the remote 
  73. caller. It's a good idea to call the WaitOut function before hanging up, to 
  74. assure that all pending output is sent.  
  75.  
  76. Example:   WaitOut;
  77.            Hangup;
  78.  
  79. Note: Your program should terminate IMMEDIATELY after calling Hangup, and 
  80. control MUST return directly to Searchlight BBS so that it may recycle 
  81. properly. Hangup should be used ONLY if your program executes directly from 
  82. Searchlight as an EXE file. Don't use this function if your program will run 
  83. from a batch file!  
  84.  
  85.  
  86. Function RS232Avail: boolean;         { Check RS232 char available }
  87.  
  88. This function returns TRUE if there is a character available to be read from 
  89. the modem input buffer.
  90.  
  91.  
  92. Function RS232In: char;                { Read RS232 char }
  93.  
  94. This function reads a character from the modem input buffer. You should only 
  95. call RS232In if RS232Avail is TRUE.
  96.  
  97. Example:   If RS232Avail then c:=RS232In;   { c = char }
  98.  
  99.  
  100. Procedure RS232Out (c: char);          { Write RS232 char }
  101.  
  102. Sends a character to the modem. You can send any ASCII character from 0 to 
  103. 255. The character is sent directly to the modem without translation.
  104.  
  105. Example:   RS232Out(#27);   { Send clear screen sequence-- ESC[2J }
  106.            RS232Out('[');
  107.            RS232Out('2');
  108.            RS232Out('J');
  109.  
  110.  
  111. Procedure PauseOutput;                 { Pause buffered output }
  112. Procedure RestartOutput;               { Restart output after pause }
  113.  
  114. If output buffering is active, these function calls allow you to pause and 
  115. restart the output to the modem. They have no effect if there is no output
  116. buffering. Note: if a FOSSIL driver is used, these functions may or may not
  117. work, depending on whether the FOSSIL driver implements them.
  118.  
  119.  
  120. Procedure ClearInputBuffer;            { Clear input buffer }
  121. Procedure ClearOutputBuffer;           { Clear output buffer }
  122.  
  123. These procedures clear the contents of the input buffer and output buffer, 
  124. respectively. Clearing the input buffer destroys any waiting input 
  125. characters; clearing the output buffer discards any characters which were 
  126. output but which have not yet been transmitted. As with PausOutput and 
  127. RestartOutput, the success of these functions when a FOSSIL driver is in use 
  128. will depend on the FOSSIL driver's implementation.
  129.  
  130.  
  131. Function BufferEmpty: boolean;         { Check if output buffer empty }
  132.  
  133. This function returns TRUE if the output buffer is empty (or if there is no 
  134. output buffering). It returns FALSE if there are characters in the output 
  135. buffer. A FALSE result means that not all characters which were printed have 
  136. been transmitted to the remote terminal.
  137.  
  138.  
  139. Procedure WaitOut;                     { Wait for output buffer to clear }
  140.  
  141. This procedure waits for the output buffer to clear, and returns when all 
  142. characters have been transmitted. It has no effect if the output buffer is 
  143. already empty or if no buffering is enabled. It is better to call this 
  144. function rather than test the BufferEmpty condition in a loop, since this 
  145. function is optimized for use in multitasking environments.
  146.  
  147. Example:   If (not Bufferempty) then WaitOut;
  148.  
  149.  
  150. Var AUXIn: text;                       { RS232 Input File }
  151.     AUXOut: text;                      { RS232 Output File }
  152.  
  153. These text file handlers can be used instead of the RS232In and RS232Out 
  154. procedures to provide input and output to the modem. Since they are text
  155. files, you can use them in standard Pascal read and write statements.
  156.  
  157. Example:   Write(Auxout,#27'[2J');  { Send clear sequence. This has the same
  158.                                       effect as the RS232Out example. } 
  159.  
  160.  
  161. Procedure ComToggle;                   { Toggle BIOS I/O support on and off }
  162.  
  163. This function toggles the BIOS redirection feature (ie. the function which 
  164. directs standard output and input through the modem) on and off. You should 
  165. only use this function if BIOS redirection is enabled when your program 
  166. begins (ie. if your program is run as a "Standard" or "Force-Color" type 
  167. door). ComToggle can be used whenever you wish to write text to the local 
  168. screen only.
  169.  
  170. Example:   Write('This message appears on both the local and remote screen.');
  171.            ComToggle;
  172.            Write('This message appears only on the local screen.');
  173.            ComToggle;
  174.            Write('This message again appears on both screens.');
  175.  
  176. You should also call ComToggle before executing any program that does its 
  177. own modem input and output-- for example, before calling a protocol engine 
  178. to perform an upload or download. Be sure that you toggle the com support 
  179. back on before your program exits.
  180.  
  181.  
  182. Type RSbaud = (B110,B150,B300,B600,B1200,B2400,B4800,B9600,B19200,B38400);
  183. Procedure RSinit (com: integer; speed: RSbaud; buffactor: integer; 
  184.                   flow: boolean);
  185.  
  186. The RSInit function is available for users who wish to do all their I/O 
  187. directly through the procedures provided in this unit. You should only use
  188. the RSInit, RSCleanup and SetPortAddress functions if your Door program has
  189. been run in the "None" (no BIOS com support) mode from Searchlight. Do not 
  190. attempt to initialize the modem if BIOS I/O is active!
  191.  
  192. The following parameters are used with the RSInit function:
  193.  
  194.       Com:  Com port number (1-4)
  195.     Speed:  Baud rate (from RSbaud type shown above)
  196. Buffactor:  Output buffering factor (0-32)
  197.      Flow:  Hardware flow control switch
  198.  
  199. You can find the proper values to use for these parameters by examining the 
  200. CONFIG.SL2 file.
  201.  
  202.  
  203. Procedure RSCleanup;         { Reset RS232 port }
  204.  
  205. If you use RSInit to initialize the COM port, you should call RSCleanup to 
  206. de-initialize the port before your program exits.
  207.  
  208.  
  209.  
  210. Var  SLData: ^SLDataType;               { Pointer to public data area }
  211.  
  212. The Searchlight public data area is a block of memory inside the serial port 
  213. drivers which contains variables a Door program may be interested in 
  214. examining. The format of the data area is given by the SLDataType record 
  215. shown below. Variable 'SLData' is automatically initialized as a pointer to 
  216. this data area. (SLData is set to NIL if the public data area is not 
  217. available).  
  218.  
  219. Example:   If SLData<>Nil then begin
  220.              if SLData^.color then writeln('User has a color terminal.');
  221.            end;
  222.  
  223.  
  224. Type AnsiType = (GENERIC,PROCOMM,STANDARD);
  225.  
  226.      SLDataType = record         { Public Data Area }
  227.       PROGID: string[6];                { Contains the string 'SLBBS' }
  228.       carrier: boolean;                 { carrier check enabled? }
  229.       writeprotect: boolean;            { disk write protection? }
  230.       aborttype: byte;                  { 0=no abort, 1=terminate, 2=reboot }
  231.  
  232.       rsact: boolean;                   { set if rs232 active }
  233.       ansi: boolean;                    { is user in ANSI mode? }
  234.       color: boolean;                   { does user have a color crt? }
  235.       directvid: boolean;               { system DirectVideo mode }
  236.  
  237.       curratt: byte;                    { current video attribute }
  238.       commtype: byte;                   { run parameter - used internally }
  239.       idletime: word;                   { idle limit (seconds) }
  240.       lastkey: boolean;                 { TRUE = last key from local kbd }
  241.  
  242.       OldVector: array[$00..$7F] of pointer;   { old user int vectors }
  243.       AnsiMode: AnsiType;               { user's ANSI mode }
  244.      end;
  245.  
  246. Notes:
  247.   The "carrier", "writeprotect" and "aborttype" flags reflect the status of 
  248.   carrier checking and write protection when the door was launched. Changing 
  249.   these flags has no effect.  
  250.  
  251.   The "Rsact" flag is TRUE if the door was launched with BIOS I/O support
  252.   (ie. "Standard" or "Force-Color" type door). It is set to FALSE if the
  253.   door was launched in "None" mode (no modem support) OR if the door was
  254.   run during a local login. (You can examine the CONFIG file to determine
  255.   if the user is local or remote).
  256.  
  257.   You can still use the modem drivers if RSACT is false, but you must 
  258.   initialize the driver with RSInit.
  259.  
  260.   "DirectVid" tells you whether Searchlight is set to allow direct video 
  261.   writes in the CONFIG file.
  262.  
  263.   "LastKey" allows you to determine whether the last keystroke read from 
  264.   standard input originated from the modem or the local keyboard.
  265.  
  266.   "OldVector" stores the saved values of interrupts which Searchlight has
  267.   intercepted. The ComToggle procedure uses these values.
  268.  
  269.   "AnsiMode" returns the ANSI terminal type selected by the user.
  270.  
  271.  
  272. -----
  273. FL'92
  274.