/* ------------------------------------------------------------------------ -- -- -- -- Application example for using Tserial_event -- -- -- -- -- -- -- -- Copyright @ 2001 Thierry Schneider -- -- thierry@tetraedre.com -- -- -- -- -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Filename : sertest.cpp -- -- Author : Thierry Schneider -- -- Created : April 8th 2001 -- -- Modified : April 24th 2001 -- -- Plateform: Windows 95, 98, NT, 2000 (Win32) -- -- ------------------------------------------------------------------------ -- -- -- -- This software is given without any warranty. It can be distributed -- -- free of charge as long as this header remains, unchanged. -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- 01.04.24 # ifdef __BORLANDC__ added in the header -- -- -- -- -- -- ------------------------------------------------------------------------ */ /* ---------------------------------------------------------------------- */ #ifdef __BORLANDC__ #pragma hdrstop // borland specific #include #pragma argsused USEUNIT("Tserial_event.cpp"); #endif //--------------------------------------------------------------------------- #include "conio.h" #include "Tserial_event.h" /* ======================================================== */ /* =============== OnCharArrival ===================== */ /* ======================================================== */ void OnCharArrival(char c) { printf("OnCharArrival: %c ",c); } /* ======================================================== */ /* ================== OnConnected ===================== */ /* ======================================================== */ void OnConnected(void) { printf("Connected !"); } /* ======================================================== */ /* =================== OnDisconnected ==================== */ /* ======================================================== */ void OnDisconnected(void) { printf("Disconnected !"); } /* ======================================================== */ /* =================== OnCharSent ================= */ /* ======================================================== */ void OnCharSent(void) { printf(" Char Sent !"); } /* ======================================================== */ /* ======================== main ======================= */ /* ======================================================== */ int main(int argc, char* argv[]) { int c; Tserial_event *com; com = new Tserial_event(); if (com!=0) { // indicating to the serial object which function to // call in case of events com->setManagerOnCharArrival (OnCharArrival); com->setManagerOnConnected (OnConnected); com->setManagerOnDisconnected (OnDisconnected); com->setManagerOnCharSent (OnCharSent); com->connect("COM1", 19200, spNONE, 8); // ------------------ do { c = getch(); printf("_%c",c); com->sendChar((char) c); } while (c!=32); // ------------------ com->disconnect(); // ------------------ delete com; com = 0; } return 0; }