亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? digi.cpp

?? DOS下采用中斷接收數據的串口通訊的例子,很難找到的好東西!
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
//
//  DIGI.CPP
//
//  Source code from:
//
//  Serial Communications: A C++ Developer's Guide, 2nd Edition
//  by Mark Nelson, IDG Books, 1999
//
//  Please see the book for information on usage.
//
// This file contains all of the code used by the DigiBoard class.
// All access of the DigiBoard is done via the INT 14H interface
// described in the DOC file available from DigiBoard.
//

#include <stdio.h>
#include <ctype.h>
#include "pc8250.h"
#include "rs232.h"
#include "digi.h"

// The DigiBoard constructor is nice and simple.  It has to read
// in the old settings to save them, then set the new ones according
// to the parameters passed in the constructor.  The only private
// member exclusive to the derived class is the line-status flag,
// which is initialized to 0.  The call to function 0x20 is used
// to disable BIOS timing emulation.

DigiBoard::DigiBoard( RS232PortName port,
                      long baud_rate,
                      char parity,
                      int word_length,
                      int stop_bits,
                      int dtr,
                      int rts,
                      int xon_xoff,
                      int rts_cts,
                      int dtr_dsr )
{
    union REGS r;

    port_name = port;
    error_status = RS232_SUCCESS;

    first_debug_output_line = RS232::FormatDebugOutput();
    debug_line_count = FormatDebugOutput();
    if ( !valid_port() ) {
        error_status = (RS232Error) DIGIBOARD_DRIVER_NOT_FOUND;
        return;
    }
    read_settings();
    saved_settings = settings;
    settings.Adjust( baud_rate,
                     parity,
                     word_length,
                     stop_bits,
                     dtr,
                     rts,
                     xon_xoff,
                     rts_cts,
                     dtr_dsr );
    write_settings();
    r.h.ah = 0x20;
    r.h.al = 0;
    r.x.dx = port_name;
    int86( 0x14, &r, &r );
    line_status = 0;
}

// The destructor just restores the old state, nothing more.

DigiBoard::~DigiBoard( void )
{
    settings = saved_settings;
    write_settings();
}

//
// A call to function 0x0c and 0x05 are needed to read all the
// parameters found in the Settings class.  All that is
// needed after that is a bunch of switch statements to convert
// the enumerated results that come back from the driver to
// settings usable by programmers.
//

void DigiBoard::read_settings( void )
{
    union REGS r;

    settings.BaudRate = -1L;
    settings.Parity = '?';
    settings.WordLength = -1;
    settings.StopBits = -1;
    settings.Dtr = -1;
    settings.Rts = -1;
    settings.XonXoff = -1;
    settings.RtsCts = -1;
    settings.DtrDsr = -1;
    r.h.ah = 0xc;
    r.x.dx = port_name;
    int86( 0x14, &r, &r );
    if ( r.h.ah == 0xff )
        return;
    switch ( r.h.cl ) {
        case 0x00 : settings.BaudRate = 110L;    break;
        case 0x01 : settings.BaudRate = 150L;    break;
        case 0x02 : settings.BaudRate = 300L;    break;
        case 0x03 : settings.BaudRate = 600L;    break;
        case 0x04 : settings.BaudRate = 1200L;   break;
        case 0x05 : settings.BaudRate = 2400L;   break;
        case 0x06 : settings.BaudRate = 4800L;   break;
        case 0x07 : settings.BaudRate = 9600L;   break;
        case 0x08 : settings.BaudRate = 19200L;  break;
        case 0x09 : settings.BaudRate = 38400L;  break;
        case 0x0a : settings.BaudRate = 57600L;  break;
        case 0x0b : settings.BaudRate = 75600L;  break;
        case 0x0c : settings.BaudRate = 115200L; break;
        case 0x0d : settings.BaudRate = 50L;     break;
        case 0x0e : settings.BaudRate = 75L;     break;
        case 0x0f : settings.BaudRate = 134L;    break;
        case 0x10 : settings.BaudRate = 200L;    break;
        case 0x11 : settings.BaudRate = 1800L;   break;
    }
    switch ( r.h.bh ) {
        case 0 : settings.Parity = 'N'; break;
        case 1 : settings.Parity = 'O'; break;
        case 2 : settings.Parity = 'E'; break;
    }
    switch ( r.h.ch ) {
        case 0 : settings.WordLength = 5; break;
        case 1 : settings.WordLength = 6; break;
        case 2 : settings.WordLength = 7; break;
        case 3 : settings.WordLength = 8; break;
    }
    switch ( r.h.bl ) {
        case 0 : settings.StopBits = 1; break;
        case 1 : settings.StopBits = 2; break;
    }
    settings.XonXoff = ( r.h.ah & 3 ) ? 1: 0;
    settings.DtrDsr = ( r.h.al & 0x21 ) ? 1 : 0;
    settings.RtsCts = ( r.h.al & 0x12 ) ? 1 : 0;
    r.x.dx = port_name;
    r.h.ah = 5;
    r.h.al = 0;
    int86( 0x14, &r, &r );
    settings.Dtr = ( r.h.bl & MCR_DTR ) ? 1 : 0;
    settings.Rts = ( r.h.bl & MCR_RTS ) ? 1 : 0;
}

// Setting the digiboard up with all the parameters found in the
// Settings class requires three INT 14H calls.  Function 4
// sets the standard communications parameters, Function 5 sets
// the modem control lines, and function 0x1e sets up handshaking.
//

RS232Error DigiBoard::write_settings( void )
{
    union REGS r;
    RS232Error status = RS232_SUCCESS;

    r.x.dx = port_name;
    r.h.ah = 4;
    r.h.al = 0;
    switch ( toupper( settings.Parity ) ) {
        case 'E' : r.h.bh = 1; break;
        case 'O' : r.h.bh = 2; break;
        default  : settings.Parity = 'N';
                   status = RS232_ILLEGAL_PARITY_SETTING;
        case 'N' : r.h.bh = 0; break;
    }
    switch ( settings.StopBits ) {
        default : settings.StopBits = 1;
                  status = RS232_ILLEGAL_STOP_BITS;
        case 1  : r.h.bl = 0; break;
        case 2  : r.h.bl = 1; break;
    }
    switch ( settings.WordLength ) {
        case 5   : r.h.ch = 0; break;
        case 6   : r.h.ch = 1; break;
        case 7   : r.h.ch = 2; break;
        default  : settings.WordLength = 8;
                   status = RS232_ILLEGAL_WORD_LENGTH;
        case 8   : r.h.ch = 3; break;
    }
    switch ( settings.BaudRate ) {
        case 110L    : r.h.cl = 0x00; break;
        case 150L    : r.h.cl = 0x01; break;
        case 300L    : r.h.cl = 0x02; break;
        case 600L    : r.h.cl = 0x03; break;
        case 1200L   : r.h.cl = 0x04; break;
        case 2400L   : r.h.cl = 0x05; break;
        case 4800L   : r.h.cl = 0x06; break;
        default      : settings.BaudRate = 9600L;
                       status = RS232_ILLEGAL_BAUD_RATE;
        case 9600L   : r.h.cl = 0x07; break;
        case 19200L  : r.h.cl = 0x08; break;
        case 38400L  : r.h.cl = 0x09; break;
        case 57600L  : r.h.cl = 0x0a; break;
        case 76800L  : r.h.cl = 0x0b; break;
        case 115200L : r.h.cl = 0x0c; break;
        case 50L     : r.h.cl = 0x0d; break;
        case 75L     : r.h.cl = 0x0e; break;
        case 134L    : r.h.cl = 0x0f; break;
        case 200L    : r.h.cl = 0x10; break;
        case 1800L   : r.h.cl = 0x11; break;
    }
    int86( 0x14, &r, &r );
    r.x.dx = port_name;
    r.h.ah = 0x1e;
    r.h.bh = (unsigned char) ( ( settings.XonXoff ) ? 3: 0 );
    r.h.bl = (unsigned char) ( ( settings.RtsCts ) ? 0x12 : 0 );
    r.h.bl |= ( settings.DtrDsr ) ? 0x21 : 0;
    int86( 0x14, &r, &r );
    r.x.dx = port_name;
    r.h.ah = 5;
    r.h.al = 1;
    r.h.bl = (unsigned char) ( ( settings.Dtr ) ? 1 : 0 );
    r.h.bl |= ( settings.Rts ) ? 2 : 0;
    int86( 0x14, &r, &r );
    return status;
}

