⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testterm.cpp

📁 DOS下采用中断接收数据的串口通讯的例子,很难找到的好东西!
💻 CPP
字号:
// ***************** START OF TESTTERM.CPP ****************
//
// This test program implements a simple IBM ANSI terminal 
// emulator. With a properly designed class, a terminal emulator
// amounts to just a few lines of code, since all of the work 
// here is being done by the AnsiTerminal object.  Note that 
// the Terminal and RS232 objects are both pointers to the 
// base class, not the derived class.  This shows how terminal 
// emulation can be performed without knowing anything about 
// the emulation code, or the display class.
//

#include "rs232.h"
#include "pc8250.h"
#include "ascii.h"
#include "ansiterm.h"
#include "textwind.h"

main()
{
    TextWindow window( 0, 0, 80, 25 );
    RS232 *port = new PC8250( COM1, 19200, 'N', 8, 1 );
    Terminal *terminal = new AnsiTerminal( *port, window );
    int c;

    window << "Press F10 to exit...\n";
    port->RtsCtsHandshaking( 1 );
    for ( ; ; ) {
        c = terminal->ReadPort();
        if ( c < 0 && c != RS232_TIMEOUT )
            break;
        if ( c >= 0 )
            terminal->Display( c );
        c = window.ReadKey();
        if ( c == F10 )
            break;
        if ( c != 0 )
            terminal->WriteKey( c );
    }
    delete terminal;
    delete port;
    return 0;
}

// ******************** END OF TESTTERM.CPP ********************

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -