能不能给个简单的例子,我是这样发的,那边收到的就是Ascii
var tempCmd:array of Byte;
i,j:integer;
sbufchar;
str:string;
Cmdchar;
begin
case Cmdobj of
1: //查询
begin
setlength(tempcmd,7);
tempCmd[0]:=27;
tempCmd[1]:=Count;
tempCmd[2]:=0;
tempCmd[3]:=2;
tempCmd[4]:=0;
tempCmd[5]:=strtoint(CarNo);
tempCmd[6]:=CreateCrc(tempCmd,6);
for i:=0 to 6 do str:=str+inttostr(tempCmd);
GetMem(sbuf,Length(str)+1);
StrPLCopy(sbuf,str,Length(str));
Comm1.WriteCommData(sbuf,strlen(sbuf));
end;
帮你改了一下,你先试试,不行我再发:
var
tempCmd:array of Byte;
i,j:integer;
sbufchar;
str:string;
Cmdchar;
begin
setlength(tempcmd,6);
tempCmd[0]:=byte(27);
tempCmd[1]:=byte(Count);//Count应该是数字吧
tempCmd[2]:=byte(0);
tempCmd[3]:=byte(2);
tempCmd[4]:=byte(0);
tempCmd[5]:=byte(strtoint(CarNo));//CarNo应该是字符串吧
tempCmd[6]:=CreateCrc(tempCmd,6);
for i:=0 to 5 do
Comm1.WriteCommData(@tempCmd,1);