tag 标签: 串口编程

相关博文
  • 热度 20
    2013-5-9 17:23
    1339 次阅读|
    0 个评论
    在进行串口通信时,经常需要用到下列一些API函数: CreateFile():用于打开一个文件访问串口; GetCommState():获取串口的当前配置,放入DCB中; SetCommState():根据DCB信息配置串口参数; SetCommTimeouts():设置串口读写操作的超时时间; ReadFile():从串口的输入缓冲区读取数据; WriteFile():向串口的输出缓冲区写入数据; SetCommMask():监视指定通信资源上的事件; WaitCommEvent():等待通信事件发生; CloseHandle():关闭由CreateFile函数打开的串口。
  • 热度 17
    2013-5-9 16:55
    1978 次阅读|
    0 个评论
    COMSTAT结构 COMSTAT结构包含串口的信息,结构定义如下: typedef struct _COMSTAT { // cst     DWORD fCtsHold : 1;   // Tx waiting for CTS signal     DWORD fDsrHold : 1;   // Tx waiting for DSR signal DWORD fRlsdHold : 1; // Tx waiting for RLSD signal     DWORD fXoffHold : 1;  // Tx waiting, XOFF char rec''d     DWORD fXoffSent : 1;  // Tx waiting, XOFF char sent     DWORD fEof : 1;       // EOF character sent     DWORD fTxim : 1;      // character waiting for Tx     DWORD fReserved : 25; // reserved     DWORD cbInQue;        // bytes in input buffer   输入缓冲区中的字节数 (这部分的缓冲区是在函数 setupcom 设定的缓冲区大小,属于软件buffer)     DWORD cbOutQue;       // bytes in output buffer   输出缓冲区中的字节数(这部分的缓冲区是在函数 setupcom 设定的缓冲区大小,属于软件buffer)   } COMSTAT, *LPCOMSTAT;  
  • 热度 24
    2012-10-18 14:31
    2298 次阅读|
    1 个评论
    3、VTIME 和  VMIN VTIME  定义要求等待的零到几百毫秒的值(通常是一个8位的unsigned char变量)。 VMIN 定义了要求等待的最小字节数, 这个字节数可能是0。 只有设置为阻塞时这两个参数才有效,仅针对于读操作。 说起来比较复杂,举个例子吧,设置为阻塞状态,写操作未进行实验,这里仅讨论读操作, read(fd,buf,8); // 读串口 3.1 options.c_cc = 0; options.c_cc = 0; VMIN = 0,当缓冲区字节数 = 0 时进行读操作,实际上这时读串口操作并未被阻塞,因为条件始终被满足。 3.2 options.c_cc = 0; options.c_cc = 1; VMIN = 1,当缓冲区字节数 = 1 时进行读操作,当没有数据时读串口操作被阻塞。 3.3 options.c_cc = 0; options.c_cc = 4; VMIN = 4,当缓冲区字节数 = 4 时进行读操作,否则读串口操作被阻塞。每次读出的最大字节数由read函数中第三个参数决定。直到缓冲区剩下的数据 read 第三个参数 并且 4 (如果这时read第三参数为 1 则进行4次读操作直至读完缓冲区,如read第三参数为2,连续进行读操作,直至缓冲区空或还剩一个字符)。没有设置VTIME,剩下的字符没有确定的期限,直到下次满足读条件的时候才被读出。 ----------------------------------考虑VTIME----------------------------- 3.4 options.c_cc = 10; //单位百毫秒 options.c_cc = 4; 同3.3的区别就是,没满足条件或读缓冲区中剩下的数据会在1秒(10百毫秒)后读出。另外特别注意的是当设置VTIME后,如果read第三个参数小于VMIN ,将会将VMIN 修改为read的第三个参数,即使用read(fd,buf,2);,以上设置变为: options.c_cc = 10; options.c_cc = 2;
相关资源
  • 所需E币: 0
    时间: 2020-5-25 15:05
    大小: 10.81KB
    上传者: Argent
    VB是早期比较流程的编程语言,VisualBasic由微软公司开发,是世界上使用人数最多的语言。它源自于BASIC编程语言。VB拥有图形用户界面(GUI)和快速应用程序开发(RAD)系统,可以轻易的使用DAO、RDO、ADO连接数据库,或者轻松的创建ActiveX控件。程序员可以轻松的使用VB提供的组件快速建立一个应用程序。感兴趣的网友们快来下载,练练手吧。
  • 所需E币: 1
    时间: 2020-5-25 15:05
    大小: 572.79KB
    上传者: Argent
    VB是早期比较流程的编程语言,VisualBasic由微软公司开发,是世界上使用人数最多的语言。它源自于BASIC编程语言。VB拥有图形用户界面(GUI)和快速应用程序开发(RAD)系统,可以轻易的使用DAO、RDO、ADO连接数据库,或者轻松的创建ActiveX控件。程序员可以轻松的使用VB提供的组件快速建立一个应用程序。感兴趣的网友们快来下载,练练手吧。
  • 所需E币: 1
    时间: 2020-5-25 15:05
    大小: 26.61KB
    上传者: Argent
    VB是早期比较流程的编程语言,VisualBasic由微软公司开发,是世界上使用人数最多的语言。它源自于BASIC编程语言。VB拥有图形用户界面(GUI)和快速应用程序开发(RAD)系统,可以轻易的使用DAO、RDO、ADO连接数据库,或者轻松的创建ActiveX控件。程序员可以轻松的使用VB提供的组件快速建立一个应用程序。感兴趣的网友们快来下载,练练手吧。
  • 所需E币: 0
    时间: 2020-5-25 15:00
    大小: 9.5KB
    上传者: Argent
    VB是早期比较流程的编程语言,VisualBasic由微软公司开发,是世界上使用人数最多的语言。它源自于BASIC编程语言。VB拥有图形用户界面(GUI)和快速应用程序开发(RAD)系统,可以轻易的使用DAO、RDO、ADO连接数据库,或者轻松的创建ActiveX控件。程序员可以轻松的使用VB提供的组件快速建立一个应用程序。感兴趣的网友们快来下载,练练手吧。
  • 所需E币: 1
    时间: 2020-5-25 15:26
    大小: 20.11KB
    上传者: Argent
    VB是早期比较流程的编程语言,VisualBasic由微软公司开发,是世界上使用人数最多的语言。它源自于BASIC编程语言。VB拥有图形用户界面(GUI)和快速应用程序开发(RAD)系统,可以轻易的使用DAO、RDO、ADO连接数据库,或者轻松的创建ActiveX控件。程序员可以轻松的使用VB提供的组件快速建立一个应用程序。感兴趣的网友们快来下载,练练手吧。
  • 所需E币: 5
    时间: 2019-12-26 01:14
    大小: 8.46MB
    上传者: givh79_163.com
    经典的串口编程教材……
  • 所需E币: 3
    时间: 2019-12-24 19:27
    大小: 49.69KB
    上传者: 2iot
    参考EEPWARMDIY手记之软件设计(三)——hellotheworld写的代码。……
  • 所需E币: 4
    时间: 2019-12-22 04:20
    大小: 1.07MB
    上传者: 二不过三
    详细说明:本人自己编写API串口通信程序与编写过程中参考的学习资料,有一定的参考价值,对于初次编程的爱好者来说比较合适。……
  • 所需E币: 5
    时间: 2019-12-22 04:20
    大小: 68.63KB
    上传者: givh79_163.com
    摘要:本文详细介绍了串行通信的基本原理,以及在Windows环境下基于ActiveX控件用MFC实现串口通信的方法。[著者文摘]……
  • 所需E币: 5
    时间: 2019-12-22 04:20
    大小: 127.31KB
    上传者: rdg1993
    摘要:绝缘子在线监测需要采集的数据有泄漏电流和空气湿度等,对采集到的数据进行VC的串口通讯,然后与ODBC数据库编程技术相结合,将串口数据实时保存在数据源文件中,实现数据实时采集和随时回放的功能。……
  • 所需E币: 5
    时间: 2019-12-22 04:20
    大小: 30.56MB
    上传者: 238112554_qq
    SIM900AGPRSV10526....................\GPRS....................\....\log.txt....................\....\logtcp.txt....................\....\sockettoolv25.exe....................\....\TCP-UDP服务管理V3.01.exe....................\串口调试助手V2.2.exe....................\代码....................\....\MCU....................\....\...\51-STC-avr程序说明.pdf....................\....\...\51-STC-TC35发送接收程序例程(开机就发送)....................\....\...\51-STC-TC35发送接收程序例程(开机就发送).rar....................\....\...\.......................................\51-STC-TC35发送接收程序例程(开机就发送)....................\....\...\.......................................\.......................................\Debug....................\....\...\.......................................\.......................................\.....\vc60.idb....................\....\...\.......................................\.......................................\.....\vc60.pdb....................\....\...\.......................................\.......................................\HEAD_IO.H....................\....\...\.......................................\.......................................\STARTUP.A51....................\....\...\.......................................\.......................................\STARTUP.LST....................\....\...\.......................................\.......................................\STARTUP.OBJ....................\....\...\.......................................\.......................................\TC35MOK.C....................\....\...\.......................................\.......................................\TC35MOK.LST....................\....\...\.......................................\.......................................\TC35MOK.OBJ....................\....\...\.......................................\.......................................\TC35模块....................\....\...\.......................................\.......................................\TC35模块-51-STC51.opt.bak....................\....\...\.......................................\.......................................\TC35模块-51-STC51.Uv2.bak....................\....\...\.......................................\.......................................\TC35模块-51-STC51.uvopt....................\....\...\.......................................\.......................................\TC35模块-51-STC51.uvproj....................\....\...\.......................................\.......................................\TC35模块-51-STC51_Opt.Bak....................\....\...\.......................................\.......................................\TC35模块-51-STC51_Uv2.Bak....................\....\...\.......................................\.......................................\TC35模块-51-STC51_uvopt.bak....................\....\...\.......................................\.......................................\TC35模块.c....................\....\...\.......................................\.......................................\TC35模块.hex....................\....\...\.......................................\.......................................\TC35模块.lnp....................\....\...\.......................................\.......................................\TC35模块.LST....................\....\...\.......................................\.......................................\TC35模块.M51....................\....\...\.......................................\.......................................\TC35模块.OBJ....................\....\...\.......................................\.......................................\TC35模块.Opt....................\....\...\.......................................\.......................................\TC35模块.plg....................\....\...\.......................................\.......................................\TC35模块_Opt.Bak....................\....\...\.......................................\.......................................\TC35模块_Uv2.Bak....................\....\...\.......................................\.......................................\TC35模块辅助.c....................\....\...\.......................................\.......................................\TC35模块辅助.dsp....................\....\...\.......................................\.......................................\TC35模块辅助.dsw....................\....\...\.......................................\.......................................\TC35模块辅助.LST....................\....\...\.......................................\.......................................\TC35模块辅助.ncb....................\....\...\.......................................\.......................................\TC35模块辅助.OBJ....................\....\...\.......................................\.......................................\TC35模块辅助.opt....................\....\...\.......................................\.......................................\TC35模块辅助.plg....................\....\...\51-STC-TC35发送接收程序例程.rar....................\....\...\GPRS_SIM300_1213.rar....................\....\...\GSMGPRS.rar....................\....\...\KUNS_ZH_GSM_2(LED显示只是发送)2.rar....................\....\...\KUNS_ZH_GSM_2(LED显示只是接收).rar....................\....\PC端....................\....\....\综合测试软件代码....................\....\....\综合测试软件代码.rar....................\....\....\................\TC上位机软件....................\....\....\................\............\.oca....................\....\....\................\............\asycfilt.dll....................\....\....\................\............\CMDLGCHS.DLL....................\....\....\................\............\COMCAT.DLL....................\....\....\................\............\comdlg32.ocx....................\....\....\................\............\GPRS.bas....................\....\....\................\............\KUN_CON_TC35.CAB....................\....\....\................\............\KUN_CON_TC35.exe....................\....\....\................\............\KUN_CON_TC35.frm....................\....\....\................\............\KUN_CON_TC35.frx....................\....\....\................\............\KUN_CON_TC35.log....................\....\....\................\............\KUN_CON_TC35.PDM....................\....\....\................\............\KUN_CON_TC35.vbp....................\....\....\................\............\KUN_CON_TC35.vbw....................\....\....\................\............\MSCOMCHS.DLL....................\....\....\................\............\MSCOMM32.OCX....................\....\....\................\............\MSSCCPRJ.SCC....................\....\....\................\............\msvbvm60.dll....................\....\....\................\............\oleaut32.dll....................\....\....\................\............\olepro32.dll....................\....\....\................\............\PDU专用.bas....................\....\....\................\............\setup.exe....................\....\....\................\............\SETUP.LST....................\....\....\................\............\SETUP1.EXE....................\....\....\................\............\ST6UNST.EXE....................\....\....\................\............\stdole2.tlb....................\....\....\................\............\Support....................\....\....\................\............\.......\asycfilt.dll....................\....\....\................\............\.......\CMDLGCHS.DLL....................\....\....\................\............\.......\COMCAT.DLL....................\....\....\................\............\.......\comdlg32.ocx....................\....\....\................\............\.......\KUN.DDF....................\....\....\................\............\.......\KUN_CON_TC35.BAT....................\....\....\................\............\.......\MSCOMCHS.DLL....................\....\....\................\............\.......\MSCOMM32.OCX....................\....\....\................\............\.......\msvbvm60.dll....................\....\....\................\............\.......\oleaut32.dll....................\....\....\................\............\.......\olepro32.dll....................\....\....\................\............\.......\SETUP.EXE....................\....\....\................\............\.......\Setup.Lst....................\....\....\................\............\.......\SETUP1.EXE....................\....\....\................\............\.......\ST6UNST.EXE……
  • 所需E币: 4
    时间: 2019-12-22 04:21
    大小: 4.62MB
    上传者: rdg1993
    ANT_final\.tkenvrc.........\ARPATopo.ned.........\ASONSimulationPlatform.bsc.........\ASONSimulationPlatform.dsp.........\ASONSimulationPlatform.dsw.........\ASONSimulationPlatform.exe.........\ASONSimulationPlatform.exp.........\ASONSimulationPlatform.ilk.........\ASONSimulationPlatform.lib.........\ASONSimulationPlatform.ncb.........\ASONSimulationPlatform.opt.........\ASONSimulationPlatform.pdb.........\ASONSimulationPlatform.plg.........\cmdenv.ini.........\data.txt.........\data0.005-1,100.txt.........\data0.005-1,150.txt.........\data0.005-1,50.txt.........\data0.01.txt.........\data5ms,0.002-0.2,150.txt.........\data5ms,0.002-0.2,50.txt.........\data5ms,0.01-1,100.txt.........\data5ms,0.01-1,50.txt.........\data5ms0.01-1,150.txt.........\data5ms,0.002-0.2,100.txt.........\datainterval.txt.........\datainterval0.001-0.2,100.txt.........\data时延100.txt.........\data时延50.txt.........\Debug\ASONSimulationPlatform.pch.........\.....\Node.obj.........\.....\Node.sbr.........\.....\Server.obj.........\.....\Signal_m.obj.........\.....\Signal_m.sbr.........\.....\vc60.idb.........\.....\vc60.pdb.........\interval0.01.txt.........\Node.cpp.........\Node.h.........\NSFNet.ned.........\NSFNet.ned.bak.........\omnetpp.ini.........\resource.h.........\run.pl.........\run.pl.bak.........\Script1.aps.........\Script1.rc.........\Signal.msg.........\Signal.msg.bak.........\Signal_m.cpp.........\Signal_m.h.........\t.txt.........\topo.h.........\程序进展.doc.........\进程日记.doc.........\阻塞率比较.xlsx.........\Debug……
  • 所需E币: 4
    时间: 2019-12-22 04:21
    大小: 8.27MB
    上传者: givh79_163.com
    simu_sd_slice-链路\Debug\simulation.exe..................\.....\simulation.ilk..................\.....\simulation.pdb..................\ipch\simulation-a497b9a9\simulation-d8479671.ipch..................\random.suo..................\simulation\data.txt..................\..........\Database.cpp..................\..........\Database.h..................\..........\.ebug\BuildLog.htm..................\..........\.....\CL.read.1.tlog..................\..........\.....\CL.write.1.tlog..................\..........\.....\Database.obj..................\..........\.....\Event.obj..................\..........\.....\link.read.1.tlog..................\..........\.....\link.write.1.tlog..................\..........\.....\MainFrame.obj..................\..........\.....\Measure.obj..................\..........\.....\mt.dep..................\..........\.....\mt.read.1.tlog..................\..........\.....\mt.write.1.tlog..................\..........\.....\simulation.exe.intermediate.manifest..................\..........\.....\simulation.lastbuildstate..................\..........\.....\simulation.log..................\..........\.....\Simulation.obj..................\..........\.....\vc100.idb..................\..........\.....\vc100.pdb..................\..........\.....\vc90.idb..................\..........\.....\vc90.pdb..................\..........\Event.cpp..................\..........\Event.h..................\..........\MainFrame.cpp..................\..........\map.data..................\..........\Measure.cpp..................\..........\Measure.h..................\..........\Simulation.cpp..................\..........\Simulation.h..................\..........\simulation.vcproj..................\..........\simulation.vcproj.BrYn-PC.BrYn.user..................\..........\simulation.vcproj.BUPT-8F8721B7FD.Administrator.user..................\..........\simulation.vcproj.lch-PC.lch.user..................\..........\simulation.vcproj.LCH.Administrator.user..................\..........\simulation.vcxproj..................\..........\simulation.vcxproj.filters..................\..........\simulation.vcxproj.user..................\simulation.ncb..................\simulation.sdf..................\simulation.sln..................\simulation.sln.old..................\simulation.suo..................\simulation.suo.old..................\UpgradeLog.XML..................\_UpgradeReport_Files\UpgradeReport.css..................\....................\UpgradeReport.xslt..................\....................\UpgradeReport_Minus.gif..................\....................\UpgradeReport_Plus.gif..................\ipch\simulation-a497b9a9..................\simulation\Debug..................\Debug..................\ipch..................\simulation..................\_UpgradeReport_Files……