文章分类 | 推荐文章 | 最新文章 | 热点文章 | 最新软件 | 精品软件 | 下载排行 | 推荐下载 | 免费看大片 | WPS | 杀毒软件
清风网络
首 页 软件下载 网络学院 数码学院
QQ 电脑入门 游戏 操作系统 图形处理 办公软件 媒体动画 精文荟萃 工具软件 网络编程 程序开发 网络技术 认证考试 网站建设 文章专栏
当前位置:清风网络学院程序开发C++Builder用Builder C++设计串行口COM1或COM2的读写操作
精品推荐
特别推荐
·菜鸟入门 认识C#中的委托和事件
·WINDOWS下的动态鼠标光标控制
热点TOP10
·C++ Builder下数据库报表Master/Detail关系功能的实现
·用Builder C++设计串行口COM1或COM2的读写操作
·无废话C#设计模式之四:Factory Method
·菜鸟入门 认识C#中的委托和事件
·C#动态生成树型结构的Web程序设计
·QuickReport基本知识
·获得文件的版本信息
·C++Builder IDE使用技巧与快捷键
·C++Builder注册表编程实例详解
·在bcb里实现像Winamp那样具有吸附效果的磁性窗口

用Builder C++设计串行口COM1或COM2的读写操作

日期:2008年2月11日 作者: 查看:[大字体 中字体 小字体]


// actually bytes in the buffer to read.
//
// If you are reading more than one byte at a time from
he buffer

// (which this program does not do) you will have the si
uation occ
ur
// where the first byte to arrive will cause the WaitFor
ultipleObj
ects()
// function to stop waiting. The WaitForMultipleObjects
) function

// resets the event handle in m_OverlappedStruct.hEvent
o the non-
signelead state
// as it returns.
//
// If in the time between the reset of this event and th
call to
// ReadFile() more bytes arrive, the m_OverlappedStruct.
Event hand
le will be set again
// to the signeled state. When the call to ReadFile() oc
urs, it wi
ll
// read all of the bytes from the buffer, and the progra
will
// loop back around to WaitCommEvent().
//
// At this point you will be in the situation where m_Ov
rlappedStr
uct.hEvent is set,
// but there are no bytes available to read. If you pro
eed and ca
ll
// ReadFile(), it will return immediatly due to the asyn
port setu
p, but
// GetOverlappedResults() will not return until the next
character
arrives.
//
// It is not desirable for the GetOverlappedResults() fu
ction to b
e in
// this state. The thread shutdown event (event 0) and
he WriteFi
le()
// event (Event2) will not work if the thread is blocked
by GetOver
lappedResults().
//
// The solution to this is to check the buffer with a ca
l to Clear
CommError().
// This call will reset the event handle, and if there a
e no bytes
to read
// we can loop back through WaitCommEvent() again, then
roceed.
// If there are really bytes to read, do nothing and pro
eed.

bResult = ClearCommError(port->m_hComm, &dwError, &comst
t);

if (comstat.cbInQue == 0)
continue;
} // end if bResult

// Main wait function. This function will normally block the th
ead


// until one of nine events occur that require action.
Event = WaitForMultipleObjects(3, port->m_hEventArray, false, IN
INI
TE);

switch (Event)
{
case 0:
{
// Shutdown event. This is event zero so it wil
be
// the higest priority and be serviced first.

port->m_bThreadAlive = false;

// Kill this thread. break is not needed, but m
kes me feel bette

上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] 下一页 




上一篇:用C++Builder建立多线程COM服务器

下一篇:在BCB中使用DirectX

相关文章:
·如何建立一个网站?规划、设计、目的、原则、宣传
·综合实例:PS洗衣粉包装设计印刷全攻略
·3DsMAX教程 设计叶片上的精致三维蜻蜓
·几何图形英文字体创意设计及应用作品欣赏
·英文字体创意设计及应用作品欣赏
·3DMAX设计制作两只花瓣上的美丽蝴蝶
·如何使设计作品获得最佳菲林输出?
·在线设计:轻松获取个性篆刻印章
·美工LOGO设计进阶
·用 CorelDRAW 设计制作商务名片
相关软件:
·C语言程序设计
·Dreamweaver 网页设计
·powerbuilder10.0中文版
·美工设计教程
·Photoshop CS经典创意设计200例
·Photoshop CS中文版平面设计师标准案例教程
·Windows环境下32位汇编语言程序设计
·颐家IDO在线互动设计软件
·Photoshop 7.0 平面 广告 装帧设计100例
·超级DIY设计器V7.0 build 2143 特别版

特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
[打印本页] [关闭窗口] 转载请注明来源:http://www.vipcn.net
| 帮助(?) | 版权声明 | 友情连接 | 关于我们 | 信息发布
Copyright 2007 www.vipcn.net All Rights Reserved. 鄂ICP备05000083号Powered by:viphot