E
edns
Unregistered / Unconfirmed
GUEST, unregistred user!
各位大虾,你们好,我的电脑使用了键盘圆型接口连接了条型扫描仪和键盘焦点在edit1 上,点击Button1,memo1中只显示"发送F001FFFF01F0"而没有"接收F001FFFF01F0"不知道哪里出了问题????请各位前备帮忙!!!谢谢了先以下是代码:----------------var Fspcomm: TFspcomm; viewstring:string; i:integer; rbuf,sbuf:array[1..6] of byte;implementation{$R *.dfm}procedure TFspcomm.senddata;vari:integer;commflg:boolean;viewstring:string;beginviewstring:='';commflg:=true;for i:=1 to 6 dobeginif not Fspcomm.comm1.writecommdata(@sbuf,1) thenbegincommflg:=false;break;end;sleep(2);viewstring:=viewstring+inttohex(sbuf,2)+''; end;viewstring:='发送'+viewstring;Fspcomm.memo1.lines.add(viewstring);Fspcomm.memo1.lines.add('');if not commflg then messagedlg('发送失败!',mterror,[mbyes],0);end;procedure TFspcomm.Comm1ReceiveData(Sender: TObject; Buffer: Pointer; BufferLength: Word);var i:integer;begin viewstring:=''; move(buffer^,pchar(@rbuf)^,bufferlength); for i:=1 to bufferlength do viewstring:=viewstring+inttohex(rbuf,2)+''; viewstring:='接收'+viewstring; memo1.lines.add(viewstring); memo1.lines.add('');end;procedure TFspcomm.BitBtn2Click(Sender: TObject);begincomm1.StopComm;end;procedure TFspcomm.Button1Click(Sender: TObject);beginsbuf[1]:=byte($f0);sbuf[2]:=byte($05);sbuf[3]:=byte($ff);sbuf[4]:=byte($ff);sbuf[5]:=byte($01);sbuf[6]:=byte($f0);senddata;end;procedure TFspcomm.BitBtn1Click(Sender: TObject);begintry comm1.CommName:=combobox1.Text; Comm1.StartComm; statusbar1.Panels.Items[0].Text:='ok!'; Memo1.Clear; except statusbar1.Panels.Items[0].Text:='not ok!'; end;end;end.