setlength(sbuf,10);
sbuf[0] := $0C;
sbuf[1] := ad1;
sbuf[2] := ad2;
sbuf[3] := $83;
sbuf[4] := hextoint(copy(DelayTime, 1, 2));
sbuf[5] := HexToInt(Copy(DelayTime, 3, 2));
sbuf[6] := HexToInt(NO);
if CtrolType = 1 then sbuf[7] := $81;
if CtrolType = 2 then sbuf[7] := $82;
if CtrolType = 4 then sbuf[7] := $84;
sbuf[8] := check(0, 7);
sbuf[9] := $0E;
OutputByte(sbuf); //----内容和tcomm组件的OutputByte的一样;;
sleep(150);
if ReadInDataCount > 0 then//---内容和tcomm组件的ReadInDataCount 的一样;;
begin
sleep(20);
count := ReadInputByte(pt);//---内容和tcomm组件的ReadInputByte的一样;;
setlength(rbuf, Count + 1);
for t := 0 to count do
begin rbuf[t] := pt^;
inc(pt);
end;
if count > 0 then
begin //<<-0C 00 01 83 00 82 48 0E
if valid(1, count - 2) = 1 then //判判断是否为HEX;
begin
if (rbuf[0] = $0C) and (rbuf[3] = $83) and (rbuf[5] = sbuf[7]) and (rbuf[count] = $0E)
then begin
result := 0;
ClearComm;
exit;
end;
end;
end;
end;
ClearComm;---子定义过程;清除com口的数据;//PurgeComm(tc, PURGE_RXCLEAR)
result := -1;
end;
//程序第一次执行时正常.在程序不关闭的前提下重新调用此代码;追踪发现
ReadInDataCount
count := ReadInputByte(pt).
的值和上次执行到此语句时的值一样;;;;;
好像是没有清除com口的数据;;;;
而我自定义的过程:
procedure ClearComm;
begin
PurgeComm(tc, PURGE_RXCLEAR);
end;
是专门有做清除com口的;(摘自tcomm);
请教:上述问题如何解决??????
注:没有用到tcomm控件;;;;
sbuf[0] := $0C;
sbuf[1] := ad1;
sbuf[2] := ad2;
sbuf[3] := $83;
sbuf[4] := hextoint(copy(DelayTime, 1, 2));
sbuf[5] := HexToInt(Copy(DelayTime, 3, 2));
sbuf[6] := HexToInt(NO);
if CtrolType = 1 then sbuf[7] := $81;
if CtrolType = 2 then sbuf[7] := $82;
if CtrolType = 4 then sbuf[7] := $84;
sbuf[8] := check(0, 7);
sbuf[9] := $0E;
OutputByte(sbuf); //----内容和tcomm组件的OutputByte的一样;;
sleep(150);
if ReadInDataCount > 0 then//---内容和tcomm组件的ReadInDataCount 的一样;;
begin
sleep(20);
count := ReadInputByte(pt);//---内容和tcomm组件的ReadInputByte的一样;;
setlength(rbuf, Count + 1);
for t := 0 to count do
begin rbuf[t] := pt^;
inc(pt);
end;
if count > 0 then
begin //<<-0C 00 01 83 00 82 48 0E
if valid(1, count - 2) = 1 then //判判断是否为HEX;
begin
if (rbuf[0] = $0C) and (rbuf[3] = $83) and (rbuf[5] = sbuf[7]) and (rbuf[count] = $0E)
then begin
result := 0;
ClearComm;
exit;
end;
end;
end;
end;
ClearComm;---子定义过程;清除com口的数据;//PurgeComm(tc, PURGE_RXCLEAR)
result := -1;
end;
//程序第一次执行时正常.在程序不关闭的前提下重新调用此代码;追踪发现
ReadInDataCount
count := ReadInputByte(pt).
的值和上次执行到此语句时的值一样;;;;;
好像是没有清除com口的数据;;;;
而我自定义的过程:
procedure ClearComm;
begin
PurgeComm(tc, PURGE_RXCLEAR);
end;
是专门有做清除com口的;(摘自tcomm);
请教:上述问题如何解决??????
注:没有用到tcomm控件;;;;
解决方案 »
- Delphi 终于重放异彩!庆祝Delphi 2006面世!
- delphi网络编程需要什么知识?
- 为什么数据库连接失败啊!!!!
- 谁知道delphi里的socket控件对应的ocx文件是哪一个?在哪个目录?
- 我现在想用条形码管理商品,但如何生成条形码?欢迎大家讨论!!!
- FastReport的问题
- 高手请进,重分相酬
- d7vcl.hlp 有没有中文版,那里有下载?我baidu.google 搜了好长时间, 都没有,小弟E文不好,谢谢。
- 怎么样锁键盘?
- 已经取得某子窗口的句柄,如何访问该字窗口的信息?
- 学DELPHI很久了,只因英文很烂,真的学不下去了......
- 我要疯了,可恶的10061错误!!翻遍百度、Goolge无人回答的问题!!
说实在的没用过。mscomm32用起来的庭好的。有空再看看spcomm,老是看到ly推荐