Z
zhiqunluodelphi
Unregistered / Unconfirmed
GUEST, unregistred user!
我用mscomm控件写COM口时,当我从接收的数据量有几K时,分几次接收到,但我接收到的数据
有乱码.不知什么原因.
procedure TFrmMain.SerialComComm(Sender: TObject);
begin
Case SerialCom.CommEvent of
comEvReceive: // Received RThreshold # of chars.
TRstoreByte;
comEvSend: ;
// ' There are SThreshold number of characters in the transmit buffer.
comEvEOF: ;// ' An EOF charater was found in the input stream
comEvCD: ;// ' Change in the CD line.
comEvCTS: ;// ' Change in the CTS line.
comEvDSR: ;// ' Change in the DSR line.
comEvRing: ;// ' Change in the Ring Indicator.
// ' Errors
comEventBreak: ;// ' A Break was received.
comEventCDTO: ;// ' CD (RLSD) Timeout.
comEventCTSTO: ;// ' CTS Timeout.
comEventDSRTO: ;// ' DSR Timeout.
comEventFrame: ;// ' Framing Error
comEventOverrun: ;// ' Data Lost.
comEventRxOver: ;// 'Receive buffer overflow.
comEventRxParity: ;// ' Parity Error.
comEventTxFull: ;// ' Transmit buffer full.
comEventDCB: ;// ' Unexpected error retrieving DCB]
end;
end;
procedure TRstoreByte;
var
Blen,BlenNext, Len1 ,Len2,Len3,MessLen, Code,i: Integer;
kk,j:integer;
temp:byte;
StrMesg,tmpMesg ,MessString,BZ,ReceivePhone,ReceiveTime,newstr : string;
BRevData : Boolean;
begin
ReadBuf := FrmMain.SerialCom.Input;
// InBufferLen := Length(readBuf);
StrMesg := pchar((@ReadBuf)^);
FrmMain.MemoReturn.Lines.Add(StrMesg);
case frmmain.xlh of
73: //列FTP文件目录
begin
Blen := pos('I/OK',strMesg);
if Blen > 0 then
begin
FTPDirMesg := '';
sleep(5000);
exit;
end;
Blen := pos('I/ONLINE',strMesg);
if Blen > 0 then
begin
FTPDirMesg := FTPDirMesg+strMesg;
//ShowMessage(FTPDirMesg);
FrmMain.AddFtpDirToViewTree(FTPDirMesg);
end
else
sleep(5000);
end;
end;
有乱码.不知什么原因.
procedure TFrmMain.SerialComComm(Sender: TObject);
begin
Case SerialCom.CommEvent of
comEvReceive: // Received RThreshold # of chars.
TRstoreByte;
comEvSend: ;
// ' There are SThreshold number of characters in the transmit buffer.
comEvEOF: ;// ' An EOF charater was found in the input stream
comEvCD: ;// ' Change in the CD line.
comEvCTS: ;// ' Change in the CTS line.
comEvDSR: ;// ' Change in the DSR line.
comEvRing: ;// ' Change in the Ring Indicator.
// ' Errors
comEventBreak: ;// ' A Break was received.
comEventCDTO: ;// ' CD (RLSD) Timeout.
comEventCTSTO: ;// ' CTS Timeout.
comEventDSRTO: ;// ' DSR Timeout.
comEventFrame: ;// ' Framing Error
comEventOverrun: ;// ' Data Lost.
comEventRxOver: ;// 'Receive buffer overflow.
comEventRxParity: ;// ' Parity Error.
comEventTxFull: ;// ' Transmit buffer full.
comEventDCB: ;// ' Unexpected error retrieving DCB]
end;
end;
procedure TRstoreByte;
var
Blen,BlenNext, Len1 ,Len2,Len3,MessLen, Code,i: Integer;
kk,j:integer;
temp:byte;
StrMesg,tmpMesg ,MessString,BZ,ReceivePhone,ReceiveTime,newstr : string;
BRevData : Boolean;
begin
ReadBuf := FrmMain.SerialCom.Input;
// InBufferLen := Length(readBuf);
StrMesg := pchar((@ReadBuf)^);
FrmMain.MemoReturn.Lines.Add(StrMesg);
case frmmain.xlh of
73: //列FTP文件目录
begin
Blen := pos('I/OK',strMesg);
if Blen > 0 then
begin
FTPDirMesg := '';
sleep(5000);
exit;
end;
Blen := pos('I/ONLINE',strMesg);
if Blen > 0 then
begin
FTPDirMesg := FTPDirMesg+strMesg;
//ShowMessage(FTPDirMesg);
FrmMain.AddFtpDirToViewTree(FTPDirMesg);
end
else
sleep(5000);
end;
end;