home *** CD-ROM | disk | FTP | other *** search
/ The Best of Mecomp Multimedia 2 / MECOMP-CD-II.iso / amiga / tools / system / serprefs / developers / includes / prefs / serial.h next >
Encoding:
C/C++ Source or Header  |  1997-10-04  |  7.5 KB  |  229 lines

  1. #ifndef PREFS_SERIAL_H
  2. #define PREFS_SERIAL_H
  3. /*
  4. ** $VER: serial.h 42.2 (4.10.1997) #CHEADER © Msi Software
  5. **
  6. ** File format for new (v1) serial preferences
  7. **
  8. ** Original (v38) structure was 33 in size, the new is 34 in size.
  9. **
  10. ** (C) Copyright 1997 Msi Software.
  11. ** All Rights Reserved
  12. */
  13.  
  14. /*****************************************************************************/
  15. #ifndef EXEC_TYPES_H
  16. #include <exec/types.h>
  17. #endif
  18.  
  19. #ifndef LIBRARIES_IFFPARSE_H
  20. #include <libraries/iffparse.h>
  21. #endif
  22. /*****************************************************************************/
  23.  
  24. #define ID_SERL MAKE_ID('S','E','R','L') /* Serial settings ID */
  25. #define ID_SERN MAKE_ID('S','E','R','N') /* Serial name ID */
  26.  
  27. struct SerialPrefs
  28. {
  29.     LONG  sp_Reserved[3];      /* System Reserved */
  30.     ULONG sp_Unit0Map;         /* default unit */
  31.     ULONG sp_BaudRate;         /* baud to be used */
  32.  
  33.     ULONG sp_InputBuffer;      /* buffer size to be used (in bytes) */
  34.     ULONG sp_OutputBuffer;     /* buffer size to be used (in bytes) */
  35.  
  36.     UBYTE sp_InputHandshake;   /* see handshake constants */
  37.     UBYTE sp_OutputHandshake;  /* see handshake constants */
  38.  
  39.     UBYTE sp_Parity;           /* see parity constants */
  40.     UBYTE sp_BitsPerChar;      /* data bits (0-255) */
  41.     UBYTE sp_StopBits;         /* stop bits (0-255) */
  42.                                /* End of old structure! */
  43.                                /* The original "C=" object ends here! */
  44.     UBYTE sp_SharedMode;       /* See shared constants */
  45.  
  46. };                             /* SIZEOF=34, original was 33 */
  47.  
  48. /* "sername" Full pathname of device, (0 terminated) */
  49. /* Stored in a separate IFF "SERN" CHUNK after the SERL chunk */
  50.  
  51.  
  52. /* constants for SerialPrefs.sp_Parity */
  53. #define PARITY_NONE 0
  54. #define PARITY_EVEN 1
  55. #define PARITY_ODD 2
  56. #define PARITY_MARK 3
  57. #define PARITY_SPACE 4
  58.  
  59. /* constants for SerialPrefs.sp_Input/OutputHandshaking */
  60. #define HSHAKE_XON 0
  61. #define HSHAKE_RTS 1
  62. #define HSHAKE_NONE 2
  63.  
  64. /* End of old constants! */
  65.  
  66.  
  67. /* constants for SerialPrefs.sp_SharedMode */
  68. #define SHARE_NONE 0
  69. #define SHARE_ON 1
  70.  
  71.  
  72. /* some nice defs */
  73. #define DEFSERNAME 'DEVS:serial.device'
  74. #define DEFSERENV 'ENV:Sys/serial.prefs'
  75. #define DEFSERENVARC 'ENVARC:Sys/serial.prefs'
  76. #define DEFSERPREFICON 'ENV:Sys/def_prefs'
  77. #define DEFSERPREFTOOL 'Sys:Prefs/Serial'
  78.  
  79. /***************************************************************************
  80.    serial.prefs versions
  81.    SerPrefs uses the type entry in the PRHD chunk (prefheader)
  82.    to let you know that the prefs are different.
  83.    (INCLUDES:prefs/prefhdr.h)
  84.    The original serial.prefs keep that value 0,
  85.    and serial.prefs v42.x keep this value 1.
  86.    When the next serial.prefs is defined it will
  87.    have value 2 or something like that.
  88.    So check the type in the PRHD chunk,
  89.    since this is much better and safer than checking the size
  90.    of the SERL chunk :-)
  91.    If you find i.e 0 as the type in PRHD,
  92.    then DO NOT try to use any data after the stop bit,
  93.    since this most likely is an old serial.prefs.
  94.    This way old programs can use new prefs without problems,
  95.    (the old Serial programs will be ignorant to any extra data).
  96.    And new programs is able to use old prefs,
  97.    with no need for the user to convert the prefs.
  98.  
  99.    A nice way to read the serial.prefs is:
  100.    1. get prefsheader.version
  101.    2. get prefsheader.type
  102.    3. get prefsheader.flags
  103.    4. if type is not 0 then report to user and abort
  104.    5. currently just ignore the flags
  105.    6. check SERL chunk lenght (do not use lenght for version checking)
  106.    7. process first part (v0)
  107.    8. if type was 1 process second part (v1)
  108.    9. (when v2 etc is used you would process it here and so on)
  109.   10. get SERN and process filename if any (perhaps get device version)
  110.  
  111.    To avoid problems, always check that the lenght is "larger than 32",
  112.    do not check if it is 34 or 33 since even though it is 33
  113.    the bug cause it to become 34.
  114.    For v1 you should check the SERL lenght if it is larger than 34 or not,
  115.    if a v1 serial.prefs SERL chunk is less than 34, it is corrupt.
  116.    Doing this allow us to use the same code for v0
  117.    for v1 and v2 prefs, instead of separate v0,v1 ad v2 routines.
  118.    SerPrefs v2.1 use this method, resulting in much less code needed :-)
  119.  
  120.    If you wonder why I used prefheader.type instead of prefheader.version,
  121.    it is because when using prefheader.version,
  122.    IPrefs complain about being unable to read the prefs,
  123.    and since serial.prefs has not realy changed,
  124.    but rather been extended this is silly since serial.prefs
  125.    no longer is backwards compatible.
  126.    But since there is no revision to use I had to use type instead,
  127.    after all v1 is a different prefs than v0 :-)
  128.    So by using type IPrefs is able to read the prefs as v0 prefs,
  129.    thus baud etc is used correctly.
  130.  
  131.  
  132.    sharedmode
  133.    Due to a bug in the C= serial.prefs,
  134.    the SERL chunk pad is counted into the SERL chunk lenght.
  135.    To take advantage of this I used this "hidden" byte to
  136.    toggle sharedmode, please note that neither IPrefs or original Serial
  137.    is aware of this and will just ignore it (thinking it's a pad :-)
  138.    Since the IFF specs say a pad should always be zero,
  139.    we can count on it being correct (not corrupted by Serial prefs utils).
  140.    But since it is counted as a part of the chunk,
  141.    according to the IFF specs it is not a pad :-)
  142.    So we can count on the IFF system to not mess with it either,
  143.    so the result is a unused byte everyone ignores :-)
  144.    I decided the first best thing to add to serial.prefs was Shared Mode,
  145.    and what better place to start than the unused byte?
  146.  
  147.  
  148.    bitsperchar
  149.    Common "Data Bits" (Bits Per Char):
  150.    5, 6, 7, 8.
  151.    8 is most used, and also the default value.
  152.  
  153.    Additional bits (for future use):
  154.    16, 32.
  155.    These are not used (hardly any hardware support >8 bits,
  156.    but to avoid updating of software,
  157.    these should be supported in preparation of new serial hardware.
  158.  
  159.  
  160.    stopbits
  161.    Common "Stop Bits":
  162.    0, 1, 2.
  163.    1 is most used, and also the default.
  164.  
  165.  
  166.    inputbuffer/outputbuffer
  167.    No real limits, can be up to the maximum 32bit value.
  168.    Or down to 64 bytes, the C= docs etc,
  169.    advise this value to be a multiple of 64.
  170.    Advised default is 4096 bytes, advised minimum is 512 bytes.
  171.    For simplicity use x*2, x/2 based values.
  172.    Like 512, 1024, 2048, 4096 etc, so the user don't have to
  173.    flip thru a bunch of numbers forever, or have to type it :-)
  174.    It's easier to keep the value a multiple of 64 also.
  175.  
  176.    baudrate
  177.    No common or advised, this vary alot on modem/hardware/connection etc.
  178.    Can be odd/even, but using well know rates are HIGHLY ADVISED.
  179.    This to avoid confusing users as well as software/hardware :-)
  180.  
  181.    Here is a list of rates (as used in Msi Software's "SerPrefs"):
  182.  
  183.         75
  184.        110
  185.        150
  186.        300
  187.        600
  188.       1200
  189.       2400
  190.       4800
  191.       7200
  192.       9600 fax rate, default (old)
  193.      14400
  194.      16800
  195.      19200 14.4 rate, fax rate, common default
  196.      21600
  197.      24000
  198.      26400
  199.      28800
  200.      31200
  201.      31250 MIDI rate, max rate on older software/Amiga
  202.      33600
  203.      38400 28.8/33.6 rate, advised default due to many 28.8 modems
  204.      57600 Max (reliable) internal serial, can be used as 33.6 rate
  205.      64000
  206.      62400
  207.      64800
  208.      65535
  209.      65536
  210.      76800
  211.     115200 Squirrel Surf (SCSI w/serial for A1200) can go this high
  212.     230400
  213.     345600
  214.     460800
  215.     576000
  216.     614400
  217.     691200
  218.     806400
  219.     921600 (please note that the SerPrefs program may support even more)
  220.  
  221.  
  222.    Roger Hågensen <emsai@online.no>
  223.    Msi Software - 5th July 1997
  224.    http://www.sn.no/~msi/index.htm
  225.  
  226. ***************************************************************************/
  227.  
  228. #endif /* PREFS_SERIAL_H */
  229.