?? sertest.cpp
字號:
/* ------------------------------------------------------------------------ --
-- --
-- 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 <condefs.h>
#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;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -