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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? digi.cpp

?? CHAPT05CHAPT05.CPP 16-Bit test program for the initelligent Digi board. CHAPT05CHAPT05.EXE 16-Bit e
?? 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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一本到不卡精品视频在线观看| 国产一区二区三区四区五区美女| 国产精品萝li| 国产一区二区三区最好精华液| 在线免费不卡电影| 亚洲男人天堂一区| 风间由美一区二区av101| 久久综合九色综合97_久久久| 蜜臀av在线播放一区二区三区 | 久久人人超碰精品| 视频一区二区三区入口| 欧美色国产精品| 亚洲成av人片www| 91精品久久久久久久91蜜桃 | 国产一区视频网站| 26uuu欧美| 国产成人免费在线观看不卡| 国产视频一区不卡| 国产一区二区不卡老阿姨| 精品国产自在久精品国产| 麻豆精品在线观看| 久久只精品国产| 成人午夜私人影院| 国产精品成人午夜| 欧美性大战久久| 三级不卡在线观看| 亚洲精品一区二区三区99| 久久成人精品无人区| 国产午夜久久久久| 91麻豆高清视频| 亚洲国产精品一区二区尤物区| 欧美日韩专区在线| 精品一区二区三区在线播放| 国产肉丝袜一区二区| 91在线视频在线| 亚洲高清免费视频| ww亚洲ww在线观看国产| 成人h动漫精品一区二区| 亚洲另类中文字| 欧美一区二区在线播放| 国产酒店精品激情| 亚洲欧美日韩中文字幕一区二区三区 | 色综合久久88色综合天天6| 亚洲丶国产丶欧美一区二区三区| 91精品国产一区二区三区蜜臀| 美脚の诱脚舐め脚责91| 国产精品久久久久久户外露出| 91福利国产成人精品照片| 蜜臀精品久久久久久蜜臀| 亚洲一区二区三区在线播放 | 欧美日韩中文国产| 久久99国产精品麻豆| 亚洲欧洲一区二区在线播放| 91精品一区二区三区久久久久久 | 成人黄色在线看| 亚洲va韩国va欧美va| 久久精品视频网| 欧美精品少妇一区二区三区| 高清日韩电视剧大全免费| 亚洲国产综合91精品麻豆| 久久久久久麻豆| 欧美婷婷六月丁香综合色| 国产黄人亚洲片| 午夜欧美电影在线观看| 国产精品免费视频网站| 日韩一区二区三区免费观看| 在线精品视频免费观看| 成人精品视频一区二区三区| 美国一区二区三区在线播放| 亚洲自拍与偷拍| 国产精品免费免费| 欧美大白屁股肥臀xxxxxx| 色婷婷久久久亚洲一区二区三区| 精东粉嫩av免费一区二区三区| 亚洲一级电影视频| 欧美专区日韩专区| 成人午夜电影小说| 婷婷久久综合九色综合绿巨人| 国产精品久久久久9999吃药| 欧洲视频一区二区| 成人午夜免费av| 久久国产尿小便嘘嘘尿| 日本最新不卡在线| 亚洲人精品一区| 欧美经典一区二区| 精品国产乱码久久久久久老虎| 欧美午夜寂寞影院| 色成年激情久久综合| 床上的激情91.| 成人免费av网站| 丁香六月综合激情| 国产91精品久久久久久久网曝门| 青青草国产成人av片免费| 日韩国产高清影视| 日韩极品在线观看| 日本亚洲免费观看| 免费成人美女在线观看| 亚洲sss视频在线视频| 亚洲gay无套男同| 亚洲 欧美综合在线网络| 亚洲午夜视频在线观看| 亚洲午夜一区二区三区| 亚洲福利国产精品| 日日夜夜免费精品视频| 亚洲国产wwwccc36天堂| 日韩精品国产精品| 蜜臀av性久久久久av蜜臀妖精| 久久精品久久综合| 国产剧情一区在线| 成人黄色免费短视频| 91视频观看免费| 精品视频在线免费看| 777久久久精品| 精品国产91久久久久久久妲己| 精品成人在线观看| 国产精品国产自产拍高清av| 亚洲人成在线播放网站岛国| 香蕉影视欧美成人| 久久av资源网| 北条麻妃一区二区三区| 色婷婷久久久亚洲一区二区三区 | 日韩av午夜在线观看| 麻豆成人免费电影| 国产成人高清视频| 色婷婷狠狠综合| 欧美一区二区三区精品| 精品国产91乱码一区二区三区| 国产亚洲一二三区| 亚洲精品日韩一| 日本欧美在线观看| 国产电影精品久久禁18| 91视频免费观看| 91精品国产综合久久国产大片| 久久久电影一区二区三区| 亚洲美女视频在线观看| 日韩高清不卡一区二区| 成人精品在线视频观看| 欧美日韩国产综合一区二区| 精品久久一区二区三区| 亚洲欧美色一区| 国内精品国产成人国产三级粉色| 99视频有精品| 欧美精品一区二区久久婷婷| 成人欧美一区二区三区视频网页| 男女男精品视频| 色哟哟一区二区在线观看| 久久久综合九色合综国产精品| 亚洲一区二三区| 麻豆精品视频在线观看| 99v久久综合狠狠综合久久| 日韩午夜精品电影| 亚洲免费色视频| 国产精品一二三在| 欧美人成免费网站| 欧美韩国日本一区| 亚洲美女少妇撒尿| 亚洲成人先锋电影| 不卡av在线免费观看| 亚洲精品一区二区三区四区高清 | 粉嫩aⅴ一区二区三区四区| 欧美不卡在线视频| 亚洲一区视频在线| 91在线观看成人| 久久久久久**毛片大全| 日韩高清不卡一区二区三区| 色综合天天综合狠狠| 日本一区二区三区四区在线视频 | 欧洲精品在线观看| 欧美大片一区二区三区| 亚洲一级二级三级在线免费观看| 激情久久五月天| 欧美一区二区三区免费视频 | 欧美激情一区二区三区在线| 老司机精品视频线观看86| 91麻豆精品91久久久久久清纯| 亚洲精品视频自拍| 99re这里都是精品| 亚洲欧美福利一区二区| 91天堂素人约啪| 亚洲欧美视频在线观看视频| 91在线精品一区二区| 中文一区二区在线观看| 成人免费视频网站在线观看| 久久精品人人做| 国产不卡免费视频| 国产欧美精品一区| 国产91在线|亚洲| 91麻豆精品国产| 亚洲国产精品久久人人爱| 91农村精品一区二区在线| 中文字幕在线一区二区三区| 成人精品视频一区二区三区| 国产精品国产自产拍高清av王其| 91在线看国产| 亚洲成人动漫精品| 欧美一区二区三区在线| 久久99热这里只有精品| 久久久国产精华| av中文字幕一区| 亚洲国产日韩av|