J
jiweishan
Unregistered / Unconfirmed
GUEST, unregistred user!
我用串口读16进制数据结果发出命令收不到数据啊,请问这是怎么回事啊,代码如下:<br>procedure TForm1.FormShow(Sender: TObject);<br>begin<br> MSComm1.CommPort := 1;<br> MSComm1.Settings := '19200,n,8,1';<br> MSComm1.InputLen := 0;<br> MSComm1.InputMode := comInputModeBinary;<br> MSComm1.RThreshold := 1;<br> MsComm1.PortOpen := True;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>Var Str : OleVariant;<br> i : iNTEGER;<br> AA : String;<br>begin<br> MSComm1.OutBufferCount := 0;<br> MSComm1.Output := IntToHex($1B,2);<br> Ab := $1B;<br> MSComm1.Output := IntToHex(Ab,2);<br> Ab := $49;<br> MSComm1.Output :=IntToHex(Ab,2);<br> Delay(100);<br> Str := MSComm1.Input;<br> Begin<br> For I := 1 To Length(Str) DO<br> Begin<br> AA := AA + Str;<br> End;<br> End;<br> ShowMessage(Str);<br><br>end;<br><br>procedure TForm1.MSComm1Comm(Sender: TObject);<br> Var<br> Xbyte : Word;<br> j : Word;<br>InByte :Byte;<br>inbyte2: Byte;<br>inData : String;<br>begin<br><br> Case MSComm1.CommEvent of <br> comEvReceive : <br> BEgin<br> InByte := MSComm1.Input;<br> ShowMessage(IntToStr(InByte));<br><br> End;<br> comEventRxOver<br> ShowMessage('Err');<br> End;<br><br>end;<br>