刚好我最近也在搞类似的东东,串口控件用SPCOMM,不过好像CPORT更好用。
具体控件怎么用就不多说了,这里给个CRC的函数
function calCRC(ptr:pchar; count:integer) :word;
var
iCrc:word;
i:integer;
begin
iCrc:=0;
while count>0 do begin
iCrc:=iCrc xor (smallint(ptr^) shl 8);
for i:=8 downto 1 do
if ((iCrc and $8000)<>0) then
iCrc:=(iCrc shl 1) xor $1021
else
iCrc:=iCrc shl 1;
pchar(ptr):=pchar(ptr+1);
count:=count-1;
end;
Result:=iCrc;
end;
具体控件怎么用就不多说了,这里给个CRC的函数
function calCRC(ptr:pchar; count:integer) :word;
var
iCrc:word;
i:integer;
begin
iCrc:=0;
while count>0 do begin
iCrc:=iCrc xor (smallint(ptr^) shl 8);
for i:=8 downto 1 do
if ((iCrc and $8000)<>0) then
iCrc:=(iCrc shl 1) xor $1021
else
iCrc:=iCrc shl 1;
pchar(ptr):=pchar(ptr+1);
count:=count-1;
end;
Result:=iCrc;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货