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

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

?? comm.cpp

?? 支持XMODEM,YMODEM,FAX協議的串口通信軟件包
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
// ******************************************************************** //
//                                                                      //
//      COMM.CPP                                                        //
//      Copyright (c) 1993, Michael Holmes and Bob Flanders             //
//      C++ Communication Utilities                                     //
//                                                                      //
//      Chapter 7: Receiving a FAX                                      //
//      Last changed in chapter 7                                       //
//                                                                      //
//      This file contains the functions to implement the basic         //
//      communications class and facilities.  Each instance of the      //
//      Comm class will control a single communications port.           //
//                                                                      //
// ******************************************************************** //


class Comm
    {
    public:
        Comm(int b,                         // define a comm instance
             int i,                         //   base addr, interrupt
             int d,                         //   baud rate divisor
             int l,                         //   line control setting
             int fc = 0,                    //   flow control flag
             UINT si = 3200,                //   input queue size
             UINT so = 1500);               //   and output queue size
        UINT Read(char *c,                  // read a character from queue
                  char *m,                  // ..and get modem status reg
                  char *l),                 //   and line status register
             Set8n(void),                   // set 8 data bits, no parity
             ICount(void),                  // get depth of input queue
             OCount(void),                  // ..or output queue
             IFree(void),                   // free space in input queue
             OFree(void);                   // ..or output queue
        int  Modem(void),                   // rtn modem status register
             ModemChanged(void),            // rtn TRUE if msr changed
             IFlow(void),                   // rtn input flow ctrl status
             IEmpty(void),                  // rtn TRUE if input queue
             OEmpty(void);                  // ..or output queue empty
        long GetSpeed(void);                // rtn current speed in bps
        void SetSpeed(int d),               // set up port's divisor
             SetBPS(long s),                // set up port's speed
             SetLine(int l),                // ..and line control register
             Write(int c),                  // write a character
             Write(char *s),                // ..or a string of characters
             Write(char *s, int l),         // ..or a block of characters
             IClear(void),                  // clear input queue
             OClear(void),                  // ..and output queue
             DTR(long t = 1500L),           // lower DTR temporarily
             RTS(int),                      // RTS signal control
             IntRoutine(void);              // interrupt service routine
       ~Comm();                             // destructor

    private:
        UINT base,                          // base port address
             irq,                           // interrupt number
             divisor,                       // baud rate divisor
             line,                          // initial line control
             i_size,                        // input buffer size
             o_size,                        // output buffer size
             i_start,                       // flow ctl restart limit
             i_stop,                        // ..and upper stop limit
             i_count,                       // characters in input queue
             o_count,                       // ..and output queue
             Deque(void);                   // deque an output queue char
        char *i_buf,                        // input buffer
             *i_get,                        // ..and nxt user get location
             *i_put,                        // ..and nxt comm put location
             *i_limit,                      // ..and last location
             *i_last,                       // ..and last i_put location
             i_of,                          // ..and input overflow flag
             *o_buf,                        // output buffer
             *o_get,                        // ..and nxt comm get location
             *o_put,                        // ..and nxt user put location
             *o_limit,                      // ..and last location
             msr_changed,                   // msr changed flag
             int_msr,                       // last interrupt msr
             int_lsr,                       // ..and last interrupt lsr
             fifo,                          // 16550 flag
             flow,                          // flow control enable flag
             o_flow,                        // output flow controlled flag
             i_flow,                        // input flow controlled flag
             empty_trans;                   // empty transmitter flag
        void InstallInt(void),              // install interrupt svc rtn
             DeInstallInt(void),            // de-install interrupt rtn
             SetLimits(void),               // set up flow ctl limits
             CheckFifo(void),               // set up fifo flags
             Queue(int c,                   // queue char to input queue
                   int m,                   //   saving modem status reg
                   int l),                  //   and line status register
             interrupt (*old_comm)(...);    // old comm interrupt pointer
    };


extern
Comm   *comm;                               // current Comm instance
void    interrupt far comm_int(...);        // comm interrupt routine



