资源描述:
《基于vc的串口通信与图形绘制实现》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、基于VC的串口通信与图形绘制实现摘要介绍了采用VisualC++6.0中的MSComm控件来实现串口通信的基本原理,如何利用Win32的底层API函数开发串口通信类CserialPort,与MicrosoftCommuinicationsControl控件相比,采用该串口通信类对串口设备操作时,能够在一定程度上避免对串口设备的“屏蔽”。增加对串口操作的透明度,提高串口传输数据的可靠性。针对VisualC++6.0具有功能强大,通信快速,实时性好等特点,介绍基于VisualC++的一种串口通信原理及其实现方法,并针对控制系统众多界面下串口通信的多
2、线程等特点,结合实例阐述通信模块化等一些技巧。应用电脑对外界数据进行直观的图形绘制。Windows环境下地串口编程与DOS环境下的串口编程有很大的不同。Windows环境下的最大特点之一就是设备无关性,它通过设备驱动程序将Windows应用程序同不同的外部设备隔离。Windows封装了Windows的通信机制,这种方式称为通信API,Windows程序员可以利用Windows通信API进行编程,不用对硬件直接进行操作。这种体系被称为Windows开放式服务体系。Windows9x/NT/2000中的API一般都支持32位的操作,因此又称为Win
3、32API。Windows操作系统是一个可抢占式的操作系统,所以Windows应用程序常常有被别的程序抢占时间片的可能,因此Win32通信业不能用于实时通信。实时通信的质量与时间紧密相关。因此,不需要许多协议层的交换式、非实时的通信可以采用Win32通信API来实现。Win32通信API把串口操作和文件操作统一起来,使用类似的操作来实现通信。关键词:VC++,嵌入式系统,,MSComm,,WindowsAPI,串口通信,模块化,图形,绘制.ABSTRACTThispaperintroducestheVisualC++6.0ofMSCommcon
4、troltoachievethebasicprinciplesofserialcommunication,howtousetheunderlyingWin32serialcommunicationAPIfunctiontodeveloptypeCserialPort,andMicrosoftCommuinicationsControlcontrolcomparedtousingtheserialcommunicationtypeofSerialequipmentoperation,toacertainextent,theserialdevice
5、toavoidthe"shield"Increasethetransparencyoftheoperationofserialport,serialporttoimprovethereliabilityofdatatransmission.ForVisualC++6.0withpowerfulrapidcommunications,real-timecharacteristicsofagoodtointroducetheVisualC++basedonaprincipleofserialcommunicationanditsimplementa
6、tion,andcontrolsystemforthemanyserialcommunicationinterface,suchasmulti-threadingcharacteristics,withexamplessuchasthemodularcommunicationskillsApplicationofcomputertotheoutsideworldintuitivegraphicaldatamapping.WindowsenvironmentShimojiserialprogrammingandserialDOSprogrammi
7、ngenvironmentareverydifferentfrom.Windowsenvironmentisoneofthegreatestcharacteristicsofdevice-independent,itwillbethroughthedevicedriverwithWindowsapplicationisolationofdifferentexternaldevices.WindowspackageoftheWindowscommunicationmechanism,whichiscalledcommunicationAPI,Wi
8、ndowsprogrammerscanusetoprogramWindowsCommunicationAPI,donotoperatedirectly