Модуль "P2KApi" (часть 64) - TP2KAPI.MakeDump

Рубрика: Исходники
Среда, 21 апреля 2010 г.
Просмотров: 51
последняя версия: 3.0.9 build 961 beta
от 07 декабря 2007 г.
function TP2KAPI.MakeDump(StartAddr, EndAddr: DWord; Buffer: pointer): Boolean;
var Cmd_temp:array[0..14] of char;
    HexAddr:string[8];
    ProgressPercent:Integer;
    Cmd_Ans:array[0..255] of char;
    BufPos, Count:Integer;
    Addr, End1:DWord;
    xx: dword;
begin

 Result:= TelStatus;
 if not TelStatus then exit;
 Addr:=StartAddr;
 End1:=EndAddr-StartAddr;
 Count:=0;
 BufPos:=0;
 while Addr<EndAddr do begin
  ProgressPercent:=Round((Addr-StartAddr)/(End1)*100);
  HexAddr:=IntToHex(Addr,8);
  cmd_temp[0]:=#02;
  cmd_temp[1]:='D';
  cmd_temp[2]:='U';
  cmd_temp[3]:='M';
  cmd_temp[4]:='P';
  cmd_temp[5]:=#$1E;
  cmd_temp[6]:=HexAddr[1];
  cmd_temp[7]:=HexAddr[2];
  cmd_temp[8]:=HexAddr[3];
  cmd_temp[9]:=HexAddr[4];
  cmd_temp[10]:=HexAddr[5];
  cmd_temp[11]:=HexAddr[6];
  cmd_temp[12]:=HexAddr[7];
  cmd_temp[13]:=HexAddr[8];
  cmd_temp[14]:=#03;
  xx:= 1024;
  USB_WriteDataEx(@Cmd_temp, 15,2,xFlashTimeOut);
  USB_ReadDataEx(@Cmd_ans, xx,2,xFlashTimeOut);
  if Pos(#$02'ERR'#$1E,Cmd_ans)>0 then begin
   Result:=False;
   Exit;
  end
  else result:= true;
//  move(Data^,cmd_temp[7],Size);
  move(cmd_ans[0],Buffer^,256);
  asm
    mov eax, Buffer
    add eax, 256
    mov Buffer, eax
  end;
  Inc(Addr,$100);
 end;
end;
Rambler's Top100