VB/C++/C#串口通讯源代码【附详细注释】
VB
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
MSComm1.CommPort = i1
MSComm1.PortOpen = True
MSComm1.InputMode = comInputModeBinary
MSComm1.InBufferCount = 0
MSComm1.InputLen = 0
MSComm1.Settings = "9600,N,8,1"
MSComm1.RThreshold = 1
MSComm1.OutBufferCount = 0
C++
/****************************************************************/
//串行口初始化
if(m_ctrlComm.GetPortOpen()) //如果串口已经打开,则关闭。
m_ctrlComm.SetPortOpen(FALSE);
m_ctrlComm.SetCommPort(1); //选择com1
if( !m_ctrlComm.GetPortOpen()) 字串9
m_ctrlComm.SetPortOpen(TRUE); //打开串口
else
AfxMessageBox("不能打开串行口!");
m_ctrlComm.SetSettings("9600,n,8,1"); //波特率9600,无校验,8个数据位,1个停止位
m_ctrlComm.SetInputMode(1); //1:表示以二进制方式检取数据
m_ctrlComm.SetRThreshold(1); //参数1表示每当串口接收缓冲区中有多于或等于1个字符时将引发一个接收数据的OnComm事件
m_ctrlComm.SetInputLen(0); //设置当前接收区数据长度为0
m_ctrlComm.GetInput(); //先预读缓冲区以清除残留数据
/****************************************************************/
C#
if (this.axMSComm1.PortOpen == true)
this.axMSComm1.PortOpen = false;
this.axMSComm1.CommPort = 1;//端口 字串2
this.axMSComm1.Settings = "9600,n,8,1";//通信参数
&
相关文档:
C#使用SQLite数据库(asp.net/winform)
2009年1月7日
评论
发表评论
SQLite
是目前比较流行的一个开源、免费的小型的Embeddable RDBMS(关系型数据库),用C实现,内存占用较小,支持绝大数的SQL92标准,个别不支持的情况,在这里
说明
对各种语言的支持也比较不错,wrapper很多� ......
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
#include<linux/config.h>
#include<linux/module.h>
#include<linux/version.h>
#include<linux/init.h>
#include<linux/kernel.h>
#include<linux/errno.h>
#include<linux/sche ......
----------------------------------------------------------------------------------------------------------------------------------------
/**/
/*
********************************************************************************************************
* @Description:s3c2410的rtc驱动的实 ......
TIOBE世界编程语言排行榜展现了编程语言的流行趋势。每个月,都有最新的数据被更新。这份排行榜的数据取样来源于互联网上富有经验的程序员、商 业应用、著名的搜索引擎(诸如谷歌、 MSN 、雅虎)的关键字排名、 Alexa 上的排名等。请注意这个排行榜只是反映了某个编程语言的热门程度 , 这并不代表它是一个最好的编程语言或� ......
下面是commond:
MySQLCommand cmd;
cmd = new MySQLDriverCS.MySQLCommand("DROP TABLE IF EXISTS test.mysqldrivercs_test",conn);
cmd.ExecuteNonQuery();
cmd.Dispose();
下面是insert:
string Value = "Value";
int SettingID = 1;
new MySQLInsertCommand(conn,
new object[,] {{"SettingID",SettingID},{"S ......