Fóruns
UPA Script - Correção de KM Golf G2 - Versão de Impressão

+- Fóruns (https://www.msbig.net)
+-- Fórum: Grupo Leves (https://www.msbig.net/forumdisplay.php?fid=28)
+--- Fórum: Volkswagen (https://www.msbig.net/forumdisplay.php?fid=124)
+---- Fórum: Eletrônica Embarcada (https://www.msbig.net/forumdisplay.php?fid=126)
+----- Fórum: Painel (https://www.msbig.net/forumdisplay.php?fid=254)
+----- Tópico: UPA Script - Correção de KM Golf G2 (/showthread.php?tid=3230)



UPA Script - Correção de KM Golf G2 - admin - 16-07-2020

program Prog1;
var
  Code, Code_1: string;
  KM: Integer;

procedure ReadKM;
begin
  if not ReadDevice then
  begin
    MsgBox('Read Error', 'Error', MB_OK);
  end
  else
  begin
    AddMsg('Golf G2');

    Code_1 := inttohex(GetByteHexEdit($61), 2) + inttohex(GetByteHexEdit($60), 2);
    KM := ((65535 - strtoint('$' + Code_1)) * 32);
    AddMsg('Kilometragem atual' + ' = ' + IntToStr(KM) + ' km');
    MsgBox(IntToStr(KM) + ' km', 'KM Atual', MB_OK);
  end;
end;

procedure NewKM;
var
  n, new_KM: integer;
  n1: string;

begin
  SetProgramModifiedOnly(true);
  if InBox('Digite a KM', 'Nova KM', code) then
  begin

  end;
  if StrToInt(code) > 999999 then
  begin
    MsgBox('O valor deve ser 000001 até 999999', 'Erro', MB_OK);
    exit;
  end;

  n := StrToInt(code);
  new_KM := (65535 - (n / 32));
  n1 := IntToHex(new_KM, 4);

  SetByteHexEdit($60, (strtoint('$' + n1[3] + n1[4])));
  SetByteHexEdit($61, (strtoint('$' + n1[1] + n1[2])));
  SetByteHexEdit($62, (strtoint('$' + n1[3] + n1[4])));
  SetByteHexEdit($63, (strtoint('$' + n1[1] + n1[2])));
  SetByteHexEdit($64, (strtoint('$' + n1[3] + n1[4])));
  SetByteHexEdit($65, (strtoint('$' + n1[1] + n1[2])));
  SetByteHexEdit($66, (strtoint('$' + n1[3] + n1[4])));
  SetByteHexEdit($67, (strtoint('$' + n1[1] + n1[2])));
  SetByteHexEdit($68, (strtoint('$' + n1[3] + n1[4])));
  SetByteHexEdit($69, (strtoint('$' + n1[1] + n1[2])));
  SetByteHexEdit($6A, (strtoint('$' + n1[3] + n1[4])));
  SetByteHexEdit($6B, (strtoint('$' + n1[1] + n1[2])));
  SetByteHexEdit($6C, (strtoint('$' + n1[3] + n1[4])));
  SetByteHexEdit($6D, (strtoint('$' + n1[1] + n1[2])));
  SetByteHexEdit($6E, (strtoint('$' + n1[3] + n1[4])));
  SetByteHexEdit($6F, (strtoint('$' + n1[1] + n1[2])));
  SetByteHexEdit($70, (strtoint('$' + n1[3] + n1[4])));
  SetByteHexEdit($71, (strtoint('$' + n1[1] + n1[2])));
  SetByteHexEdit($72, (strtoint('$' + n1[3] + n1[4])));
  SetByteHexEdit($73, (strtoint('$' + n1[1] + n1[2])));
  SetByteHexEdit($74, (strtoint('$' + n1[3] + n1[4])));
  SetByteHexEdit($75, (strtoint('$' + n1[1] + n1[2])));
  SetByteHexEdit($76, (strtoint('$' + n1[3] + n1[4])));
  SetByteHexEdit($77, (strtoint('$' + n1[1] + n1[2])));
  SetByteHexEdit($78, (strtoint('$' + n1[3] + n1[4])));
  SetByteHexEdit($79, (strtoint('$' + n1[1] + n1[2])));
  SetByteHexEdit($7A, (strtoint('$' + n1[3] + n1[4])));
  SetByteHexEdit($7B, (strtoint('$' + n1[1] + n1[2])));
  SetByteHexEdit($7C, (strtoint('$' + n1[3] + n1[4])));
  SetByteHexEdit($7D, (strtoint('$' + n1[1] + n1[2])));
  SetByteHexEdit($7E, (strtoint('$' + n1[3] + n1[4])));
  SetByteHexEdit($7F, (strtoint('$' + n1[1] + n1[2])));
  RefreshHexEdit;
  if MsgBox('Programar?', 'Confirme', MB_YESNO) = IDYES then
  begin
    SetProgramModifiedOnly(true);
    ProgramDevice;
    VerifyDevice;
    ReadKM;
  end;
end;

begin
  AddDeviceGroup('VW', 'Select a car');
  AddDevice('Golf G2', '93S46', 'VW', '93S46');
  AddAction('Read KM', 'ReadKM', 'Golf G2');
  AddAction('New KM', 'NewKM', 'Golf G2');
  AddMsg('Script (Golf G2.uds) Installed '#169' 2020 Fórum MSBig - www.msbig.net');
  SetProductInfo('Golf G2', 'Device Script'#$D'Copyright'#169' 2020 Fórum MSBig - www.msbig.net');
end.