接受代码如下:procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
strRecv,MyData: string;
MWei,Wei1,Wei2,Wei3: string;
begin
SetLength(strRecv,BufferLength);
Move(Buffer^,PChar(strRecv)^,BufferLength);
if strRecv=#$E5 then //发送确认码
begin
PLCEnter;
end
else
begin //处理接受的有效数据
if (Length(strRecv)=35) or (Length(strRecv)=127) and (SendType<>3) then
begin
if Length(strRecv)=35 then
begin
try
MyData:=Copy(strRecv,26,8); except end; end;
if Length(strRecv)=127 then
begin end;
end;
end ;
end ;串口监控的数据如下:01 00 00 00 00 00 00 00
转化为字符串时怎么变成了 #1 #0 #0 #0 #0 #0 #0 #0,求解?
另请教怎么让 #1 #0 #0 #0 #0 #0 #0 #0转化为10进制。
BufferLength: Word);
var
strRecv,MyData: string;
MWei,Wei1,Wei2,Wei3: string;
begin
SetLength(strRecv,BufferLength);
Move(Buffer^,PChar(strRecv)^,BufferLength);
if strRecv=#$E5 then //发送确认码
begin
PLCEnter;
end
else
begin //处理接受的有效数据
if (Length(strRecv)=35) or (Length(strRecv)=127) and (SendType<>3) then
begin
if Length(strRecv)=35 then
begin
try
MyData:=Copy(strRecv,26,8); except end; end;
if Length(strRecv)=127 then
begin end;
end;
end ;
end ;串口监控的数据如下:01 00 00 00 00 00 00 00
转化为字符串时怎么变成了 #1 #0 #0 #0 #0 #0 #0 #0,求解?
另请教怎么让 #1 #0 #0 #0 #0 #0 #0 #0转化为10进制。
var
Ss: array of byte; for i:=1 to BufferLength do
Ss[i-1]:=ord(strRecv[i]);
BufferLength: Word);
var
StrRecv: string;
i:integer;
begin
SetLength(strRecv,BufferLength);
Move(Buffer^,PChar(strRecv)^,BufferLength);
//---------------转化为ASCII码开始---------------求代码。。//---------------转化为ASCII码结束---------------end;
BufferLength: Word);
var
StrRecv: string;
iAsc: array of Byte;
i:integer;
begin
SetLength(strRecv,BufferLength);
SetLength(iAsc,BufferLength);
Move(Buffer^,PChar(strRecv)^,BufferLength);
//---------------转化为ASCII码开始---------------
for i:=1 to BufferLength do
iAsc[i-1]:= Ord(strRecv[i]);
//---------------转化为ASCII码结束---------------
end;