哪为兄弟会DELPHI,帮忙给该写个串口程序!!写成DLL
//---------------------------------------------------------------------------------------////函数功能:继电器控制
//参数说明:
// comport ——串口号 ;
// cardID ——板卡号;
// chanelNum ——欲控制的继电器的个数;
// ctrldata ——继电器状态设定。直接写入继电器号1-16,表示继电器选择常开触点;
// 继电器号加16即17-32,表示继电器选择常闭触点;
//使用指导:
// eg.要打开第1个继电器,关闭第2个继电器;串口为1;板卡号1;
// ......
// comport=1;
// cardID=1;
// chanelNum=2;
// strcpy(ctrldata,"\1\x12");
// Relay(comport,cardID,chanelNum,ctrldata);
//版本:V1.0
//日期:2005年12月27日
//-------------------------------------------------------------------
void Relay(int comport,int cardID,int chanelNum,char ctrldata)
{
static int num;
short int i=0;
unsigned char senddata,senddata1,senddata2,senddata3;
//标示字
senddata=0xaa;
senddata=0x55;
//板卡号
senddata=cardID+32;
OpenComConfig (comport, "",9600,3, 8, 2, 1000, 1000);
FlushOutQ(comport);
ComWrt(comport,senddata,3);
while(1)
{
num=GetOutQLen(comport);
if(num==0)
break;
}
CloseCom(comport);
//通道个数
senddata1=chanelNum;
//控制继电器状态
strcpy(senddata1+1,ctrldata);
senddata1=cardID+chanelNum+32;
OpenComConfig (comport, "",9600,4, 8, 2, 1000, 1000);
FlushOutQ(comport);
ComWrt(comport,senddata1,chanelNum+2);
while(1)
{
num=GetOutQLen(comport);
if(num==0)
break;
}
CloseCom(comport);
} <P>写串口程序很简单,写在DLL比较麻烦!</P>
不懂DEPHI,兄弟为什么不直接用LV或CVI直接做一个呢?这样也可以的! <P>我也想呀,可是大系统是用DELPHI做的,没办法呀。用cvi那容易多了。~~~~~~~</P>
<DIV>既然是做成DLL,DELPHI能不能调用C语言作的Win32Dll</DIV>
<DIV>用CVI可以做标准win32DLL的</DIV>
<DIV>大系统应该用VC做啊</DIV>
<DIV>你说的大系统是几百万以上的?</DIV> <P><STRONG><FONT face=Verdana color=#da2549>game216</FONT></STRONG></P>
<P><STRONG><FONT face=Verdana color=#da2549>用VC做的DLL好像可以,能给个范例吗?我的程序在论坛里有帖,你看看。</FONT></STRONG></P>
<P><STRONG><FONT face=Verdana color=#da2549>你说的CVI的WIN32DLL是不是CVI自己的动态连接库吗?</FONT></STRONG></P>
<P><STRONG><FONT face=Verdana color=#da2549>如果是WIN API的话DELPHI支持的。</FONT></STRONG></P>
<P><STRONG><FONT face=Verdana color=#da2549>个位版主帮帮忙,小弟在此谢过了!</FONT></STRONG></P>
页:
[1]