home *** CD-ROM | disk | FTP | other *** search
- #ifndef PREFS_SERIAL_H
- #define PREFS_SERIAL_H
- /*
- ** $VER: serial.h 42.2 (4.10.1997) #CHEADER © Msi Software
- **
- ** File format for new (v1) serial preferences
- **
- ** Original (v38) structure was 33 in size, the new is 34 in size.
- **
- ** (C) Copyright 1997 Msi Software.
- ** All Rights Reserved
- */
-
- /*****************************************************************************/
- #ifndef EXEC_TYPES_H
- #include <exec/types.h>
- #endif
-
- #ifndef LIBRARIES_IFFPARSE_H
- #include <libraries/iffparse.h>
- #endif
- /*****************************************************************************/
-
- #define ID_SERL MAKE_ID('S','E','R','L') /* Serial settings ID */
- #define ID_SERN MAKE_ID('S','E','R','N') /* Serial name ID */
-
- struct SerialPrefs
- {
- LONG sp_Reserved[3]; /* System Reserved */
- ULONG sp_Unit0Map; /* default unit */
- ULONG sp_BaudRate; /* baud to be used */
-
- ULONG sp_InputBuffer; /* buffer size to be used (in bytes) */
- ULONG sp_OutputBuffer; /* buffer size to be used (in bytes) */
-
- UBYTE sp_InputHandshake; /* see handshake constants */
- UBYTE sp_OutputHandshake; /* see handshake constants */
-
- UBYTE sp_Parity; /* see parity constants */
- UBYTE sp_BitsPerChar; /* data bits (0-255) */
- UBYTE sp_StopBits; /* stop bits (0-255) */
- /* End of old structure! */
- /* The original "C=" object ends here! */
- UBYTE sp_SharedMode; /* See shared constants */
-
- }; /* SIZEOF=34, original was 33 */
-
- /* "sername" Full pathname of device, (0 terminated) */
- /* Stored in a separate IFF "SERN" CHUNK after the SERL chunk */
-
-
- /* constants for SerialPrefs.sp_Parity */
- #define PARITY_NONE 0
- #define PARITY_EVEN 1
- #define PARITY_ODD 2
- #define PARITY_MARK 3
- #define PARITY_SPACE 4
-
- /* constants for SerialPrefs.sp_Input/OutputHandshaking */
- #define HSHAKE_XON 0
- #define HSHAKE_RTS 1
- #define HSHAKE_NONE 2
-
- /* End of old constants! */
-
-
- /* constants for SerialPrefs.sp_SharedMode */
- #define SHARE_NONE 0
- #define SHARE_ON 1
-
-
- /* some nice defs */
- #define DEFSERNAME 'DEVS:serial.device'
- #define DEFSERENV 'ENV:Sys/serial.prefs'
- #define DEFSERENVARC 'ENVARC:Sys/serial.prefs'
- #define DEFSERPREFICON 'ENV:Sys/def_prefs'
- #define DEFSERPREFTOOL 'Sys:Prefs/Serial'
-
- /***************************************************************************
- serial.prefs versions
- SerPrefs uses the type entry in the PRHD chunk (prefheader)
- to let you know that the prefs are different.
- (INCLUDES:prefs/prefhdr.h)
- The original serial.prefs keep that value 0,
- and serial.prefs v42.x keep this value 1.
- When the next serial.prefs is defined it will
- have value 2 or something like that.
- So check the type in the PRHD chunk,
- since this is much better and safer than checking the size
- of the SERL chunk :-)
- If you find i.e 0 as the type in PRHD,
- then DO NOT try to use any data after the stop bit,
- since this most likely is an old serial.prefs.
- This way old programs can use new prefs without problems,
- (the old Serial programs will be ignorant to any extra data).
- And new programs is able to use old prefs,
- with no need for the user to convert the prefs.
-
- A nice way to read the serial.prefs is:
- 1. get prefsheader.version
- 2. get prefsheader.type
- 3. get prefsheader.flags
- 4. if type is not 0 then report to user and abort
- 5. currently just ignore the flags
- 6. check SERL chunk lenght (do not use lenght for version checking)
- 7. process first part (v0)
- 8. if type was 1 process second part (v1)
- 9. (when v2 etc is used you would process it here and so on)
- 10. get SERN and process filename if any (perhaps get device version)
-
- To avoid problems, always check that the lenght is "larger than 32",
- do not check if it is 34 or 33 since even though it is 33
- the bug cause it to become 34.
- For v1 you should check the SERL lenght if it is larger than 34 or not,
- if a v1 serial.prefs SERL chunk is less than 34, it is corrupt.
- Doing this allow us to use the same code for v0
- for v1 and v2 prefs, instead of separate v0,v1 ad v2 routines.
- SerPrefs v2.1 use this method, resulting in much less code needed :-)
-
- If you wonder why I used prefheader.type instead of prefheader.version,
- it is because when using prefheader.version,
- IPrefs complain about being unable to read the prefs,
- and since serial.prefs has not realy changed,
- but rather been extended this is silly since serial.prefs
- no longer is backwards compatible.
- But since there is no revision to use I had to use type instead,
- after all v1 is a different prefs than v0 :-)
- So by using type IPrefs is able to read the prefs as v0 prefs,
- thus baud etc is used correctly.
-
-
- sharedmode
- Due to a bug in the C= serial.prefs,
- the SERL chunk pad is counted into the SERL chunk lenght.
- To take advantage of this I used this "hidden" byte to
- toggle sharedmode, please note that neither IPrefs or original Serial
- is aware of this and will just ignore it (thinking it's a pad :-)
- Since the IFF specs say a pad should always be zero,
- we can count on it being correct (not corrupted by Serial prefs utils).
- But since it is counted as a part of the chunk,
- according to the IFF specs it is not a pad :-)
- So we can count on the IFF system to not mess with it either,
- so the result is a unused byte everyone ignores :-)
- I decided the first best thing to add to serial.prefs was Shared Mode,
- and what better place to start than the unused byte?
-
-
- bitsperchar
- Common "Data Bits" (Bits Per Char):
- 5, 6, 7, 8.
- 8 is most used, and also the default value.
-
- Additional bits (for future use):
- 16, 32.
- These are not used (hardly any hardware support >8 bits,
- but to avoid updating of software,
- these should be supported in preparation of new serial hardware.
-
-
- stopbits
- Common "Stop Bits":
- 0, 1, 2.
- 1 is most used, and also the default.
-
-
- inputbuffer/outputbuffer
- No real limits, can be up to the maximum 32bit value.
- Or down to 64 bytes, the C= docs etc,
- advise this value to be a multiple of 64.
- Advised default is 4096 bytes, advised minimum is 512 bytes.
- For simplicity use x*2, x/2 based values.
- Like 512, 1024, 2048, 4096 etc, so the user don't have to
- flip thru a bunch of numbers forever, or have to type it :-)
- It's easier to keep the value a multiple of 64 also.
-
- baudrate
- No common or advised, this vary alot on modem/hardware/connection etc.
- Can be odd/even, but using well know rates are HIGHLY ADVISED.
- This to avoid confusing users as well as software/hardware :-)
-
- Here is a list of rates (as used in Msi Software's "SerPrefs"):
-
- 75
- 110
- 150
- 300
- 600
- 1200
- 2400
- 4800
- 7200
- 9600 fax rate, default (old)
- 14400
- 16800
- 19200 14.4 rate, fax rate, common default
- 21600
- 24000
- 26400
- 28800
- 31200
- 31250 MIDI rate, max rate on older software/Amiga
- 33600
- 38400 28.8/33.6 rate, advised default due to many 28.8 modems
- 57600 Max (reliable) internal serial, can be used as 33.6 rate
- 64000
- 62400
- 64800
- 65535
- 65536
- 76800
- 115200 Squirrel Surf (SCSI w/serial for A1200) can go this high
- 230400
- 345600
- 460800
- 576000
- 614400
- 691200
- 806400
- 921600 (please note that the SerPrefs program may support even more)
-
-
- Roger Hågensen <emsai@online.no>
- Msi Software - 5th July 1997
- http://www.sn.no/~msi/index.htm
-
- ***************************************************************************/
-
- #endif /* PREFS_SERIAL_H */
-