home *** CD-ROM | disk | FTP | other *** search
-
- /***************************************************************************
- These C++ classes are copyright 1990, by William Herrera.
- All those who put this code or its derivatives in a commercial product MUST
- mention this copyright in their documentation for users of the products in
- which this code or its derivative classes are used. Otherwise, this code
- may be freely distributed and freely used for any purpose.
- ***************************************************************************/
-
- // File comports.hpp
- // Class definition for COM1, COM2, COM3, and COM4 classes.
-
- #ifndef COMPORTS_HPP
- #define COMPORTS_HPP 1
-
- #include "uart.hpp"
- #include "charqueu.hpp"
-
- static void DoNothing() { return; }
-
- #ifdef __TURBOC__
-
-
- #define DECLARE_COMX(COM, x, driver) \
- \
- class COM##x : public uart \
- { \
- friend void interrupt driver##x(...); \
- friend class SerialPort; \
- protected: \
- static CharQueue * inq; \
- static CharQueue * outq; \
- static DRIVER driver; \
- static COM##x * this_ptr;/* allows driver to get to this */ \
- void (*DoIfNoCarrier)(); /* by default does nothing. */ \
- public: \
- COM##x(); \
- ~COM##x(); \
- virtual void SetDoIfNoCarrier(void (*f)()); \
- virtual void SendChar(char ch); \
- virtual int GetChar(); \
- void PurgeInput() { inq->Purge(); } \
- void FlushOutput(); \
- void PurgeOutput() { outq->Purge(); } \
- boolean InputEmpty() { return inq->IsEmpty(); } \
- boolean OutputEmpty() { return outq->IsEmpty(); } \
- boolean OutputReady() { return (boolean)!outq->IsFull(); } \
- }; \
- void interrupt driver##x(...);
-
-
-
-
- #else ifdef __ZTC__
-
- #define DECLARE_COMX(COM, x, driver) \
- \
- class COM##x : public uart \
- { \
- friend int _cdecl driver##x(struct INT_DATA *); \
- friend class SerialPort; \
- protected: \
- static CharQueue * inq; \
- static CharQueue * outq; \
- static DRIVER driver; \
- static COM##x * this_ptr;/* allows driver to get to this */ \
- void (*DoIfNoCarrier)(); /* by default does nothing. */ \
- public: \
- COM##x(); \
- ~COM##x(); \
- virtual void SetDoIfNoCarrier(void (*f)()); \
- virtual void SendChar(char ch); \
- virtual int GetChar(); \
- void PurgeInput() { inq->Purge(); } \
- void FlushOutput(); \
- void PurgeOutput() { outq->Purge(); } \
- boolean InputEmpty() { return inq->IsEmpty(); } \
- boolean OutputEmpty() { return outq->IsEmpty(); } \
- boolean OutputReady() { return (boolean)!outq->IsFull(); } \
- }; \
- int _cdecl driver##x(struct INT_DATA *);
-
-
-
- #endif
-
-
-
- // here we declare COM1 through COM4. Change to suit
-
- DECLARE_COMX(COM, 1, driver)
-
- DECLARE_COMX(COM, 2, driver)
-
- DECLARE_COMX(COM, 3, driver)
-
- DECLARE_COMX(COM, 4, driver)
-
- #endif
-
-