亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产精品妹子av| 久久久精品一品道一区| 欧美色综合天天久久综合精品| 成人午夜视频免费看| 成人成人成人在线视频| 9人人澡人人爽人人精品| 91在线视频网址| 欧美日韩午夜在线| 欧美一级在线观看| 国产日韩欧美高清| 午夜影院在线观看欧美| 青娱乐精品视频在线| 国产高清在线精品| 色8久久人人97超碰香蕉987| 欧美乱妇23p| 国产欧美视频一区二区| 五月婷婷色综合| 大胆亚洲人体视频| 欧美一区二区精品久久911| 久久综合精品国产一区二区三区| 国产精品国产成人国产三级| 视频一区二区三区中文字幕| 国产精品1024| 精品卡一卡二卡三卡四在线| 亚洲免费观看高清完整版在线| 国产在线观看一区二区| 欧美日韩国产a| 一个色妞综合视频在线观看| 国产精品亚洲一区二区三区在线| 欧美日韩三级一区二区| 亚洲视频一区在线| 国产精品综合久久| 日韩欧美三级在线| 日日夜夜一区二区| 欧美人伦禁忌dvd放荡欲情| 一区视频在线播放| 成人a免费在线看| 国产精品麻豆视频| 成人午夜私人影院| 亚洲色图一区二区三区| 欧美一区二区视频在线观看| 亚洲成人中文在线| 亚洲一区二区欧美日韩| 人人狠狠综合久久亚洲| 午夜视频在线观看一区二区| 国产91色综合久久免费分享| 欧美日本国产一区| 精品福利一区二区三区免费视频| 香蕉久久夜色精品国产使用方法| 欧美性受xxxx黑人xyx性爽| 亚洲午夜一区二区| 欧美一级久久久| 国产在线精品国自产拍免费| 亚洲国产成人私人影院tom| 国模少妇一区二区三区| 日本一区二区三区电影| 制服丝袜国产精品| 亚洲一区二区三区视频在线播放 | 色婷婷激情久久| 亚洲综合色视频| 欧美精品一区二区三区一线天视频 | 欧美绝品在线观看成人午夜影视| 国产精品污www在线观看| 在线视频中文字幕一区二区| 蜜桃精品视频在线| 亚洲久草在线视频| 日韩久久久久久| 国产福利一区二区三区在线视频| 日本一区二区三级电影在线观看| 成人av在线一区二区三区| 日韩黄色免费网站| 国产精品久久毛片a| 日韩精品一区二区三区视频播放| 不卡免费追剧大全电视剧网站| 亚洲成人免费av| 亚洲色图在线播放| 国产区在线观看成人精品| 欧美一区二区在线不卡| 日本久久电影网| 成人黄色777网| 国产乱码精品一区二区三区av | 丝袜亚洲精品中文字幕一区| 中文字幕一区二区三区四区不卡 | 久久99国产精品麻豆| 日本成人中文字幕在线视频| 亚洲国产一区二区a毛片| 亚洲欧美日韩国产手机在线| 中文字幕一区视频| 亚洲视频一二三区| 亚洲制服欧美中文字幕中文字幕| 中文字幕一区在线观看| 综合欧美一区二区三区| 综合久久一区二区三区| 亚洲自拍都市欧美小说| 亚洲成av人片| 国产曰批免费观看久久久| 国产一区二区三区不卡在线观看| 国产一区久久久| 99久久精品费精品国产一区二区| 99久久99久久精品免费看蜜桃| jizzjizzjizz欧美| 在线观看日韩精品| 欧美电视剧免费观看| 国产精品成人网| 视频一区免费在线观看| 国产91综合一区在线观看| 成人国产精品免费观看视频| 99精品一区二区| 日韩精品一区二区在线观看| 亚洲国产精品v| 裸体一区二区三区| 91在线国产福利| 久久久电影一区二区三区| 美美哒免费高清在线观看视频一区二区| 久久精品国产久精国产| 欧美性受极品xxxx喷水| 中文字幕va一区二区三区| 日韩中文字幕区一区有砖一区| 风间由美性色一区二区三区| 欧美乱妇20p| 天天av天天翘天天综合网色鬼国产 | 91蜜桃在线观看| 精品播放一区二区| 首页综合国产亚洲丝袜| 成人午夜短视频| 精品日韩一区二区三区免费视频| 亚洲不卡一区二区三区| 波多野结衣一区二区三区| 久久综合九色综合久久久精品综合| 亚洲激情自拍视频| 99久精品国产| 亚洲精品乱码久久久久久黑人 | 久久蜜臀中文字幕| 国内欧美视频一区二区 | 肉色丝袜一区二区| 欧美日韩激情一区二区| 日韩不卡一区二区三区| 欧美一区二区三区小说| 黑人巨大精品欧美黑白配亚洲| 日韩欧美精品三级| 久久激情五月激情| 精品国产91乱码一区二区三区| 日本成人在线电影网| 久久你懂得1024| 色综合久久六月婷婷中文字幕| 亚洲精品国久久99热| 欧美日韩三级在线| 国产一区二区三区蝌蚪| 国产精品私房写真福利视频| 色综合中文字幕国产| 日韩成人精品视频| 亚洲国产高清aⅴ视频| 欧美日韩国产系列| 国产在线国偷精品产拍免费yy | 国产乱子伦一区二区三区国色天香| 久久天天做天天爱综合色| av一区二区三区黑人| 日韩精品每日更新| 久久久久成人黄色影片| 欧美三区免费完整视频在线观看| 久久超级碰视频| 伊人色综合久久天天人手人婷| 日韩精品专区在线影院观看| 91老司机福利 在线| 国模一区二区三区白浆| 蜜桃视频在线观看一区二区| 亚洲免费在线电影| 久久亚洲综合色一区二区三区 | 亚洲欧美怡红院| xfplay精品久久| 欧美一区二区三级| 欧美精品tushy高清| 欧美日韩在线精品一区二区三区激情| 国产二区国产一区在线观看| 免费的成人av| 日本不卡一区二区三区高清视频| 亚洲电影你懂得| 亚洲精品国产品国语在线app| 亚洲欧美综合另类在线卡通| 欧美国产日本视频| 亚洲素人一区二区| 亚洲精品第一国产综合野| 中文字幕一区二区日韩精品绯色| 国产精品欧美一区喷水| 国产精品三级在线观看| 亚洲人成网站色在线观看| 亚洲视频精选在线| 亚洲成av人片一区二区梦乃| 日韩高清不卡一区二区| 蜜桃精品视频在线观看| 国产成人8x视频一区二区| 91麻豆国产福利在线观看| 欧美综合欧美视频| 日韩一区二区三区在线| 欧美tickling网站挠脚心| 国产精品福利在线播放| 午夜精品久久久久久| 成人美女视频在线观看18| 日本韩国视频一区二区| 欧美成人福利视频|