/* ******************************************************************** *
 *
 *  Comm -- define communications port instance
 *
 * ******************************************************************** */

Comm::Comm(int b,                           // comm port base address
           int i,                           // interrupt number
           int d,                           // baud rate divisor
           int l,                           // line control setting
           int fc,                          // flow control flag
           UINT si,                         // input queue size
           UINT so)                         // output queue size
{
UINT    max_size = 64535U / 3;              // max number of input chars

base = b;                                   // set up instance base addr
irq = i;                                    // ..interrupt request
o_size = so;                                // ..output buffer size
flow = fc;                                  // ..flow control flag
CheckFifo();                                // ..fifo flag if available
SetSpeed(d);                                // ..line speed
SetLine(l);                                 // ..line format

if (si < 512)                               // q. less than .5k of buffer?
    si = 512;                               // a. yes .. set to minimum

if (si > max_size)                          // q. greater than maximum?
    si = max_size;                          // a. yes .. set to max size

if (so < 256)                               // q. really small output buf?
    so = 256;                               // a. yes .. set to minimum

i_size = si;                                // save input buffer size
empty_trans = 1;                            // ..set empty transmitter flag
msr_changed = 1;                            // ..set msr changed flag
o_flow = i_flow = 0;                        // ..clear active flags
o_count = i_count = 0;                      // ..and current queue counts

i_buf = i_get = i_put =                     // allocate input buffer
            new char[i_size * 3];           // ..for data, lsr and msr
i_limit = i_buf + (i_size - 1) * 3;         // ..set limit address
memset(i_buf, 0, i_size * 3);               // ..and clear area to nulls

o_buf = o_get = o_put = new char[o_size];   // allocate output buffer
o_limit = o_buf + o_size - 1;               // ..set limit address
memset(o_buf, 0, o_size);                   // ..and clear area to nulls

SetLimits();                                // set up flow ctl limits
InstallInt();                               // ..and interrupt routine

int_msr = IN(MSR);                          // set up initial MSR

}



/* ******************************************************************** *
 *
 *  SetLimits -- set up receive buffer flow control limits
 *
 *  This routine sets up the flow control limits for receive
 *  operations.  Flow control will be asserted when the buffer
 *  reaches a point when there is not enough room to receive
 *  a second worth of data in the input buffer.  Flow control will
 *  be de-asserted when 50% of the upper limit is read by the
 *  application.
 *
 * ******************************************************************** */

void    Comm::SetLimits(void)
{

i_stop = (UINT) (115200L / 10) / divisor;   // get 1 second in characters

if (i_stop > i_size)                        // q. limit too high?
    i_stop = i_size / 2;                    // a. yes .. set at half
 else
    i_stop = i_size - i_stop;               // else .. set limit point

i_start = i_stop / 2;                       // set restart point at 50%

}



/* ******************************************************************** *
 *
 *  CheckFifo -- if UART is a 16550, set FIFO variable to true
 *
 * ******************************************************************** */

void    Comm::CheckFifo(void)
{

fifo = 0;                                   // assume standard uart
OUT(FCR, 0xcf);                             // try to enable FIFOs

if ((IN(IIR) & 0xc0) != 0xc0)               // q. FIFO bits found?
    return;                                 // a. no .. just return

OUT(FCR, 0);                                // turn off FIFOs
fifo = 1;                                   // set fifo available flag

}



/* ******************************************************************** *
 *
 *  SetSpeed -- set up port baud rate divisor
 *
 * ******************************************************************** */

