home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / README.EXE / TELEPATH.TXT < prev   
Encoding:
Text File  |  1991-05-01  |  22.6 KB  |  484 lines

  1.                               REVIEW: Telepathy
  2.                                 By Steve Baker
  3.  
  4. (Editor's Note: Steve Baker will be reviewing three Clipper
  5. communications packages in the next several issues of The Aquarium.
  6. Look for reviews of SilverClip and CommTools to follow.)
  7.  
  8. Laaaaadies and Gentlemennnnnnn,
  9.  
  10. I have the distinct honor of being chosen to introduce to you, a
  11. relative newcomer to the third-party communications game. Hailing from
  12. Extrasensory Software, weighing in at one disk, one hundred
  13. fifty-eight pages of documentation, and recently entering competition
  14. in October 1990, ...
  15.  
  16.                          TELEPATHY!
  17.          (flashbulbs, cheers, screams and clapping).
  18.  
  19. Did you ever want your Clipper program to dial the phone for you? Send
  20. or receive a file to another computer? Work with a bar code reader?
  21. Write a BBS program?  Make your own terminal program? Receive input
  22. from an A-to-D converter?  And yes... even write your own version of a
  23. program like Aquarium?  Can you say "Extrasensory Software" ten times
  24. real fast?  Ok... neither can I.  How about "Telepathy"?
  25.  
  26. Telepathy is a communications library for Clipper Summer 87, and
  27. Clipper 5.0.  With it, we can look incredibly smart if someone asks us
  28. if we can perform serial communications from within our Clipper
  29. programs.
  30.  
  31. The Telepathy Library
  32.  
  33. The Telepathy functions generally fit into the following categories
  34. (these are my categories -- the Telepathy docs just group all the
  35. functions in one place.)
  36.  
  37.                    SERIAL PORT CONTROL
  38.                    UART STATUS / CONTROL
  39.                    RECEIVING DATA
  40.                    SENDING DATA
  41.                    MODEM CONTROL
  42.                    PROTOCOL FILE TRANSFER
  43.                    TERMINAL EMULATION
  44.                    BIT AND BYTE STUFF
  45.                    EVENT NOTIFICATION
  46.                    ERROR CONTROL
  47.  
  48. I have included a reference table in the "Source Code" section of this
  49. article, that lists each function, and gives the Norton Guides
  50. description of what it does.
  51.  
  52. Any "Clipper Head" will love the function design used in Telepathy.
  53. Most functions are of the multi-purpose GetSet() type of design.  For
  54. example, instead of one function to Get the current UART baud rate,
  55. and one to set a new baud rate, there is a single function called
  56. tp_baud().  This function returns the current setting, and sets a new
  57. baud rate if desired, in the same manner as Clipper's SETCOLOR() and
  58. SET() functions.  In addition, the modem status and UART status
  59. functions have been designed to return information on several status
  60. bits with one call, rather than have a separate function for each
  61. status register of interest. This makes a lot of sense to me, and I
  62. think that a Clipper user cannot help but like the Telepathy design
  63. approach.
  64.  
  65. What's so good about Telepathy?
  66.  
  67. This is the hard part...  How to get the "feel" of the library across
  68. to you so that you can appreciate how good it really is.  Rather than
  69. ramble on about each function, I first want to try and give you an
  70. overall view of what "stands out" about Telepathy (I'll ramble later).
  71.  
  72. Let me start by saying that I think the most notable quality of
  73. Telepathy is the degree of access that you have in controlling and
  74. responding to serial port communications. This control comes from
  75. three concepts:
  76.  
  77.      1. The support of a user-specified Progress function
  78.         during file transfer.
  79.      2. The support of an idle function during all processing.
  80.      3. The unique Telepathy Notification system.
  81.  
  82. Progress Function
  83.  
  84. During any protocol file transfer (and Telepathy supports a bevy of
  85. formats), you can specify a user-defined function that will be called
  86. repeatedly during the file transfer.  This is similar to the UDF that
  87. can be specified in MemoEdit(), and is called on start and finish, and
  88. after each block transmission.  On each call, your function is sent a
  89. status code, the name of the file being transferred, the byte count,
  90. and the error code. Using this design, your file transfers can have a
  91. completely customized look to them.  I know of no other communications
  92. library that gives you this ability without working in C.  (See the
  93. accompanying source code for a sample Progress function.)
  94.  
  95. The Idle Function
  96.  
  97. All Telepathy functions that have to wait for input or output
  98. repeatedly call a function called tp_idle().  By writing your own
  99. tp_idle() function, and pre-empting the library version, you can have
  100. control at all times. For example, even though you specified that a
  101. function should wait forever to receive a certain string at the serial
  102. port, you can still maintain control because that function will be
  103. continuously calling your idle function while waiting. Any routine can
  104. be aborted by the return value of tp_idle().  (See the source code
  105. file for an example.) This function also applies to file transfers.
  106. Powerful stuff!
  107.  
  108. The Notification System
  109.  
  110. Did I say the idle function was powerful?  Well if the idle function
  111. was a 33 Mhz 386, then the Notification system is a Cray
  112. supercomputer.  This system allows you to specify a particular
  113. communications "event" to watch for, and what function to call when it
  114. happens, and then go merrily along your way until one of the events
  115. occurs.  To do this, Telepathy has 6 functions that allow you to
  116. specify conditions to watch for.  You can ask for notification
  117. whenever any of the following happens:
  118.  
  119.    - any input whatsoever is received at the serial port.
  120.    - a certain character is received.
  121.    - the output buffer is empty.
  122.    - the input buffer fills up to a "high water" mark.
  123.    - any of the modem status flags change value.
  124.    - a certain amount of time has elapsed.
  125.  
  126. To request a notification, you call the correct function for the type
  127. of notification you are requesting, and pass the name of the function
  128. you want to branch to when the notification is received.  For example,
  129. you could set your modem to auto-answer, and then request to be
  130. notified whenever a Carrier was detected by the modem.  Your program
  131. could continue doing whatever it does (now I sound like one of my
  132. clients!) and then automatically branch to a routine to handle an
  133. incoming data call when notified.  (See the source code for a sample
  134. routine using notifications.)
  135.  
  136. To accomplish this feat, Telepathy makes use of Clipper's SET KEY
  137. abilities.  When a notification condition is met, Telepathy stuffs a
  138. special inkey() value into the keyboard, and issues a SET KEY command
  139. for that inkey() value.  Branching will then automatically occur from
  140. the next wait state encountered, just as it would for any SET KEY. The
  141. system is designed so that only one SET KEY value is used for all
  142. notifications, leaving you 31 remaining possibilities in the rest of
  143. your program.
  144.  
  145. Input Watches
  146.  
  147. Another Telepathy feature that I mentally include with notifications,
  148. is the ability to register up to 16 different strings to watch for.
  149. When a watch string is registered, Telepathy looks for that string
  150. whenever data is read from the receive buffer.  (Note that watches are
  151. processed as data is read from the buffer -- notifications are posted
  152. as events happen at the serial port.)  You can then query as to
  153. whether any of the watch strings have been received, which string, and
  154. how many times.
  155.  
  156. Protocol File Transfer
  157.  
  158. The supported file-transfer protocols in Telepathy are outstanding.
  159. You receive support for the following protocols:
  160.  
  161.                 Xmodem
  162.                 Xmodem-CRC
  163.                 Xmodem-1K  (sometimes called Ymodem)
  164.                 Ymodem     (sometimes called Ymodem batch)
  165.                 Ymodem_G
  166.                 Zmodem
  167.                 Kermit
  168.  
  169. In addition, all required support functions to control optional
  170. settings for these protocols are provided.
  171.  
  172. As we already discussed, a custom Progress() function can be specified
  173. for any of these protocols allowing completely customized status
  174. displays during file transfer.
  175.  
  176.  
  177. UART Status / Control
  178.  
  179. A host of functions exist to Get/Set the status of all registers, and
  180. to control all flow control settings. If you will refer to the
  181. detailed function list in the source code section, you will see that a
  182. function exists to Get or Set just about everything you can think of.
  183.  
  184. A couple of functions deserve special recognition here for their
  185. design:
  186.  
  187. The tp_lstat(), and the tp_mstat() functions return the status of the
  188. Line Status Register, and modem registers respectively.  A string is
  189. returned that contains an identifier for any "high" bit in the
  190. register.  For example, if the modem carrier detect was high, and
  191. Clear To Send was high, tp_mstat() would return "CK". Using this
  192. design, you can receive a string from these functions that describes
  193. the status of each register bit...in one function call.
  194.  
  195. The 16550 UART is also supported.  This is an improved version of the
  196. NS16450 that can be put into an alternate FIFO mode which relieves the
  197. CPU of some processing overhead.
  198.  
  199. Telepathy also supports user control of Hi-Water and Low-Water receive
  200. buffer settings. You can specify these settings to control what
  201. percentage of the receive buffer is filled when input is stopped and
  202. started using flow control.
  203.  
  204. Serial Port Control
  205.  
  206. As you can see from the function listing in the source code section,
  207. all of the functions you would expect to see are there for opening and
  208. closing a serial port, and controlling all settings such as baud, stop
  209. bits, parity, data bits etc. One design feature that I particularly
  210. like, is the ability to specify all settings as parameters of the
  211. tp_open() function. While there are separate functions to get/set an
  212. individual setting, there is no need to call them after opening the
  213. port. The port can be opened, and completely set up in one function
  214. call.
  215.  
  216. In addition to the normal tp_open() function, there is also a function
  217. named tp_reopen().  This function just opens the port with whatever
  218. parameters it finds the serial adapter currently set to.  Using this
  219. function you could close the port but leave the modem on-line, execute
  220. an external program, and then reopen the port with the existing
  221. settings.
  222.  
  223. Receiving Data
  224.  
  225. The functions for receiving information through the serial port
  226. essentially use three strategies:
  227.  
  228.    1.  Passively let the input characters accumulate in a receive
  229.        buffer and then search or retrieve the information in the
  230.        buffer later.
  231.  
  232.    2.  Actively receive remote-entered information, process it
  233.        as it is received, and assign it to a variable (such as a
  234.        password or file name)
  235.  
  236.    3.  Actively monitor the information coming into the serial port
  237.        and discard all received information until one of several
  238.        special strings is received (such as logging onto a BBS and
  239.        waiting for the right question)
  240.  
  241. The majority of functions deal with method one.  When a port is
  242. opened, an input and output buffer is initialized, and the size can be
  243. user-specified.  As characters are received, they are automatically
  244. placed in the input buffer.  Using the receive functions, you can then
  245. extract information from the buffer (tp_recv), determine how many
  246. characters have been received (tp_inchrs), parse the information
  247. (tp_recvto), look for specific information (tp_lookfor), empty the
  248. buffer (tp_clearin) etc.
  249.  
  250. (See the source code routine SimpleTerm() for an example.)
  251.  
  252. The second method, using tp_recvln(), allows you to receive a line of
  253. information from a remote user, and actively allow remote line
  254. editing.  Think of this as a remote GET.  You could use this for
  255. getting interactive input such as PassWords or FileNames.
  256.  
  257. The third method, using tp_waitfor(), actively watches the information
  258. coming into the serial port, and throws everything away until one of
  259. several strings is received.  This could be used while waiting for a
  260. specific prompt to reply to when logging onto a BBS etc.  In my
  261. opinion, this function is one of the most useful in the library.  It
  262. allows you to specify a list of strings, or an array of strings to
  263. wait for at the serial port. A time limit may be specified, or you may
  264. have it wait forever. Whenever one of the strings comes into the port,
  265. the function will return a numeric indicating the position in the
  266. list/array of the string that it found, allowing you to branch to the
  267. appropriate processing method.  I've had to write a considerable
  268. amount of code with another comm library to obtain the same
  269. functionality that this function gives you.
  270.  
  271. Transmitting Data
  272.  
  273. Sending information out the serial port is pretty simple.  After the
  274. output buffer is initialized when you open the port, all you do is
  275. stick whatever you want sent into the output buffer. To put a string
  276. into the output buffer, the function tp_send() is used. Once a string
  277. is in the buffer, Telepathy's internals and the UART take care of
  278. whittling down the information in the buffer, and getting it out the
  279. port, while observing whatever flow-control settings are in effect.
  280.  
  281. (See the source code routine SimpleTerm() for an example.)
  282.  
  283. Modem Control
  284.  
  285. You may be surprised that there are no internal library functions to
  286. control the modem.  You are provided a .PRG file of modem-control
  287. functions written in Clipper S87, that make use of the other Telepathy
  288. functions.  I admit that at first I thought "Ah Ha! ... a weakness".
  289. Having used another communications library in the past, I was used to
  290. the modem stuff being accomplished by library functions.
  291.  
  292. After I did some testing and thinking though, it became clear to me
  293. that there were some definite advantages to having the modem control
  294. functions "out in the open".  Using a modem is like talking on the
  295. phone in the old days when you had to have a third party "operator" on
  296. the line with you (no, I'm not really THAT old). When you need to
  297. make a call, you just pick up the phone (open comm port) and get the
  298. operator's (modem's) attention.  We could do this by yelling
  299. "Operator!" (AT) into the phone until the operator responded. If
  300. the operator is listening, they will respond with "This is the
  301. operator, I heard you..." (OK). Then we just yell "OPERATOR, connect
  302. me with 555-1212 please"  (ATDT555-1212).  While you're talking to
  303. your party on the other end, the operator just makes sure that your
  304. conversation gets passed back and forth.  If you want the operator to
  305. do anything special however, you have to get their attention again.
  306. To do this, we could flash up and down on the receiver hook (+++) and
  307. yell "Operator!" (AT), until the operator answered (OK).
  308.  
  309. So really, controlling a modem comes down to what you yell after you
  310. get the modem's attention. Having these functions written in Clipper
  311. gives you much more capability to handle any non-standard problems,
  312. and also to review any assumptions that are made, and change them to
  313. suit you.  I wrote a 5.0 version of some modem functions using the
  314. Summer '87 file that came with Telepathy as a base.  Some of this code
  315. is included in the source file as an example.
  316.  
  317. Terminal Emulation
  318.  
  319. Currently Telepathy supports both TTY, and ANSI terminal emulation.
  320. VT-100, and VT-52 are not supported.
  321.  
  322. Bit and Byte Stuff
  323.  
  324. Several functions are provided for the bithead.  Ordinarily, I would
  325. just mention these and say that it is perfectly clear what they are
  326. used for... just not to me.  I feel that they need to get mentioned
  327. however since Telepathy uses a "power of 2" return value for several
  328. of it's "could be one, any, or all" types of functions.  An example
  329. would be tp_hshk() which returns a number that represents all of the
  330. current handshake settings (sort of like color numbers).  Rather than
  331. getting quickly over my head trying to discuss bits and bytes, I will
  332. just say that it is not necessary to try to extract information from
  333. this number, or to try to build this number since individual functions
  334. are available to do that for you. If you did want to play with the
  335. bits though (yech...), bin_and() could be used to test these values,
  336. and bin_or() could be used to build a value specifying multiple
  337. settings.
  338.  
  339. Error Control
  340.  
  341. All of Telepathy's functions set an internal numeric error code
  342. whenever an error is encountered.  Some functions will return an error
  343. result directly, but all functions set the internal error code prior
  344. to exiting.  The function tp_error() will return the error result of
  345. the last Telepathy function called.  This allows you to test for error
  346. conditions after every call to a communications function.  The
  347. function tp_errmsg() will return a verbose description of an error
  348. code returned by tp_error(). Error codes are generated for general
  349. errors, file transfer errors, and Dos errors.  A header file is
  350. supplied with the manifest constant definitions for these error codes.
  351.  
  352. A list of standardized error codes is provided in the source code
  353. section.
  354.  
  355. Another nice feature of Telepathy that could be grouped under error
  356. control, is the ability to disable its own interrupts on an unplanned
  357. exit from your program.  Should your program abort to DOS rather
  358. ungracefully, you don't have to worry about using a utility to disable
  359. any interrupts that were in effect prior to exiting to DOS.
  360.  
  361. Installation
  362.  
  363. It would be reasonable to assume that if you are writing a program for
  364. developers, your customer is capable of getting your program onto his
  365. hard disk with a few basic instructions.  I agree with this, except
  366. I've gotten lazy(ier) in my old age. It's gotten to the point where I
  367. expect a completely automated installation routine for any commercial
  368. program.  'Tis not the case with Telepathy. "Create this directory and
  369. then copy these files and then..."  You get the idea. Certainly not
  370. hard, but also not the lazy man's way.
  371.  
  372. Documentation
  373.  
  374. The Telepathy manual comes in a nice 3-ring binder with a "Just the
  375. facts ma'am" look.  (Editor's Note: Joe Friday hailed from the City of
  376. Angels, as does Extrasensory Software -- maybe there is a connection?)
  377. In addition to the usual stuff, Telepathy has a wonderful "Serial
  378. Communication Primer" that runs for a full eight pages.  In it, you
  379. learn just about everything you need to know to have a reasonable
  380. chance of actually understanding what you are doing with communication
  381. programming.  In addition to the primer, there are general information
  382. sections on Serial Programming, protocol File transfers, and the slick
  383. Telepathy notification system.
  384.  
  385. The function documentation does not follow the Nantucket format of
  386. Syntax, Arguments, Returns, Description, Examples, etc. Instead, the
  387. function syntax is shown with an assignment variable, and then the
  388. assignment variable is discussed along with the passing parameters.
  389. Here is an example:
  390.  
  391.                 tp_recv() - receive string
  392.  
  393.       cString = tp_recv(nPort[, nLength[, nTimeout]])
  394.  
  395. The return value of this function is documented by the Hungarian
  396. notation of cString (if you want to more about this notation, see
  397. Matt Maier's "Standards and Conventions" article in the 2/91
  398. Aquarium), and by any remarks about cString in the rest of the
  399. function documentation.  It is easy to tell what you are getting back
  400. by looking at the assignment variable.
  401.  
  402. Unfortunately, this format does not tell you the whole story. I missed
  403. the Returns section to clarify little exceptions to the rule. As an
  404. example: tp_close() and tp_clearout() do not show a return variable,
  405. and tp_baud() specifies that the old baud rate is always returned. As
  406. it turns out, tp_close() actually returns an error code, tp_clearout()
  407. returns NIL, and tp_baud() can return an error code under certain
  408. circumstances. The first case was an omission that was corrected in
  409. the Norton Guide file. The second case was undocumented probably
  410. because it always returns NIL.  The third case is just undocumented. A
  411. formal Return section would help clarify things in my opinion.
  412.  
  413. The printed manual suffers from the usual "first release" problems.
  414. Most of the references to "see page __" are wrong and since they are
  415. all 6 pages off, it's easy to see what happened. Coding examples are
  416. extremely sparse, and what examples do exist are in Summer '87 format.
  417.  
  418. In addition to the printed manual, Telepathy comes with a nice Norton
  419. Guide help file, a Tom Rettig help file, and a limited version of the
  420. Tom Rettig engine.
  421.  
  422. In general, the documentation is good.  A Function cross-reference by
  423. general task would be nice.  Without a doubt, the docs could use more
  424. coding examples to show how each function was intended to be used.
  425. What I found missing the most in the Telepathy manual, was a section
  426. that says, "And now this is what you do with all this stuff to make a
  427. communications program in Clipper...".  However, you do receive
  428. several sample .PRG files however that help fill this void.
  429.  
  430. After Sale Support
  431.  
  432. Extrasensory Software offers several methods of getting assistance
  433. after you purchase Telepathy.  You can contact them via voice phone
  434. (although the hours are somewhat unusual), BIX, CompuServe
  435. (76702,672), TelePath, UseNet, U.S. Mail, and even the Aquarium
  436. Message Center (although this option is not mentioned in either the
  437. manual or Norton Guide).  One thing I wish they had was a dedicated
  438. BBS where one could find sample code and quick answers to routine
  439. questions.   I found their support to be very good in general, and
  440. their frequent update policy is outstanding.  You need only ask for
  441. something and it's in the mail.
  442.  
  443. So How Much is it ... and what do I get...
  444.  
  445. I sound like a late-night TV salesman don't I?  Sorry... I'm just the
  446. Aquarium reviewer and I can't even throw in a free Ginzu knife or
  447. anything, but for a very reasonable $149.95, you get the whole
  448. Telepathy package:
  449.  
  450. Telepathy comes on a single disk.  You receive both Clipper Summer
  451. '87, and Clipper 5.0 versions.  The library comes in a non-overlay
  452. version, and a version for dynamic overlays that is split into ROOT
  453. and OVL modules. The overlay modules work with those linkers that
  454. support dynamic overlaying of C and Assembler (the version of RTLINK
  455. that comes with Clipper 5.0 cannot dynamically overlay C or ASM).
  456.  
  457. For documentation you receive a printed manual, a Norton Guide help
  458. file, a Tom Rettig help file, and a limited version of the Tom Rettig
  459. engine.
  460.  
  461. As a nice bonus, you receive CLIP, a handy compiler and linker driver
  462. for Clipper.
  463.  
  464. Ordering Information:
  465.  
  466. Telepathy - $149
  467.  
  468. Extrasensory Software
  469. 4450 Murietta Ave.,  #8
  470. Sherman Oaks, CA   91423
  471. Orders  (800) 444-4682
  472. Fax     (818) 986-5411
  473. Support (818) 981-8367
  474. Aquarium (address messages to Ira Emus or Dave Rifkind)
  475. CompuServe (76702,672)
  476. BIX (IRAE)
  477.  
  478. About the Author
  479.  
  480. Steve Baker is Programming Director for the Parkside Company, and we
  481. are proud to introduce him to the Aquarium editorial staff.  Steve
  482. welcomes your comments via the Aquarium Message Center or (if you
  483. simply must use CompuServe) at ID 72007,3371.
  484.