代码大致如下:
procedure TCom.ReadCom(var buffer: string; var dwCount: Cardinal);
var
dwNum:Cardinal;
begin
dwNum:=DWORD(-1);
ReadFile(Handle,buffer,1024,dwNum,nil);
dwCount := dwNum;procedure TComThread.Execute;
var
lpBuffer:string;
dwCount:Cardinal;
pcmd:pCommand; //pcommand为一命令包指针
if com = nil then
begin
raise exception.Create('!!!!');
end;
while (not Suspended) do
begin
com.ReadCom(lpBuffer,dwCount); if dwCount>0 then pcmd := PCommand(lpBuffer);DWCOUNT中有值,但LPBUFFER无效,且串口测试过,工作正常,PCMD^中老是取不到值。
procedure TCom.ReadCom(var buffer: string; var dwCount: Cardinal);
var
dwNum:Cardinal;
begin
dwNum:=DWORD(-1);
ReadFile(Handle,buffer,1024,dwNum,nil);
dwCount := dwNum;procedure TComThread.Execute;
var
lpBuffer:string;
dwCount:Cardinal;
pcmd:pCommand; //pcommand为一命令包指针
if com = nil then
begin
raise exception.Create('!!!!');
end;
while (not Suspended) do
begin
com.ReadCom(lpBuffer,dwCount); if dwCount>0 then pcmd := PCommand(lpBuffer);DWCOUNT中有值,但LPBUFFER无效,且串口测试过,工作正常,PCMD^中老是取不到值。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货