home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / amos / lserial_demo / docs / lserial / lserialv21.doc next >
Encoding:
Text File  |  1992-09-19  |  29.4 KB  |  867 lines

  1. Lserial V21(3) for AMOS1.3 and above.
  2. Lserial is (C) Niklas Sjöberg 1992
  3.  
  4. See IMPORTANT.TXT for more information on how to reach me or
  5. register!
  6.  
  7.  
  8.        NOTE: Commands added since V1 is marked with *-, so just  load
  9.      you favorite textreader and search for "*-".
  10.  
  11.        Commands added since V2 are marked ++
  12.  
  13.        Lserial.doc is now  splitted  in  two  parts.  Part  I  covers
  14.     general    serial-commands  and  part  II  covers  all  necessary
  15.     information about the XPR-specifications.
  16.  
  17.  
  18.  
  19.     DISTRIBUTION:
  20.     -------------
  21.        Lserial no longer is freely distributable, it is  now  shipped
  22.     under the term shareware.
  23.  
  24.              Lserial is copyrighted by me, Niklas Sjöberg.
  25.  
  26.  
  27.     DISCLAIMER:
  28.     -----------
  29.        All the usual... You are using this program at your own  risk.
  30.      I can not be held responsible for any damage or whatsoever.
  31.  
  32.  
  33.     WHY?:
  34.     -----
  35.        AMOS's serial didn't work in 1.0/1.1, in  1.2/1.3  it  worked,
  36.     but  only sometimes  and only a little :-) The main 1.3-bug seems
  37.     to be when one tries to open the device after  closing  (this  is
  38.     NOT  a  devicebug since it is tested with serial.device from both
  39.     1.3.3 and 2.04. An old serial.device from WB1.2  causes  AMOS  to
  40.     hang  on  some occasions for some reason) it once and then trying
  41.     to open it again. You also get xpr and some other features.
  42.  
  43.  
  44.     HOW TO:
  45.     -------
  46.        In the days of V1.1/1.2 I used to  supply  a  program  for  my
  47.     extensions  which  could  change  any  (of  mine) extension to be
  48.     configured as any number. This is not possible  anymore,  due  to
  49.     the  layout  of  1.3  (well it IS possible but it would slow down
  50.     every access to the data-table). Because of this you  MUST  place
  51.     LSerial as extension number eleven (11). Your manual explains all
  52.     about  adding  extensions.  If  you  MUST  or  NEED  to  have  it
  53.     configured as  another number then send me a disk  full  of  nice
  54.     programs and some international replycoupuns to cover mailing.
  55.  
  56.  
  57.  
  58.                         PART I - General serialcommands
  59.  
  60.     Before you start crashing your computer :
  61.  
  62.        It is up to  you,  the  programmer,  to  make  sure  that  the
  63.     serial.device (or another device you might have selected) is open
  64.     and  ready  for  use before you try to access any read/write/xpr-
  65.     commands. If you for instance try to call Lser Send as the  first
  66.     instruction  in  your program it will hang OR crash the computer!
  67.     Always use Lser  Open! If the device  failed  to  open  you  will
  68.     receive  an  errormessage  and the program will be aborted, or if
  69.     you have a errorhandling-routine the error will be trapped  (that
  70.     is the best solution!). It is safe to call Lser Close even though
  71.     no  device  is open, so it might be a good idea to always do this
  72.     before your program exists or if you change device.
  73.  
  74.  
  75.  
  76.     Lser Open - Open serial for use.
  77.     Lser Open BAUD,RWlen,STOP,BUF_SIZE,BRKtime,FLAGS,UNIT,"name.device"
  78.  
  79.     where
  80.  
  81.     BAUD     - Baudrate
  82.     RWlen    - number of bits when read/write (normally 8)
  83.     STOP     - Number of stop-bits (normally 1)
  84.     BUF_SIZE - Internal buffer for device. MUST be >512 bytes
  85.     BRKtime  - How long a BRK should last, in MICROseconds
  86.                (normally 250000)
  87.     FLAGS    - See Appendix B for list
  88.     UNIT     - Unit, normally 0 for external modems.
  89.     name     - Normally serial.device (located in devs:)
  90.  
  91.  
  92.  
  93.     Lser Close - Close serial.device
  94.     Lser Close
  95.  
  96.  
  97.  
  98. ++  Lser Params - Change the settings of the currently open device
  99. ++  Lser Params RWlen,STOP,BUF_SIZE,BRKtime,EXTFlags,FLAGS
  100.  
  101. ++  where
  102.  
  103. ++     All parameters mean the same thing like  in  Lser  Open.  Note
  104. ++  that  a  new  field  EXTFlags  is  available. This field may have
  105. ++  different values for different devices. It  is  used  to  control
  106. ++  mark  and  space parity instead of odd and even. Bit 24 "if mark-
  107. ++  space, use mark". Bit 25, use mark-space. These flags where added
  108. ++  mostly due to future compability and extensions.
  109.  
  110. ++     According to C= Autodocs it is always best to decide if access
  111. ++  shall be shared or exclusive when opening the device. It is  also
  112. ++  wise  to  decide  if 7-wire or 3-wire protocol should be used. Do
  113. ++  not count on that these two options  can  be  changed  after  the
  114. ++  device has been opened. Use Lser Baud to change the baudrate.
  115.  
  116.  
  117.  
  118. ++  NOTE! This command has been here all along,  I've just  missed it
  119. ++  in the documentation! Sorry..
  120.  
  121. ++  Lser Baud - Change baudrate
  122. ++  Lser Baud NEWRATE
  123.  
  124. ++  where
  125.  
  126. ++     NEWRATE is the new baudrate.
  127.  
  128.  
  129.     Lser Send - Send data to the modem, non-multitasking
  130.     Lser Send A$
  131.  
  132.     where
  133.  
  134.        A$ contains any data. Note  that  this  instruction  does  not
  135.     return to AMOS until the whole string is sent.
  136.  
  137.  
  138.  
  139.     Lser Query - Check if there is data to read
  140.     L=Lser Query
  141.  
  142.     where
  143.  
  144.        L - Contains the number of chars available to read.
  145.  
  146.  
  147.  
  148.     Lser Read - Read all available characters.
  149.     A$=Lser Read
  150.  
  151.     where
  152.  
  153.        A$ will contain all data buffered by the  device.  WARNING  If
  154.     there  are  VERY  many  characters  to  read AMOS may crash. This
  155.     command should only be used if you often read  from  the  device,
  156.     like  in  a  comm-program which continually loops and read. Using
  157.     it when communicating with MIDI or via 0-modem can  be  dangerous
  158.     due to the very high speed!
  159.  
  160.  
  161.  
  162.     Lser Mulsend - Send a string in a multitasking manner.
  163.     Lser Mulsend A$
  164.  
  165.     where
  166.  
  167.        A$ may contain any data. If you try  to  send  any  more  data
  168.     before Mulsend has completed only garbage will be output from the
  169.     modem.  Control  will  return  to  AMOS immediately. Changing the
  170.     contents of A$ before Mulsend has completed is a stupid thing  to
  171.     do..(I  have  not had time to test and see if serial.dev actually
  172.     copies the data)
  173.  
  174.  
  175.  
  176.     Lser Mulcheck - Check if Mulsend has sent all data.
  177.     L=Lser Mulcheck
  178.  
  179.     where
  180.  
  181.        L will be true if Mulsend is ready.
  182.  
  183.  
  184.  
  185.  
  186.     Lser Get - Get a specified number of characters.
  187.     A$=Lser Get(N)
  188.  
  189.     where
  190.  
  191.        N Is the number of characters you  wish  to  read.  Note  that
  192.     control  will  not  return to AMOS until the number of characters
  193.     specified have been received.  This can cause  AMOS  to  hang  if
  194.     you  haven't any CARRIER and no data appears. A good advise is to
  195.     use Lser Query or Lcarrier before trying to read anything.
  196.  
  197.  
  198.  
  199.  
  200.     Lcarrier - Check for carrier
  201.     L=Lcarrier
  202.  
  203.     where
  204.  
  205.        L will be true if CARRIER exists.
  206.  
  207.  
  208.  
  209. ++  Lser Status - Get statusflags from device
  210. ++  L=Lser Status
  211.  
  212. ++  where
  213.  
  214. ++  the 16 first bits of L have the following meaning:
  215. ++  (Active high means active if bit set, active low = active if
  216. ++   bit=0)
  217.  
  218. ++   Bit#   Active Description
  219. ++   ----   ------ -----------
  220. ++     0           reserved
  221. ++     1           reserved
  222. ++     2    high   Ring indicator. Note that this flags also is
  223. ++                 "connected" to parallel's SEL. Do not relay to
  224. ++                 much on this bit!
  225. ++     3    low    Data Set Ready      (DSR)
  226. ++     4    low    Clear To Send       (CTS)
  227. ++     5    low    Carrier Detect      (CD)
  228. ++     6    low    Ready To Send       (RTS)
  229. ++     7    low    Data Terminal Ready (DTR)
  230. ++     8    high   hardware overrun
  231. ++     9    high   break sent (most recent output)
  232. ++    10    high   break received (as latest input)
  233. ++    11    high   transmit x-OFFed
  234. ++    12    high   receive x-OFFed
  235. ++ 13-15           reserved
  236. ++ 16-31           Always zero
  237.  
  238.        The most interesting fields are DSR/DTR. You can use  Lcarrier
  239.     to check for carrier instead of using  this function (Lcarrier is
  240.     faster).
  241.  
  242.  
  243.  
  244.     Lser Brk - Send a BRK to modem (time specified in Lser Open)
  245.     Lser Brk
  246.  
  247.  
  248.  
  249.  
  250. *-  Linkey$ - Convert some AMOS-characters to ANSI-codes.
  251. *-  A$=Linkey$
  252.  
  253. *-  where
  254.  
  255. *-     A$   will  contain one or more characters. Linkey$ works  just
  256. *-  like  Inkey$  in  AMOS  except that it might return more than one
  257. *-  character. It always reads one character from the keyboard but if
  258. *-  for instance a cursor-key was pressed the ANSI-code will  require
  259. *-  three  characters.  Currently  Linkey$  converts  all cursor-keys
  260. *-  and all keys pressed while the CONTROL-key is held  down.  Escape
  261. *-  backspace  a-z  etc. are not converted in any way. If no keys are
  262. *-  pressed A$ will be empty. Always use this instead  of  Inkey$  if
  263. *-  you are to be able to communicate with another (ANSI/VT100) term-
  264. *-  inal.
  265.  
  266.  
  267.  
  268.  
  269.                         PART II - The XPR specs
  270.  
  271.  
  272. *-     XPR stands for eXternal PRotocol and  was  invented  by  W.G.J
  273. *-  Langevald    in    1989.  The  idea  is  that  the  author  of  a
  274. *-  communicationprogram  (or  of  any      program    involved    in
  275. *-  filetransfers)    can    use    standard    Amiga-libraries   for
  276. *-  filetransfers. The xpr*-libraries are supposed to  be  the  brain
  277. *-  of  the protcol, checking the incoming data, if necessary request
  278. *-  a re-send, save data to a file etc. etc. The (comm)program is the
  279. *-  one which supplies all the basic routines for  serial-read/write,
  280. *-  saving  files  etc.  These  routines  are  later  called  by  the
  281. *-  xpr*.library. Since the XPR  is  quite  flexible,  allowing  many
  282. *-  different  operations to be performed, you may count on that if a
  283. *-  program supports ONE xpr.library it  will  probably  support  all
  284. *-  future libraries. This means that the user may use protcols which
  285. *-  even  wasn't  invented  when  the author of the program wrote his
  286. *-  callbacks! It also means that the author of the program only need
  287. *-  to write his callback routines once (which he already  needed  in
  288. *-  his  originally program in the first place) in order to work with
  289. *-  any protocols. Lately some XEM*.library (eXternal EMulation) have
  290. *-  appeared. These can/could  actually  be  used  through  the  XPR-
  291. *-  standard  using  XprHostMon  and XprUserMon. Due to the layout of
  292. *-  AMOS (not using normal  intuition-screen)  these  cannot  be  run
  293. *-  under AMOS in any way.
  294.  
  295.  
  296.  
  297. *-     When all the callbacks are written (which I have done for you)
  298. *-  it  is  quite  easy to use any xpr.library. In general the 'flow'
  299. *-  when using a xpr looks something like this  : (unnecessary  setup
  300. *-  removed sine Lxpr handles this for you)
  301.  
  302.  
  303. *-  1) Open the desired library
  304. *-     (Did it open?)
  305. *-  2) Call SetUp with a proper init-string.
  306. *-     (See docs for the library in question)
  307. *-  3) Check flags returned by SetUp
  308. *-     (See below)
  309. *-  4) Wait until user requests up-/download.
  310. *-     (If  flags supported UserHostMon, download may be initiated
  311. *-     automagically)
  312. *-  5) Get appropriate filenames for up/download (if necessary, spe-
  313. *-     cified in flags)
  314. *-  6) Call Send or Receive.
  315. *-  7) When the program is quit or xpr is changed, close it and/or
  316. *-     jump to 1).
  317.  
  318. *-     APPENDIX C contains a complete example of how to use a xpr-
  319. *-  library.
  320.  
  321.  
  322. *-     Before we start dealing with the  Lxpr-syntax,  here  are  the
  323. *-  callbacks   that  are  supported  by  Lxpr  (usually  the  needed
  324. *-  callbacks for a library are stated in the library docs.)
  325.  
  326.  
  327. *-  xpr_filename  - Support for both batch and singlefile transfer.
  328. *-                 (actually this is a datafield, but always filled
  329. *-                 in by Lxpr)
  330. *-  xpr_fopen     - Opens file(s)
  331. *-  xpr_fclose    - Close file(s)
  332. *-  xpr_fread     - Read from file(s)
  333. *-  xpr_fwrite    - Write to file(s)
  334. *-  xpr_sread     - Read from serial.device (or spec. in Lser Open)
  335. *-  xpr_swrite    - Write from serial.device(or spec. in Lser Open)
  336. *-  xpr_sflush    - Clear all data in serial.device-buffer
  337. *-  xpr_update    - Print info (see below)
  338. *-  xpr_chkabort  - See if user aborted transfer
  339. *-  xpr_chkmisc   - No need for this one, yet, not one xpr require is
  340. *-                  so far.
  341. *-  xpr_gets      - Get a string from the user
  342. *-  xpr_setserial - Get and/or change serialparameters
  343. *-  xpr_ffirst    - Get the first filename during batch transfer
  344. *-  xpr_fnext     - Get the next filename during a batch transfer
  345. *-  xpr_finfo     - Obtain fileinformation (filetype not supported)
  346. *-  xpr_fseek     - Position in a file
  347. *-  xpr_extension - All four (the four below).
  348. *-  xpr_options   - Supported but currently not used (just exits)
  349. *-  xpr_unlink    - Delete file(s)
  350. *-  xpr_squery    - Return # of chars available from serial
  351. *-  xpr_getptr    - Return customscreen-pointer (WB always returned)
  352.  
  353.  
  354. *-  The xpr_update-function supports the following fields :
  355.  
  356. *-  xpru_protocol    - The name of the xpr currently used
  357. *-  xpru_filename    - The file being transferd
  358. *-  xpru_filesize    - Size of the file being transferd
  359. *-  xpru_msg         - Last message from library
  360. *-  xpru_errormsg    - Last errormessage
  361. *-  xpru_blocks      - Number of blocks sent
  362. *-  xpru_blocksize   - The current size of each block
  363. *-  xpru_bytes       - Number of bytes sent
  364. *-  xpru_errors      - Number of errors during transfer
  365. *-  xpru_timeouts    - Number of timeouts during transfer
  366. *-  xpru_blockcheck  - Type of error-check (usually CRC or checksum)
  367. *-  xpru_expecttime  - Expected (total) transfertime
  368. *-  xpru_elapsedtime - Time elapsed since start of transfer
  369. *-  xpru_datarate    - cps for total transfer so far
  370.  
  371. *-  more fields may be supported in the future.
  372.  
  373.  
  374. *-     The Lxpr-part only contains one command! This is  due  to  the
  375. *-  inner workings of the AMOS compiler which treats all functions as
  376. *-  local,  as  it  datas.  Lxpr  COULD have been split up on several
  377. *-  commands, but would have meant that either all the  xpr-callbacks
  378. *-  and  data  had  been stored in the global function (ie. extension
  379. *-  init which always is linked if the extension is used) or a lot of
  380. *-  copying and unecessary space waste  between  the  functions.  For
  381. *-  those  of you who never use the xpr-functions less memory will be
  382. *-  used.  The  only  thing  added  which  occupies  memory  are  the
  383. *-  timer.device structure and its replyport.
  384.  
  385. *-  The syntax for Lxpr are as follows :
  386.  
  387. *-  A$=Lxpr("filename","setup-string","libraryname",FUNCTION)
  388.  
  389. *-  where
  390.  
  391. *-     FUNCTION is either, 0 for Send file(s), 1 for Receive file(s),
  392. *-  2  for  Openlibrary,  3  for  Closelibrary,  4  for  Setup  (send
  393. *-  parameters),  5  for  read  (works like Lser Read, but XprHostMon
  394. *-  will be called if required, se below), 6 for  Write  (works  just
  395. *-  Lser Send, but calls XprUserMon if required).
  396.  
  397. *-     I strongly suggest that you set up some global  variables  and
  398. *-  assign appropriate values to them and then use them in all further
  399. *-  xpr-calls :
  400.  
  401. *-  XPRSEND =0
  402. *-  XPRREC  =1
  403. *-  XPROPEN =2
  404. *-  XPRCLOSE=3
  405. *-  XPRSETUP=4
  406. *-  XPRREAD =5
  407. *-  XPRWRITE=6
  408. ++  XPRCUSTOMIZE
  409.  
  410. *-     XPRREAD and XPRWRITE are always checked for first,guaranteeing
  411. *-  you as fast as possible reads and writes to/from the  device.  Of
  412. *-  course you may overrule the library's request that XprHostMon and
  413. *-  XprUserMon  should  be called, by calling Lser Read and Lser Send
  414. *-  instead. These two routines are somewhat faster than the  XPRREAD
  415. *-  and  WRITE and may safely be used if "flags" from SetUp indicates
  416. *-  that the protocol doesn't require  XprHostMon  and/or  XprUserMon
  417. *-  to be called.
  418.  
  419. Please note that it is up to your program to evaluate filepatterns requested
  420. by the user. XPRSEND and XPRREC only accepts full filenames separated by
  421. a space. If you use Ldos you can use the Lcat-commands in combination with
  422. Lmatch (Release 2 only) in order to find matching filenames.
  423.  
  424.  
  425.  
  426. *-  XPRSEND - Send one or more files.
  427. *-  A$=Lxpr(FILENAME$,"","",XPRSEND)
  428.  
  429. *-  where
  430.  
  431. *-     A$  currently  is  undefined  (empty  string).  FILENAME$  may
  432. *-  contain  one or more filenames which are to be sent. If more than
  433. *-  one filename is specified they must be separated  with  a  single
  434. *-  space. Note that all libraries doesn't support batchtransfers.
  435.  
  436.  
  437.  
  438. *- WARNING! FILENAME$ MUST BE NULLTERMINATED! (FILENAME$=FILENAME$+Chr$(0))
  439.  
  440.  
  441.  
  442. *-  XPRREC - Receive one or more files.
  443. *-  A$=Lxpr(FILENAME$,"","",XPRREC)
  444.  
  445. *-  where
  446.  
  447. *-     A$ currently is undefined (empty  string).  FILENAME$  can  be
  448. *-  left  out  if  "flags"  specified  that  the protocol can receive
  449. *-  filenames from sender (Ymodem-batch, Zmodem etc.)  FILENAME$  may
  450. *-  contain  more  than  one  filename  but  protocols  which handles
  451. *-  batchtransfers usually  can  receive  filenames  and  if  "flags"
  452. *-  specify this you may set FILENAME$="".
  453.  
  454. *- WARNING! FILENAME$ MUST BE NULLTERMINATED! (FILENAME$=FILENAME$+Chr$(0))
  455.  
  456.  
  457.  
  458. *-  XPROPEN - Open a xpr-library for use.
  459. *-  A$=Lxpr("","",LIBRARY$,XPROPEN)
  460.  
  461. *-  where
  462.  
  463. *-     A$ will be empty if the open failed, otherwise A$ will contain
  464. *-  the string "OK" (in capitals). LIBRARY$ is the complete  name  of
  465. *-  the library, for example xprzmodem.library.
  466.  
  467.  
  468.  
  469.  
  470. *-  XPRCLOSE - Close a xpr-library.
  471. *-  A$=Lxpr("","","",XPRCLOSE)
  472.  
  473. *-  where
  474.  
  475. *-     A$ currently is undefined. Always close your  current  library
  476. *-  before opening a new library or exiting the program.
  477.  
  478.  
  479.  
  480.  
  481. *-  XPRSETUP - Initialize the xpr and customize its performance.
  482. *-  A$=Lxpr("",SETUP$,"",XPRSETUP)
  483.  
  484. *-  where
  485.  
  486. *-       SETUP$  is  a  valid  option-string,  as  specified  in  the
  487. *-  protocol's documentation. A$ will contain a bit-pattern converted
  488. *-  to  ASCII.  Please  note  that  the order of the bits are left to
  489. *-  right  and  not  right  to  left  as  usual.  In    other   terms
  490. *-  Mid$(A$,1,1)  means  bit  0 (NOT 1) and Mid$(A$,1,3) means bit 2.
  491. *-  The bits have the following meanings :
  492.  
  493. *-  Bit 0 : If set, all was successful.
  494. *-  Bit 1 :  Protocol  requires  no  filerequester / filenames   when
  495. *-  receiving files. Note that the xpr may supply a filerequester
  496. *-  itself, which probably will appear on the workbench-screen  since
  497. *-  Lxpr  tells  the  xpr  to  use  this screen when/if xpr_getptr is
  498. *-  called.
  499. *-  Bit 2 : Protocol requires no filerequester/filnames when sending
  500. *-  files.
  501. *-  Bit 3 : The xpr would  like you  to use   XProtocolHostMon()  for
  502. *-  all serial input. This means that you SHOULD call XPRREAD instead
  503. *-  of  using  the  normal  Lser-functions. If you don't the protocol
  504. *-  might not operate correctly and functions such as  autoactivation
  505. *-  on download might be disabled. Note that it is perfectly legal to
  506. *-  call  XPRREAD  even  if  this  bit  isn't  set.  Lxpr  only calls
  507. *-  HostMon() if suitable.
  508. *-  Bit 4 : The  xpr  would  like you to use  XProtocolUserMon()  for
  509. *-  all  user  input (ie. it want  to check what you are sending). As
  510. *-  above, you should call XPRWRITE if this bit is set. Note that  it
  511. *-  is  perfectly  legal to call XPRWRITE even if this bit isn't set.
  512. *-  Lxpr only calls UserMon() if suitable.
  513. *-  Bit 5 : The  xpr  would  like you to use HostMon() even  when  no
  514. *-  input  from  is  received. This feature is NOT supported by Lxpr!
  515. *-  This can cause your program to be locked for an unknown time  and
  516. *-  may drain all CPU-power you have got.
  517.  
  518. *-    As  an  example  xprzmodem  returns  :  "110100"  (if  AY  was
  519. *-  requested).  The  first character ("1") says "All OK", the second
  520. *-  character ("1") indicates that the xpr doesn't need filename when
  521. *-  receiving files. The next "0"  indicates that the  protocol  need
  522. *-  filenames  (ie. you supply requester) when  sending. The last "1"
  523. *-  shows that the library want us to use XPRREAD since  it  want  to
  524. *-  check  incoming  data  (auto download). The second last zero says
  525. *-  that the library don't care what we send to the other  side  (you
  526. *-  may  still  use XPRWRITE safely) and the last zero indicates that
  527. *-  the protocol not will require a  call to HostMon() even  when  no
  528. *-  data is present (which Lxpr doesn't support)
  529.  
  530. *- WARNING! SETUP$ MUST BE NULLTERMINATED! (SETUP$=SETUP$+Chr$(0))
  531.  
  532.  
  533.  
  534.  
  535. *-  XPRREAD - Read any data that is currently available.
  536. *-  A$=Lxpr("","","",XPRREAD)
  537.  
  538. *-  where
  539.  
  540. *-     A$ will contain the data from the serial.device. Note that  if
  541. *-    the  xpr has requested HostMon() to be called the data can have
  542. *-  been modified  by the  xpr.  For  instance,  as  soon  as  zmodem
  543. *-  recognize  its  startsequence    for  download  it will start the
  544. *-  download and return an empty string and A$ will thus be empty.
  545.  
  546.  
  547.  
  548. *-  XPRWRITE - Write a string to the serial.
  549. *-  A$=Lxpr(STRING$,"","",XWRITE)
  550.  
  551. *-  where
  552.  
  553. *-     A$ always will be empty on return. Please note that if the xpr
  554. *-  has requested XProtocolUserMon() to be called  you  can  never be
  555. *-  sure that exactly the data you wanted to send really was sent. To
  556. *-  my knowledge there are currently no xpr available which writes to
  557. *-  your  data.  A  future  MNP-xpr however typically would need this
  558. *-  function. STRING$ is a normal textstring.
  559.  
  560.  
  561.  
  562. ++  XPRCUSTOMIZE - Change output from the xpr.
  563. ++  A$=Lxpr("x","text %code","",XCUSTOMIZE)
  564.  
  565. ++  where
  566.  
  567. ++     A$ always will be empty on return. "x"  is  a  special  "code"
  568. ++  which  tells  Lserial which text you wish to change. "text %code"
  569. ++  is the new text to be inserted. If you are to print a string, fx.
  570. ++  filename, you put  a  %s  where  you  want  the  filename  to  be
  571. ++  inserted.  If  you  are to print a number, like filesize, use %ld
  572. ++  instead. As said before, "x" is a character, ranging from "a"  to
  573. ++  "m"  for  the  various  strings. Default are: (just like in older
  574. ++  versions)
  575.  
  576.  
  577. ++  Code String
  578. ++  ---- ------
  579. ++  a    Protocol : %s
  580. ++  b    File name : %s
  581. ++  c    Size : %ld
  582. ++  d    Last message : %s
  583. ++  e    Last error : %s
  584. ++  f    # of Errors : %ld
  585. ++  g    # of Timeouts: %ld
  586. ++  h    # of Blocks : %ld, current size : %ld bytes
  587. ++  i    Transf. Bytes: %ld
  588. ++  j    Estimated : %s
  589. ++  k    Elapsed : %s
  590. ++  l    Error check : %s
  591. ++  m    CPS : %ld
  592.  
  593. ++     Note that it is wise to include both position of text, plus  a
  594. ++  Chr$(26)  (Cline)  which  erases the current line before the text
  595. ++  is printed. If you want to remove any message (even  if  the  xpr
  596. ++  supports  it)  you  can  call XPRCUSTOMIZE with only a space " ".
  597. ++  Also note that Lserial no longer prints any  messages  until  the
  598. ++  xpr asks it to. That may cause for instance "Last error" to never
  599. ++  be printed, if no errors occur. Because of this you might want to
  600. ++  Print  (using  normal  Print)  these  fields to the screen before
  601. ++  calling Lxpr. An example:
  602.  
  603. ++  A$=At(0,15)+"Last error : "
  604. ++  Print A$+"none so far."
  605.  
  606. ++  then modify the xpr-string:
  607.  
  608. ++  DUMMY$=Lxpr("e",Chr$(26)+A$+"%s","",XCUSTOMIZE)
  609.  
  610. ++  To shut Last error up forever:
  611.  
  612. ++  DUMMY$=Lxpr("e"," ","",XCUSTOMIZE)
  613.  
  614. ++  To print more than one result in one line:
  615. ++  (NOTE! that messages are printed in the same order  as  they  are
  616. ++  listed above! You thus have to put the Chr$(26) to clear the line
  617. ++  in the string which is printed first!)
  618.  
  619. ++  A1$=Chr$(26)+At(0,10)+"Estimated : %s"
  620. ++  A2$=At(30,10)+"(elapsed %s)"
  621. ++  DUMMY$=Lxpr("j",A1$,"",XCUSTOMIZE)
  622. ++  DUMMY$=Lxpr("k",A2$,"",XCUSTOMIZE)
  623.  
  624. ++  while would produce something like:
  625.  
  626. ++  "Estimated : 00:05:31 (elapsed 00:02:11)"
  627.  
  628.  
  629. ++     Please don't use to long strings, since some xprs return quite
  630. ++  long messages  sometimes.  Try  using  strings  shorter  than  30
  631. ++  characters if possible.
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.     BUGS:
  641.     -----
  642.        None found during my tests  against  a  few BBS's.  One  thing
  643.     could  happen  though and is nothing special to LSerial : Garbage
  644.     collection (which never happens). When using a  lot  of  strings,
  645.     AMOS once in a while need to do a garbage collection, sorting all
  646.     strings  together.  It  seems  like AMOS has very hard to see for
  647.     itself when it is time for this and strange gurus may follow.  If
  648.     this  happens  call  Free  (DUMMY=Free) once in  a while. If this
  649.     doesn't help call Free VERY often or increase the buffer  a  bit.
  650.     If  something  strange  still happens you might have found a bug,
  651.     please contact me.
  652.  
  653.  
  654. *-     Also you must be warned about the Lxpr-functions which doesn't
  655. *-  bother with such trivial things like  checking  if  you  actually
  656. *-  have  a library open! Lxpr return enough "codes" for your program
  657. *-  to make sure that everything is OK before it tries  to  call  any
  658. *-  other   function.  This  is  the  way  C,  Pascal  and  assembly-
  659. *-  programmers have to work...
  660.  
  661.  
  662.  
  663. !PLEASE READ IMPORTANT.TXT!
  664.  
  665.  
  666.  
  667.     APPENDIX A:
  668.     -----------
  669.     Errorcodes:
  670.  
  671.     0 Serial already open
  672.     1 Invalid devicename
  673.     2 Unable to open device
  674.     3 Overflow in stringbuffer
  675.     4 Invalid read-size
  676. ++  5 Command need NULL-terminated string
  677. ++  6 You can't call with an empty argument
  678. ++  7 Invalid XPR-customstring (a-m)
  679. ++  8 Non valid XPR-command
  680.  
  681.  
  682.  
  683.     APPENDIX B:
  684.     -----------
  685.  
  686.       The FLAGS are specified when opening the device. Each functions
  687.     is assigned  to a value (or bit) and you may  add  the  different
  688.     values  together  to  select  one  or  more  options. For further
  689.     information see the docs for the serial shipped with AMOS.  NOTE:
  690.     all values are in HEX! (LISTING FROM GenAm3, edited somewhat)
  691.  
  692.     Val   Name            Meaning
  693.     ---   ----            -------
  694.     $1  = SERF_PARTY_ON  - Parity on (even if not $2)
  695.     $2  = SERF_PARTY_ODD - Odd Parity
  696.     $4  = SERF_7WIRE     - 7Wire
  697.     $8  = SERF_QUEUEDBRK - Break in background
  698.     $10 = SERF_RAD_BOOGIE- Highspeed (disables div. checks)
  699.     $20 = SERF_SHARED    - Other programs may open device
  700.     $40 = SERF_EOFMODE   - EOF recognition enabled
  701.     $80 = SERF_XDISABLED - xON/xOFF disabled
  702.  
  703.     Typically you can set FLAGS to zero.
  704.  
  705.  
  706.                                APPENDIX C:
  707.                                -----------
  708.  
  709. ++  This example is a bit old now. See the one included with Ldos
  710. ++  instead!
  711.  
  712. *-     This is sample-program which shows how to use  the  xpr's  and
  713. *-  the  serial-commands  in  general. Actually it can be used as the
  714. *-  worlds shortest communicationprogram! It supports the most common
  715. *-  ANSI-sequences via Lansi (located in  Ldos) which converts  ANSI-
  716. *-  sequences to AMOS controlcodes. The only thing we need to convert
  717. *-  before  we  send it is the cursorkey-codes which are 3 bytes long
  718. *-  in "ANSI-format"
  719.  
  720. (There are no *- in this code, so you may easily load it into AMOS)
  721.  
  722.  
  723. Set Buffer 20      : Rem 20 Kb string-space
  724. Global XSEND,XREC,XOPEN,XCLOSE,XSETUP,XREAD,XWRITE
  725. XSEND=0            : Rem These are the globals which we use
  726. XREC=1             : Rem when calling Lxpr.
  727. XOPEN=2            : Rem This way you don't have to remember which
  728. XCLOSE=3           : Rem command that belonged to which value.
  729. XSETUP=4
  730. XREAD=5
  731. XWRITE=6
  732.  
  733.  
  734. E$=Chr$($1B)+Chr$($5B) : Rem ANSI-startsequence.
  735. CU$=E$+"A"             : Rem The codes for all
  736. CD$=E$+"B"             : Rem cursormovements.
  737. CR$=E$+"C"             : Rem Up,down,left and right
  738. CL$=E$+"D"
  739. Screen Open 1,640,256,8,Hires : Rem 8 colour ANSI is enough.
  740.                               : Rem Lansi converts 16->8 automatically
  741. Flash Off
  742. Palette ,,,$FF0
  743. Paper 0
  744. Clw
  745.  
  746. Rem Open serial.device in "standard-mode" with a 8 Kb buffer
  747. Lser Open 2400,8,1,8096,250000,$20,0,"serial.device"
  748.  
  749. Rem Just shows how to use Mul Send. Try this one in 300 bps!
  750. Lser Mul Send "ATZ"+Chr$(13)
  751.  
  752.  
  753. While Not Lser Mul Check : Rem wait until all data is sent
  754.    Print "Waiting for mulsend to complete.."
  755. Wend
  756.  
  757. Centre "Press <!> to quit demo" : Print
  758. Centre "Press <?> to SEND    files with Zmodem" : Print
  759. Centre "Press <+> to RECEIVE files with Zmodem" : Print
  760.  
  761. Rem Try to open xprzmodem.library
  762. STA$=Lxpr("","","xprzmodem.library",XOPEN) : Rem open
  763. If STA$<>"OK" : Rem if STA$="OK" the call was successful.
  764.    Print "Failed to open xprzmodem.library!"
  765.    Lser Close
  766.    End
  767. End If
  768.  
  769. Rem Initialize the library.
  770. Rem Z1=Chop files, TN=Text mode off, KY=Keep partial files
  771. Rem B4=Save buffer every 4Kb, OR=Owerwrite Resume, SN,RN=Don't send/
  772. Rem receive full paths, AY=Autoactivate (call HostMon()), E10=allow
  773. Rem 10 errors before abort.
  774. STA$=Lxpr("","Z1,TN,KY,B4,OR,SN,RN,AY,E10"+Chr$(0),"",XSETUP)
  775.  
  776. STATUS=Val(Mid$(STA$,1,1)) : Rem All OK? 0 if failed.
  777. FREQDL=Val(Mid$(STA$,2,1)) : Rem Need Freq for DL? (1 if not)
  778. FREQUL=Val(Mid$(STA$,3,1)) : Rem Need Freq for UL? (1 if not)
  779. Rem Don't care to check for User- and HostMon since we always call XREAD
  780. Rem and XWRITE and let Lxpr handle this..
  781.  
  782. If STATUS=0
  783.    Print "Failed to setup parameters..."
  784.    A$=Lxpr("","","",XCLOSE)
  785.    Lser Close
  786.    End
  787. End If
  788.  
  789. Do : Rem MainLoop
  790.    Multi Wait
  791.    A$=Inkey$
  792.    If A$="!" Then Exit 1
  793.    If A$="#" Then Clw : A$="" : Rem If the screen becomes garbled
  794.  
  795.    If A$="?"
  796.       Clw
  797.       If FREQUL=0 : Rem Do we need a filerequester?
  798.          Proc _GET_FILE : Rem If so get file(s)
  799.          A$=Param$
  800.          Print "Requested file(s): ";A$
  801.       Else
  802.          A$=""
  803.       End If
  804.       STA$=Lxpr(A$,"","",XSEND) : Rem start download
  805.       A$=""
  806.       Home : Cline : Print "Press a key!" : Wait Key : Clw
  807.    End If
  808.  
  809.    If(A$="+")
  810.       Clw
  811.       If FREQDL=0 : Rem Do we need to supply filename(s)
  812.          Proc _GET_FILE
  813.          A$=Param$
  814.          Print "Requested file(s): ";A$
  815.       Else
  816.          A$=""
  817.       End If
  818.       STA$=Lxpr(A$,"","",XREC)
  819.       Home
  820.    End If
  821.  
  822.    If A$<>"" : Rem Check for
  823.       If A$=Chr$(30) : Rem CURSOR UP
  824.          A$=CU$
  825.       End If
  826.       If A$=Chr$(31) : Rem CURSOR DOWN
  827.          A$=CD$
  828.       End If
  829.       If A$=Chr$(28) : Rem CURSOR RIGHT
  830.          A$=CR$
  831.       End If
  832.       If A$=Chr$(29) : Rem CURSOR LEFT
  833.          A$=CL$      : Rem and replace with ANSI-sequence
  834.       End If
  835.       D$=Lxpr(A$,"","",XWRITE) : Rem Send to modem
  836.    End If
  837.  
  838.    D=Free : Rem AMOS has always had problems with
  839.             Rem garbage collections. This prevents crashes
  840.             Rem when stringbuffer are use a lot.
  841.  
  842.    A$=Lxpr("","","",XREAD) : Rem is there anything to read?
  843.  
  844.    Print Lansi(A$); : Rem Convert ANSI->AMOS and print.
  845. Loop
  846.  
  847.  
  848. T$=Lxpr("","","",3) : Rem close library
  849. Lser Close          : Rem and device.
  850. Rem END OF PROGRAM
  851.  
  852. Procedure _GET_FILE
  853.    U:
  854.    Amos To Back
  855.    A$=Lfreq("Choose a file, press cancel when all are selected",$2+$4+$10+$40+$1000)
  856.    If A$="" Then Goto UT
  857.    If FILE$=""
  858.       FILE$=A$
  859.    Else
  860.       FILE$=FILE$+" "+A$
  861.    End If
  862.    Goto U
  863.    UT:
  864.    Amos To Front
  865. End Proc[FILE$+Chr$(0)]
  866.  
  867.