请问串口通信中,有没有因为某种故障导致单片机不应答,这时它还触发onreceive事件吗?因为我把查询失败的处理办法写在onreceive事件里了,如果这时它不触发onreceive事件,那么我的程序就不能继续轮询下去,就是不能继续自动查询下面的其他站点
解决方案 »
- 问2个文本文件的问题
- 太喜欢delphpi了.可惜一直没时间学
- 2007第一个月过去了,我的共享路继续惨淡凄凉中,大家有什么创意吗?
- 獲取網管或路由器的mac值?
- 帮我改sql语句,谢谢
- 菜鸟请教DBGrid的问题.
- 是否有将extended转换成int的函数
- 请问有没有一本电子书是专门介绍异常的?谢谢
- 怎样使用TeamSource或者提供一些相关资料和网站,谢谢!
- Tcheck.create(Aowner) 的位置怎么放,Aowner怎么用? 如果放在Tscrollbox中怎么设?
- 有人能告诉我,我的空间中好友资料去哪了?
- 收集资料,Delphi在D7以后的版本,在各方面有哪些新技术和改进?
var
i:Integer;
begin
FreeOnTerminate:=True; while not Terminated do
begin
WaitForSingleObject(AcqFluxEvent,INFINITE); for i := 0 to CommRW_Repeat-1 do
begin
try
if FFluxControl.AcquiteFluxData then
begin
PostMessage(FHandle,WM_UPDATE_FLUX,FLAG_WM_FLUX,0);
Break;
end; except
on E:ECommException do
begin
FFluxControl.StartWork;
Sleep(DefaultCmdIntervalII);
if i = CommRW_Repeat-1 then
PostMessage(FHandle,WM_ERROR_COMM,FLAG_WM_FLUX,E.Code);
end;
end;
end;
Sleep(CommFluxReal_Delay);
end;
end;CommRW_Repeat //重发次数
FFluxControl.AcquiteFluxData //这个函数包含了送命令和读串口返回数据的处理
其伪代码:
发命令;
延时;
读串口;
begin
n4click(self);
if(caxun_event.WaitFor(1000)=wrtimeout) then
begin
if(listview1.Items.Item[sr].equipment_type='交流柜配电箱') then listview1.Items.Item[sr].ImageIndex:=2
else if(listview1.Items.Item[sr].equipment_type='56路交直流电源头柜') then listview1.Items.Item[sr].ImageIndex:=5
else if(listview1.Items.Item[sr].equipment_type='64路双路交流电源柜') then listview1.Items.Item[sr].ImageIndex:=11
else if(listview1.Items.Item[sr].equipment_type='100路电源头柜') then listview1.Items.Item[sr].ImageIndex:=8;
statusbar1.Panels[0].Text:=listview1.Items.Item[sr].Caption+'查询失败';
sr:=sr+1;
if(sr>listview1.Items.Count-1) then sr:=0;
end
else
begin
statusbar1.Panels[0].Text:=listview1.Items.Item[sr].Caption+'查询成功';
sr:=sr+1;
if(sr>listview1.Items.Count-1) then sr:=0;
caxun_event.ResetEvent;//收到正确数据后,caxun_event.setEvent
end;
//form1.ListView1.Items.Item[sr].Selected:=true;
//form1.StatusBar1.Panels[3].Text:=inttostr(sr);
end;
大家帮我看一下,这段代码有什么不对,明明设置sr:=0,但论询时第一个扫瞄的是第二个站点,第一个站点要轮询完,第二遍才扫瞄到
是发送过程代码