void    Comm::SetSpeed(int d)               // baud rate divisor
{

divisor = d;                                // save divisor for later
OUT(IER, 0);                                // clear interrupts enable

if (fifo)                                   // q. is UART a 16550 chip?
    OUT(FCR, FCR_16550);                    // a. yes .. enable fifo

IN(LSR);                                    // read/reset line status reg
IN(MSR);                                    // ..and modem status register
IN(IIR);                                    // ..and interrupt id register
IN(RBR);                                    // ..and receive buffer reg

__asm   cli                                 // stop interrupts
OUT(LCR, IN(LCR) | LCR_DLAB);               // set divisor latch bit
OUT(DLM, d >> 8);                           // out msb portion of divisor
OUT(DLL, d & 0xff);                         // ..then the lsb portion
OUT(LCR, IN(LCR) & ~LCR_DLAB);              // clear divisor latch bit
OUT(MCR, MCR_DO);                           // enable DTR, OUT2 and RTS
__asm   sti                                 // ..and interrupts

OUT(IER, IER_RBF | IER_TBE | IER_MSI);      // then enable UART interrupts

}



/* ******************************************************************** *
 *
 *  SetBPS -- set port's speed
 *
 * ******************************************************************** */

void    Comm::SetBPS(long s)                // speed in BPS
{

SetSpeed((int)(115200L / s));               // calc and set divisor

}



/* ******************************************************************** *
 *
 *  GetSpeed -- retrieve current port speed
 *
 * ******************************************************************** */

long   Comm::GetSpeed(void)
{

return((long) (115200L / (long) divisor));  // return current speed

}



/* ******************************************************************** *
 *
 *  SetLine -- set up port's line control register
 *
 * ******************************************************************** */

void    Comm::SetLine(int l)                // new line control setting
{

line = l & ~LCR_DLAB;                       // save new value in instance
OUT(LCR, line);                             // ..and write new LCR

}