// Function 6 is called to return the name of the port, but
// it also functions effectively as a check to see if the
// DigiBoard considers the port to be a valid one.

int DigiBoard::valid_port( void )
{
    union REGS r;

    r.x.dx = port_name;
    r.h.ah = 6;
    r.h.al = 0;
    int86( 0x14, &r, &r );
    return ( r.h.ah != 0xff );
}

// Reading a byte uses the two BIOS emulation functions, one to
// read in the modem status, and the other to read the character.
// This function, like many of the other ones, updates the
// line status flags with the result read back from the board.

int DigiBoard::read_byte( void )
{
    union REGS r;

    if ( error_status < 0 )
        return error_status;
    r.h.ah = 3;
    r.x.dx = port_name;
    int86( 0x14, &r, &r );
    line_status |= r.h.ah;
    if ( r.h.ah & LSR_DATA_READY ) {
        r.h.ah = 2;
        r.x.dx = port_name;
        int86( 0x14, &r, &r );
        line_status |= r.h.ah;
        return( r.h.al );
    }
    return( RS232_TIMEOUT );
}

// This function also uses a standard BIOS function call.

int DigiBoard::write_byte( int c )
{
    union REGS r;

    if ( error_status < 0 )
        return error_status;
    r.x.dx = port_name;
    r.h.ah = 0x01;
    r.h.al = (char) c;
    int86( 0x14, &r, &r );
    line_status |= r.h.ah;
    if ( r.h.ah & 0x80 )
        return RS232_TIMEOUT;
    return RS232_SUCCESS;
}

// DigiBoard has two private functions, 14 and 15, which are
// used to read or write blocks of data.  They both transfer
// as much data as possible, then return a count.

int DigiBoard::read_buffer( char *buffer, unsigned int count )
{
    union REGS r;
    struct SREGS s;

    if ( error_status < 0 )
        return error_status;
    r.x.dx = port_name;
    r.x.cx = count;
    r.h.ah = 0x0f;
    s.es = (unsigned int) ( (long) (void __far *) buffer >> 16 );
    r.x.bx = (unsigned int) (long) (void __far *) buffer;
    int86x( 0x14, &r, &r, &s );
    ByteCount = r.x.ax;
    buffer[ ByteCount ] = '\0';
    if ( ByteCount != count )
        return RS232_TIMEOUT;
    return( RS232_SUCCESS );
}

int DigiBoard::write_buffer( char *buffer, unsigned int count )
{
    union REGS r;
    struct SREGS s;

    if ( error_status < RS232_SUCCESS )
        return error_status;

    r.x.dx = port_name;
    r.x.cx = count;
    r.h.ah = 0x0e;
    s.es = (unsigned int) ( (long) (void __far *) buffer >> 16 );
    r.x.bx = (unsigned int) (long) (void __far *) buffer;
    int86x( 0x14, &r, &r, &s );
    ByteCount = r.x.ax;
    if ( ByteCount != count )
        return RS232_TIMEOUT;
    return RS232_SUCCESS;
}

// This function does no work on its own.  Instead, it uses
// the adjust function to change the settings member, then
// calls the write_settings() function to do the job.

