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

📄 queue.cpp

📁 DOS下采用中断接收数据的串口通讯的例子,很难找到的好东西!
💻 CPP
字号:
//
//  QUEUE.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.
//
// Most of the queue class functions are defined in QUEUE.H as
// inline for speed.  This routine probably won't generate
// inline code with most compilers, and it is not used in the
// ISR, so speed is not as critical.  Thus, it gets defined
// normally.

#include "queue.h"

int Queue::Peek( unsigned char *buf, int count )
{
    unsigned int index = tail_index;
    int total = 0;

    while ( total < count && index != head_index ) {
         *buf++ = buffer[ index++ ];
         if ( index >= QueueSize )
             index = 0;
         total++;
    }
    return total;
}
// ******************** END OF QUEUE.CPP *******************

⌨️ 快捷键说明

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