?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产在线国偷精品免费看| 丝袜诱惑制服诱惑色一区在线观看| 久久av中文字幕片| 人人精品人人爱| 欧美日本一区二区三区| 丝袜国产日韩另类美女| 日韩欧美国产精品一区| 激情偷乱视频一区二区三区| 久久九九久久九九| 色综合色狠狠综合色| 性久久久久久久久久久久| 宅男噜噜噜66一区二区66| 久久精品国产亚洲一区二区三区| 亚洲精品一区二区三区影院| 成人毛片视频在线观看| 亚洲一区二区三区在线| 日韩视频国产视频| 成人免费黄色在线| 亚洲成va人在线观看| 精品久久久久久无| 96av麻豆蜜桃一区二区| 五月天国产精品| 国产欧美日韩麻豆91| 91福利精品视频| 欧美日韩在线精品一区二区三区激情| 视频在线观看一区| 国产人伦精品一区二区| 在线观看日韩毛片| 国产剧情一区在线| 日韩制服丝袜先锋影音| 国产精品欧美一区二区三区| 欧美二区三区的天堂| 不卡的av电影| 青青草原综合久久大伊人精品 | 中国色在线观看另类| 在线观看日韩电影| 国产91综合网| 天天综合网 天天综合色| 136国产福利精品导航| 日韩一卡二卡三卡四卡| 欧美影视一区二区三区| 国产成人免费xxxxxxxx| 玖玖九九国产精品| 亚洲第一福利视频在线| 国产精品免费视频网站| 欧美成人精品福利| 欧美另类久久久品| 91女人视频在线观看| 国产精品自拍av| 九九视频精品免费| 天天射综合影视| 亚洲主播在线播放| 亚洲桃色在线一区| 中文无字幕一区二区三区| 日韩午夜av一区| 欧美伦理电影网| 欧美日韩免费电影| 在线精品视频免费播放| jlzzjlzz欧美大全| 国产99久久久国产精品| 国产一二三精品| 精品一二三四区| 麻豆传媒一区二区三区| 天天综合色天天| 日韩激情视频在线观看| 亚洲6080在线| 亚洲h在线观看| 三级不卡在线观看| 日韩电影在线观看一区| 日韩国产欧美视频| 奇米精品一区二区三区在线观看一| 亚洲图片有声小说| 亚洲6080在线| 美女一区二区久久| 久久99精品一区二区三区| 经典三级视频一区| 国产一区二区三区最好精华液| 精品一区二区三区日韩| 国产乱码精品1区2区3区| 国产精品456露脸| 成人a区在线观看| 色狠狠色噜噜噜综合网| 欧美日韩亚洲另类| 日韩午夜激情视频| 久久精品这里都是精品| 国产欧美一区二区三区在线看蜜臀 | 久久国内精品视频| 国产一区二区在线观看视频| 国产精品 日产精品 欧美精品| 国产69精品久久久久777| 成人精品国产福利| 91黄视频在线| 日韩三级中文字幕| 久久精品视频网| 亚洲女爱视频在线| 天天做天天摸天天爽国产一区| 精品一二三四区| a美女胸又www黄视频久久| 欧美在线影院一区二区| 日韩一区二区三区观看| 2023国产精华国产精品| 日韩一区日韩二区| 日韩在线一区二区| 国产激情一区二区三区桃花岛亚洲| 97se亚洲国产综合自在线不卡| 欧美日韩国产片| 日本一区二区三区在线观看| 亚洲裸体xxx| 美国毛片一区二区三区| 成人性生交大片免费看中文网站| 91电影在线观看| 欧美精品一区二区在线播放| 中文字幕欧美一区| 日韩中文字幕亚洲一区二区va在线| 国产美女视频一区| 欧美日韩的一区二区| 久久久国产综合精品女国产盗摄| 一区二区三区四区激情| 国产麻豆成人精品| 精品视频色一区| 国产三级精品三级| 欧美a级理论片| 91在线观看下载| 欧美xxxxx裸体时装秀| 自拍偷拍欧美激情| 国产精品综合二区| 欧美日本国产一区| 亚洲女女做受ⅹxx高潮| 国产精品羞羞答答xxdd| 欧美写真视频网站| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | 亚洲特级片在线| 久久99精品国产.久久久久久 | 爽好多水快深点欧美视频| 国产麻豆精品视频| 7777精品久久久大香线蕉| 中文字幕亚洲精品在线观看| 精品一区二区三区不卡| 欧美日韩精品综合在线| 自拍偷拍国产亚洲| 成人动漫中文字幕| 国产亚洲一二三区| 国内精品自线一区二区三区视频| 欧美日韩性生活| 一区二区三区自拍| 99视频一区二区| 中文字幕一区二区日韩精品绯色| 国产精品综合二区| ww久久中文字幕| 精品一区二区三区免费| 日韩午夜精品视频| 麻豆91在线播放免费| 3d动漫精品啪啪1区2区免费| 亚洲大片免费看| 欧美日韩专区在线| 精品国产在天天线2019| 久久国内精品自在自线400部| 欧美久久久久久久久久| 一区二区三区欧美视频| 91久久精品网| 亚洲成a人片在线不卡一二三区 | 国产精品丝袜一区| 国产剧情av麻豆香蕉精品| 久久久午夜精品理论片中文字幕| 久久精品久久久精品美女| 日韩三级视频中文字幕| 免费人成在线不卡| 26uuu久久天堂性欧美| 国内成人自拍视频| 欧美极品少妇xxxxⅹ高跟鞋| 高潮精品一区videoshd| 国产精品久久久久久久久久久免费看 | 欧美日韩黄视频| 日韩精品午夜视频| 91精品国产一区二区| 日韩av一二三| 欧美精品一区二区三区很污很色的| 韩国欧美一区二区| 国产精品视频yy9299一区| av男人天堂一区| 亚洲国产精品久久不卡毛片| 欧美一区二区三区精品| 激情综合色综合久久综合| 久久久99久久| 91香蕉视频污| 亚洲一区二区三区美女| 欧美美女网站色| 韩国精品一区二区| 亚洲欧洲色图综合| 欧美日韩免费不卡视频一区二区三区| 日本午夜精品一区二区三区电影| 久久久久久免费网| 欧洲精品一区二区三区在线观看| 五月综合激情日本mⅴ| 久久先锋影音av鲁色资源网| av在线播放一区二区三区| 天涯成人国产亚洲精品一区av| 国产午夜精品一区二区| 在线视频欧美精品| 国产综合色在线|