RS232Error DigiBoard::Set( long baud_rate,
                           int parity,
                           int word_length,
                           int stop_bits )
{
    settings.Adjust( baud_rate,
                     parity,
                     word_length,
                     stop_bits,
                     UNCHANGED,
                     UNCHANGED,
                     UNCHANGED,
                     UNCHANGED,
                     UNCHANGED );
    return write_settings();
}

// DigiBoard function 7 sets a break of a variable time in 10
// millisecond ticks.

int DigiBoard::Break( long milliseconds )
{
    union REGS r;

    if ( error_status < RS232_SUCCESS )
        return error_status;
    r.x.dx = port_name;
    r.h.ah = 7;
    r.h.al = 1;
    r.x.bx = (int) ( milliseconds / 10 );
    int86( 0x14, &r, &r );
    return RS232_SUCCESS;
}

// All four of the modem status functions just use BIOS function
// 3 to read in the MSR of the UART.  They then just mask off

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
免费成人在线观看视频| 欧美日韩一区二区三区视频| 色婷婷精品大在线视频| 欧美一区二区视频在线观看2020| 久久久99久久精品欧美| 午夜久久福利影院| 99久久精品久久久久久清纯| 久久综合九色综合欧美就去吻 | 精品久久人人做人人爽| 亚洲一二三四区不卡| 成人成人成人在线视频| 久久精品男人的天堂| 奇米影视7777精品一区二区| 欧美日韩国产色站一区二区三区| 中文字幕乱码一区二区免费| 黑人巨大精品欧美一区| 9191精品国产综合久久久久久| 亚洲欧洲av在线| 国产精品99久| 久久免费国产精品 | 亚洲国产综合91精品麻豆| 国产91对白在线观看九色| 精品成人一区二区三区| 日韩av在线发布| 欧美乱妇一区二区三区不卡视频| 亚洲毛片av在线| 色综合一区二区三区| 亚洲欧美在线视频| 菠萝蜜视频在线观看一区| 国产精品国产三级国产aⅴ无密码| 国产伦精品一区二区三区视频青涩 | 91黄色免费网站| 亚洲精品第1页| 欧美亚洲国产一区二区三区va| 亚洲精品成a人| 欧美在线视频全部完| 亚洲国产精品尤物yw在线观看| 欧美少妇一区二区| 日韩精品一二三| 精品国产一区二区三区忘忧草| 久久99国产精品麻豆| 久久久亚洲国产美女国产盗摄 | 久久九九国产精品| 激情成人午夜视频| 国产亚洲成年网址在线观看| 国产激情一区二区三区桃花岛亚洲| 欧美精品一区二区三区四区| 风间由美一区二区av101| 中文字幕av在线一区二区三区| 91丨九色丨尤物| 亚洲成人免费在线观看| 日韩免费观看高清完整版| 国产一区二区三区四区五区美女| 国产精品三级在线观看| 色婷婷综合久久久| 五月天丁香久久| 久久女同性恋中文字幕| 91免费国产视频网站| 视频一区二区三区在线| 国产亚洲一区二区在线观看| 97久久人人超碰| 丝袜美腿亚洲色图| 国产日本一区二区| 欧美日韩一卡二卡三卡| 国产一区二区成人久久免费影院| 国产精品久久久久久久久晋中| 欧美午夜一区二区三区| 国产馆精品极品| 日韩国产在线观看| 国内精品伊人久久久久影院对白| 精品视频在线看| 亚洲在线成人精品| 欧美www视频| 91免费版在线看| 玖玖九九国产精品| 亚洲欧美日韩国产中文在线| 精品国产青草久久久久福利| av不卡在线观看| 久久国产精品色| 亚洲小说春色综合另类电影| 久久久国际精品| 日韩欧美精品三级| 91久久精品一区二区三区| 国产麻豆精品在线| 奇米亚洲午夜久久精品| 亚洲精品日韩专区silk | 欧美视频在线播放| 不卡av免费在线观看| 国产一区二区三区免费| 亚洲成人自拍网| 亚洲欧美经典视频| 国产欧美日韩久久| 精品国产精品网麻豆系列| 欧美精品一级二级三级| 色94色欧美sute亚洲线路一ni| 国产不卡视频在线观看| 久久丁香综合五月国产三级网站| 亚洲综合色网站| 国产精品的网站| 国产欧美日本一区二区三区| 精品免费99久久| 91精品国产欧美一区二区18| 欧美色图免费看| 综合激情成人伊人| 亚洲欧美色图小说| 水蜜桃久久夜色精品一区的特点 | 国产美女在线精品| 久久国产生活片100| 天天综合色天天综合色h| 一区二区三区日韩| 最近日韩中文字幕| 国产精品麻豆视频| 国产精品天美传媒沈樵| 亚洲国产精品ⅴa在线观看| 国产无一区二区| 国产精品美女一区二区三区| 国产精品网曝门| 亚洲三级视频在线观看| 亚洲男人天堂一区| 亚洲一线二线三线久久久| 亚洲人成精品久久久久久 | 麻豆精品视频在线| 激情六月婷婷久久| 国产高清精品网站| 91网站在线观看视频| 一本大道久久a久久精二百| 色综合网站在线| 欧美理论在线播放| 精品日韩av一区二区| 久久精品男人天堂av| 国产精品国产三级国产专播品爱网| 亚洲一区二区在线免费观看视频| 一区二区免费在线播放| 日韩国产精品久久久| 黑人巨大精品欧美黑白配亚洲| 国产成人小视频| 色欲综合视频天天天| 欧美日韩高清一区二区三区| 日韩视频在线观看一区二区| 久久久青草青青国产亚洲免观| 中文字幕亚洲视频| 日韩电影免费一区| 国产精品中文字幕日韩精品 | 欧美一区二区日韩| 国产人妖乱国产精品人妖| 亚洲日本青草视频在线怡红院| 亚洲国产精品久久艾草纯爱| 久久av中文字幕片| 99re这里都是精品| 制服丝袜av成人在线看| 国产精品乱码一区二区三区软件| 一二三四区精品视频| 久久精品国产第一区二区三区| 成人精品免费视频| 3atv在线一区二区三区| 国产精品人人做人人爽人人添| 亚洲国产精品一区二区尤物区| 国产一区二区精品久久91| 欧美亚男人的天堂| 久久久99精品久久| 亚洲国产精品麻豆| 国产成人午夜电影网| 91精品国产综合久久精品麻豆| 久久久久久夜精品精品免费| 亚洲一区二区三区小说| 岛国精品一区二区| 这里只有精品电影| 亚洲精品日韩一| 国产99一区视频免费| 日韩一区二区免费在线电影| 亚洲精品久久嫩草网站秘色| 国产ts人妖一区二区| 日韩一级免费观看| 亚洲一区二区三区四区在线| 成人久久久精品乱码一区二区三区 | 国产在线国偷精品免费看| 欧美三区免费完整视频在线观看| 欧美国产精品中文字幕| 久久99九九99精品| 51精品国自产在线| 一区二区在线看| a4yy欧美一区二区三区| 久久你懂得1024| 国内精品久久久久影院一蜜桃| 欧美性受xxxx| 一区二区三区.www| 99久久精品免费精品国产| 久久久美女艺术照精彩视频福利播放| 日韩电影一二三区| 欧美日韩国产综合久久| 亚洲综合另类小说| 日本电影欧美片| 亚洲免费在线观看视频| 成人教育av在线| 亚洲国产激情av| 成人美女视频在线观看18| 欧美精彩视频一区二区三区| 国产精品一区二区在线看| 国产午夜精品一区二区| 丁香网亚洲国际|