home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************
- *
- * COMM.H
- *
- * This file contains the header file needed to compile COMM16.C and
- * COMM32.C. This file should not be included in source code which
- * wishes to use the CommOS2 library.
- *_________________________________________________________________________
- *
- * Copyright (c) 1992 by ASH Software, Inc.
- *
- * Update History
- *
- * 12/ 6/1992 - Module created
- *
- **************************************************************************/
-
- #if !defined(COMM__H)
- #define COMM__H
-
- #define INCL_DOS
- #define INCL_ERRORS
- #define INCL_DOSDEVIOCTL
- #define INCL_DOSDEVICES
-
- #include <os2.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- #include "COMMOS2.H"
-
- //
- // This library uses a number of semaphores to serialize access to
- // resources. The following variable determines how long to wait
- // before returning to the calling program with an error. The
- // definition contains the length of time (in msec) to wait for
- // the semaphore. In addition, the definition SEM_INDEFINITE_WAIT
- // may be used to wait forever and SEM_IMMEDIATE_RETURN to return
- // without waiting.
- //
-
- #define COMMOS2_RESOURCE_SEM_WAIT 5000L // Wait 5 seconds
-
- #define COMM_QUERY_RXCOUNT 1
- #define COMM_QUERY_RXBUFFER 2
- #define COMM_QUERY_TXCOUNT 3
- #define COMM_QUERY_TXBUFFER 4
-
- #if defined(INCL_COMMOS2_16BIT)
- static DOSFSRSEM hCommSem;
- #define CommGetStruct COMMSTRUCT16
- #define TimerValue TIMERVALUE16
- #define TimerDifference TIMERDIFFERENCE16
- #define CommQueryQueue COMMQUERYQUEUE16
- #endif
-
- #if defined(INCL_COMMOS2_32BIT)
- static HMTX hCommSem;
- #define CommGetStruct COMMSTRUCT32
- #define TimerValue TIMERVALUE32
- #define TimerDifference TIMERDIFFERENCE32
- #define CommQueryQueue COMMQUERYQUEUE32
- #endif
-
- //
- // Define the Comm library error structure and declare an external
- // pointer to an array of these structures. The static global pointer
- // will be allocated during processing of CommStartSystem and freed
- // during processing of CommStopSystem.
- //
-
- typedef struct
- {
- DCBINFO DCBOriginal;
- DCBINFO DCBInfo; // Port DCB Info
- #if defined(INCL_COMMOS2_32BIT)
- HMTX hCommWriteSem;
- HMTX hCommReadSem;
- #endif
- #if defined(INCL_COMMOS2_16BIT)
- DOSFSRSEM hCommWriteSem;
- DOSFSRSEM hCommReadSem;
- #endif
- ULONG ulCommErrorCode; // Last Comm error code
- ULONG ulDosErrorCode; // Last Dos error code
- ULONG ulCommMode; // Last Comm mode
- USHORT usBaudRate; // Initial baud rate
- USHORT usParity; // Initial parity
- USHORT usDataBits; // Initial databits
- USHORT usStopBits; // Initial stopbits
- USHORT usTxBreak; // Initial Tx Break
- HFILE hCommPortFile; // Handle to Comm port
- int fPortOpened; // An attempt to open the port was made
- int fPortOpen; // Comm port is actually open
- } COMMOS2_STRUCT;
- typedef COMMOS2_STRUCT *PCOMMOS2_STRUCT;
-
- static PCOMMOS2_STRUCT
- pCommOS2Struct;
-
- static int
- iMaxNumberCommPorts = 0;
-
- //
- // Declare static functions
- //
-
- static PCOMMOS2_STRUCT CommGetStruct(HCOMMPORT hCommPort);
- static ULONG TimerValue(void);
- static ULONG TimerDifference(ULONG ulBaseTimerValue);
- static ULONG CommQueryQueue(HCOMMPORT hCommPort,short sMode,
- ULONG *ulValue);
-
- #endif
-