home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / util / libs / DigNet_1_0.lha / dignet / docs / dignet.doc
Encoding:
Text File  |  1997-02-25  |  10.8 KB  |  428 lines

  1. TABLE OF CONTENTS
  2.  
  3. dignet.library/---background---
  4. dignet.library/---notes---
  5. dignet.library/AbortNet
  6. dignet.library/AllocNet
  7. dignet.library/FreeNet
  8. dignet.library/InitIOEXT
  9. dignet.library/QueryNet
  10. dignet.library/ReadIOEXT
  11. dignet.library/ReadNet
  12. dignet.library/Timeout
  13. dignet.library/WriteNet
  14.  
  15.  
  16. dignet.library/---background---               dignet.library/---background---
  17.  
  18.  
  19.   We developed this library to ease the pain when writing serial
  20.   network dependent programs. It's always a husle when setting up
  21.   structure for this and that and allocate memory, init the device and
  22.   so on. We developed this library to do the dirty work for us.
  23.   It's straight forward to use and it does simple operations that
  24.   covers our need. Since this library is freeware we will not implement
  25.   "deeper" stuff such as signaling, async transfers and so on. We will
  26.   implement our own protocol in a future version though.
  27.  
  28.   If you're gonna communicate with another machine you just allocate
  29.   the serial.device or a compatible device, send your data from one
  30.   side, receive them on the other. And that's all you have to do.
  31.  
  32.   You are free to implement the library as a stand-alone file in your
  33.   archives. You should however give the file credit in your program
  34.   visable for the user. It should say something like:
  35.  
  36.     Using dignet.library by Kenneth "Kenny" Nilsen of
  37.     Digital Surface. Available from Aminet.
  38.  
  39.   That's all we require. If you don't want to add such a line in your
  40.   program(s) you must include the whole library archive with all files
  41.   as it came from Aminet.
  42.  
  43.  
  44.   We don't take responsibillity if your hardware or software gets
  45.   scrued up due to use of this library. You use it entirely at your
  46.   own risk!
  47.  
  48.  
  49.   You can mail us at:  kenny@bgnett.no
  50.   Visit the homepage:  http://www.bgnett.no/~kenny/
  51.  
  52.  
  53. dignet.library/---notes---                         dignet.library/---notes---
  54.  
  55.  
  56.   The NET is described as a structure, but since it is a private
  57.   structure it will be refered to as a APTR for the function call
  58.   (for C programmers). You should however make sure it is on a word
  59.   aligned address.
  60.  
  61.   To use the Read and Init IOEXT functions you must be sure that the
  62.   IOEXT block of the device is at the same offset as the serial.device.
  63.   For example, duart.device will work fine.
  64.  
  65.   When you write to a port you would make a small delay before you
  66.   read the destination port since sometimes it doesn't seem like the
  67.   datas is updated. Also, we would recommend you to transfer in small
  68.   blocks or even just in bytes to make sure every data is transfered
  69.   correctly. There will be implemented an own transfer protocol in a
  70.   future release of this library.
  71.  
  72.   Do NOT call functions that are marked PRIVATE (see FD file). They
  73.   WILL crash! You have been warned.
  74.  
  75. dignet.library/AbortNet                               dignet.library/AbortNet
  76.  
  77. NAME
  78.     AbortNet -- aborts the device IO
  79.  
  80. SYNOPSIS
  81.  
  82.     error=AbortNet(net)
  83.                    a0
  84.  
  85.     ULONG AbortNet(APTR);
  86.  
  87.  
  88. FUNCTION
  89.     This function will abort the iorequests at the device. All iorequests are
  90.     stopped immediatly. Read the serial.doc for more information on how this
  91.     works.
  92.  
  93. INPUTS
  94.     net - ptr. to a valid net structure
  95.  
  96. RESULTS 
  97.     error - return null or an errorcode
  98.  
  99. NOTES
  100.     
  101. EXAMPLE
  102.     
  103. BUGS
  104.     
  105. SEE ALSO
  106.     serial.doc
  107.  
  108. dignet.library/AllocNet                               dignet.library/AllocNet
  109.  
  110. NAME
  111.     AllocNet -- Allocates a private structure to use with the other functions
  112.  
  113. SYNOPSIS
  114.  
  115.     netstruct=AllocNet(devicename,unit)
  116.                        a1         d0
  117.  
  118.     APTR netstruct AllocNet(STRPTR,UWORD);
  119.  
  120.  
  121. FUNCTION
  122.     To use any of the functions in this library you need to allocate a net
  123.     structure. This structure is private. The structure information needed
  124.     for the other functions to know where and what to send/read. It also
  125.     allocates memory to use with IOEXT, message structures and so on.
  126.     Additional the device is flushed and aborted at startup to make a clean
  127.     start for user. When this function returns true you are ready to use the
  128.     device.
  129.  
  130.     The function will also init the device with the following defaults:
  131.  
  132.          baud  = 19200
  133.          mode  = 7WIRE and XDISABLED
  134.          read  = 8 bits
  135.          write = 8 bits
  136.          stop  = 1 bit
  137.    r/w buffers = 2 kb
  138.  
  139.     To change this setting use the ReadIOEXT() and InitIOEXT().
  140.  
  141. INPUTS
  142.     devicename - ptr. to the device name you want to open
  143.     unit - unit number
  144.  
  145. RESULTS 
  146.     netstruct - ptr. to a private structure or NULL if any failure
  147.  
  148. NOTES
  149.     NOTE: Devices returns NULL when succeeded. This library function will not
  150.     reflect this result. It will return NULL only if a failure occured such
  151.     as out of memory or the port couldn't be created or the device couldn't
  152.     be opened. There is currently no way within the library to find the exact
  153.     cause of the problem.
  154.  
  155. EXAMPLE
  156.  
  157. From C -
  158.     Net=AllocNet("serial.device",0)
  159.  
  160. From Assembler -
  161.     move.l    DignetBase,a6        ;library base in a6
  162.     lea    DeviceName,a0        ;device name in a0
  163.     moveq.l    #0,d0            ;unit number in d0
  164.     jsr    _LVOAllocNet(a6)    ;call function
  165.     move.l    d0,Net            ;store pointer
  166.     beq    Error            ;if null go to error handling
  167.  
  168. BUGS
  169.     Maybe an exact cause of an error should be implemented.
  170.  
  171. SEE ALSO
  172.     FreeNet(), ReadIOEXT(), InitIOEXT()
  173.  
  174. dignet.library/FreeNet                                 dignet.library/FreeNet
  175.  
  176. NAME
  177.     FreeNet -- Frees and cleanup the structure allocated with AllocNet()
  178.  
  179. SYNOPSIS
  180.  
  181.     FreeNet(net)
  182.             a0
  183.  
  184.     void FreeNet(APTR);
  185.  
  186.  
  187. FUNCTION
  188.     This function will free the structure allocated with AllocNet(). It will
  189.     also flush, abort, wait and close the device and then free memory
  190.     allocated with AllocNet().
  191.  
  192. INPUTS
  193.     net - ptr. to a valid net structure
  194.  
  195. EXAMPLE
  196.     FreeNet(net)
  197.  
  198. BUGS
  199.     
  200. SEE ALSO
  201.     AllocNet()
  202.  
  203.  
  204. dignet.library/InitIOEXT                             dignet.library/InitIOEXT
  205.  
  206. NAME
  207.     InitIOEXT -- Init the IOEXT structure of a device (serial/duart etc.)
  208.  
  209. SYNOPSIS
  210.  
  211.     error=InitIOEXT(net,newIOEXT,size)
  212.                     a0  a1       d0
  213.  
  214.     ULONG InitIOEXT(APTR,APTR,ULONG);
  215.  
  216.  
  217. FUNCTION
  218.     This function will init the IOEXT and call the device function
  219.     SetParameters. Only use this with devices that are compatible with the
  220.     serial device (for example duart.device).
  221.  
  222.     Always use the ReadIOEXT() first to copy current settings of the device
  223.     to your buffer. This way you only have to change some fields. If not you
  224.     will have to setup the whole IOEXT struture.
  225.  
  226. INPUTS
  227.     net - ptr. to a valid net structure
  228.     newIOEXT - ptr. to new settings
  229.     size - number of bytes to copy
  230.  
  231. RESULTS 
  232.     error - reflects the io_error field. Null if ok.
  233.  
  234. NOTES
  235.     
  236. EXAMPLE
  237.     
  238. BUGS
  239.     
  240. SEE ALSO
  241.     ReadIOEXT()
  242.  
  243. dignet.library/QueryNet                               dignet.library/QueryNet
  244.  
  245. NAME
  246.     QueryNet -- Query the device and return number of chars that are
  247.                 available for read.
  248.  
  249. SYNOPSIS
  250.  
  251.     chars=QueryNet(net)
  252.                   a0
  253.  
  254.     ULONG QueryNet(APTR);
  255.  
  256.  
  257. FUNCTION
  258.     Use this function before you ReadNet() the device. This function will
  259.     return number of bytes that are available to read. You can parse the
  260.     result directly to ReadNet(). If zero bytes the ReadNet() will abort and
  261.     return.
  262.  
  263. INPUTS
  264.     net - ptr. to a valid net structure
  265.  
  266. RESULTS 
  267.     chars - number of chars available to read
  268.  
  269. NOTES
  270.     
  271. EXAMPLE
  272.     
  273. BUGS
  274.     
  275. SEE ALSO
  276.     ReadNet()
  277.  
  278. dignet.library/ReadIOEXT                             dignet.library/ReadIOEXT
  279.  
  280. NAME
  281.     ReadIOEXT -- Copies current settings in IOEXT to a buffer
  282.  
  283. SYNOPSIS
  284.  
  285.     ReadIOEXT(net,buffer,size)
  286.                a0  a1     d0
  287.  
  288.     void ReadIOEXT(APTR,APTR,ULONG);
  289.  
  290.  
  291. FUNCTION
  292.     This function will copy current setting of the IOEXT structure used to
  293.     for example to set baud rate in the serial device. The device has to be
  294.     compatible with the serial device to read successfully. The reason for
  295.     this is that it reads from an offset that is valid for the serial.device.
  296.     If another device has its IOEXT structure at same offset this function
  297.     and the InitIOEXT() function can be used. Remember to set number of
  298.     bytes to copy.
  299.  
  300. INPUTS
  301.     net - ptr. to a valid net structure
  302.     buffer - ptr. to a buffer to copy to
  303.     size - number of bytes to copy
  304.  
  305. NOTES
  306.     Be careful when not using a serial.device compatible device.
  307.  
  308. EXAMPLE
  309.     
  310. BUGS
  311.     
  312. SEE ALSO
  313.     InitIOEXT()
  314.  
  315. dignet.library/ReadNet                                 dignet.library/ReadNet
  316.  
  317. NAME
  318.     ReadNet -- reads x bytes from the device
  319.  
  320. SYNOPSIS
  321.  
  322.     error=ReadNet(net,buffer,size)
  323.                   a0  a1     d0
  324.  
  325.     ULONG ReadNet(APTR,APTR,ULONG);
  326.  
  327.  
  328. FUNCTION
  329.     This function will read from the device. You should first call a query
  330.     function to check the number of bytes waiting and then read those into
  331.     your buffer. If zero bytes this function will abort immediatly so it is
  332.     safe to call it. If you ask for more bytes than are available this
  333.     function will wait until the amont can be obtained.
  334.  
  335. INPUTS
  336.     net - ptr. to a valid net structure
  337.     buffer - ptr. to a buffer
  338.     size - number of bytes to read
  339.  
  340. RESULTS 
  341.     error - null if ok, it reflect the io_error field
  342.  
  343. NOTES
  344.     
  345. EXAMPLE
  346.     error=ReadNet(net,buffer,queryresult)
  347.  
  348. BUGS
  349.     
  350. SEE ALSO
  351.     WriteNet(), QueryNet()
  352.  
  353.  
  354. dignet.library/Timeout                                 dignet.library/Timeout
  355.  
  356. NAME
  357.     Timeout -- waits x seconds to receive char(s) on the device for reading
  358.  
  359. SYNOPSIS
  360.  
  361.     chars=Timeout(net,seconds)
  362.                   a0  d0
  363.  
  364.     ULONG Timeout(APTR,UWORD);
  365.  
  366.  
  367. FUNCTION
  368.     You can use this function to give a device a certain amont of time to get
  369.     a char or more on the port for reading. You set seconds to wait. If a
  370.     char or more is received the function will return with the current amount
  371.     of chars in buffer. If timeout occure it will return with NULL.
  372.  
  373.     Null seconds is valid, however it will just call the QueryNet() function
  374.     instead and return immediatly.
  375.  
  376. INPUTS
  377.     net - ptr. to a valid net structure
  378.     seconds - number of seconds to wait for timeout
  379.  
  380. RESULTS 
  381.     chars - number of chars received before timeout or NULL if none
  382.  
  383. NOTES
  384.     
  385. EXAMPLE
  386.     
  387. BUGS
  388.     
  389. SEE ALSO
  390.     
  391. dignet.library/WriteNet                               dignet.library/WriteNet
  392.  
  393. NAME
  394.     WriteNet -- Writes x bytes to the device
  395.  
  396. SYNOPSIS
  397.  
  398.     error=WriteNet(net,buffer,size)
  399.                    a0  a1     d0
  400.  
  401.     ULONG WriteNet(APTR,APTR,ULONG);
  402.  
  403.  
  404. FUNCTION
  405.     This function write a number of bytes (really a copy) from a buffer of
  406.     size x. The function returns immediatly.
  407.  
  408. INPUTS
  409.     net - ptr. to a valid net structure
  410.     buffer - ptr. to a buffer taht contains bytes to write
  411.     size - number of bytes to write
  412.  
  413. RESULTS 
  414.     error - reflects the io_error field. Null if ok.
  415.  
  416. NOTES
  417.     
  418. EXAMPLE
  419.     error=WriteNet(net,buffer,100)
  420.  
  421. BUGS
  422.     There had to be implemented a delay of 20/50 of a second to not return
  423.     strange result if queried and read right after a write.
  424.  
  425. SEE ALSO
  426.     ReadNet()
  427.  
  428.