/****h* TimedSerial.h *******************************************
*
* NAME
*    TimedSerial.h
*
* DESCRIPTION
*    Header file for the functions in TimedSerial.c
*****************************************************************
*
*/

#ifndef  TIMEDSERIAL_H
# define TIMEDSERIAL_H  1

# ifndef    EXEC_TYPES_H
#  include <exec/types.h>
# endif
 
# define  SETBAUD        1
# define  SETSTOP        2
# define  SETFLAGS       3
# define  SETEXTFLAGS    4
# define  SETREADLEN     5
# define  SETWRITELEN    6
# define  SETBREAKTIME   8
# define  SETCTLCHAR     9
# define  SETRBUFLEN     10

// --------------------------------------------------------------------

# ifdef ALLOCATE

VISIBLE int              TimedOut     = FALSE;
VISIBLE int              TimeValue    = 1;
VISIBLE ULONG            WaitSerMask  = 0L;

VISIBLE struct IOExtSer *ReadRequest  = NULL;
VISIBLE struct IOExtSer *WriteRequest = NULL;
VISIBLE char            *ReadBuffer   = NULL;
VISIBLE char            *WriteBuffer  = NULL;
VISIBLE int              ReadSize     = 0;
VISIBLE int              WriteSize    = 0;
VISIBLE UWORD            SerialStatus = 0;

# else

IMPORT int              TimedOut;
IMPORT int              TimeValue;
IMPORT ULONG            WaitSerMask;

IMPORT struct IOExtSer *ReadRequest;
IMPORT struct IOExtSer *WriteRequest;
IMPORT char            *ReadBuffer;
IMPORT char            *WriteBuffer;
IMPORT int              ReadSize;
IMPORT int              WriteSize;
IMPORT UWORD            SerialStatus;

# endif

// ---------- Function Prototypes: -------------------------------------

VISIBLE void  TimerDelay( int delayseconds );

VISIBLE int   TestTimer( void );

VISIBLE char *TranslateErrorNumber( int errnum );

VISIBLE int   OpenSerial( char *serName,
                          int   unit, 
                          int   HowLong, 
                          int   buffersize,
                          int   flags
                        );

VISIBLE void  CloseSerial( void );

VISIBLE char  *ReadString( int timeout, int strsize );
VISIBLE UBYTE  ReadChar(   int timeout );

VISIBLE int WriteString( int timeout, char *string, int strsize );
VISIBLE int WriteChar(   int timeout, int   ch                  );

VISIBLE int ResetSerial( int timeout );
VISIBLE int ClearSerial( int timeout );
VISIBLE int FlushSerial( int timeout );
VISIBLE int StopSerial(  int timeout );
VISIBLE int StartSerial( int timeout );
VISIBLE int QuerySerial( int timeout );
VISIBLE int BreakSerial( int timeout, int duration );

VISIBLE int SetSerialParams( int timeout, int which, int params );

VISIBLE int GetSerialStatus( void );

#endif

/* ------------------- END of TimedSerial.h file --------------------- */
