Thema: Delphi Auslesen/Programmieren

Einzelnen Beitrag anzeigen

STW

Registriert seit: 19. Nov 2003
Ort: Solothurn
22 Beiträge
 
#25

Re: Auslesen/Programmieren

  Alt 7. Jan 2004, 07:35
Hallo

Brauch nochmals ein bisschen Hilfe...
nochmals ein bisschen code

Hab es nun mit Arrays gemacht:
Delphi-Quellcode:
type
  PFT_PROGRAM_DATA = ^FT_PROGRAM_DATA;
  FT_PROGRAM_DATA = packed record //(EEPROM Programming Interface)
    VendorID : word;
    ProductID : word;
    Manufacturer : Array [0..12] of Char; // PChar;
    ManufacturerID : Array [0..8] of Char; // PChar;
    Description : Array [0..24] of Char; // PChar;
    SerialNumber : Array [0..12] of Char; // PChar;
    MaxPower : word;
    PnP : Word;
    SelfPowered : Word;
    RemoteWakeup : Word;
    Rev4 : boolean;
    IsoIn : boolean;
    IsoOut : boolean;
    PullDownEnable : boolean;
    SerNumEnable : boolean;
    USBVersionEnable : boolean;
    USBVersion : Word;
  end;

var
 ftData : FT_PROGRAM_DATA;

implementation
function FT_EE_Program(fthandle: DWord; PFT_PROGRAM_DATA: Pointer) : FT_Result; stdcall ; External FT_DLL_Name name 'FT_EE_Program';
function FT_EE_Read(fthandle: DWord; PFT_PROGRAM_DATA: Pointer) : FT_Result; stdcall ; External FT_DLL_Name name 'FT_EE_Read';


Function ProgramEE : FT_Result;
 begin
  Result := FT_EE_Program(Multi_Handle,@FTData);
  if Result <> FT_OK then FT_Error_Report('FT_EE_Program',Result);
end;

Function ReadEE : FT_Result;
begin
  Result := FT_EE_Read(Multi_Handle,@FTData);
  if Result <> FT_OK then FT_Error_Report('FT_EE_Read',Result);
end;
Hier ist, wie ich die ftData einlese:

Delphi-Quellcode:
procedure TForm1.ProgramButClick(Sender: TObject);
begin
  DeviceIndex := 0;
  GetFTDeviceCount;
  if NumDevs > 0 then repeat
    case DeviceIndex of
      0: DevNumber := SR1.Text;
      1: DevNumber := SR2.Text;
    end;
    FT_OpenEx(DevNumber,FT_OPEN_BY_SERIAL_NUMBER,@Multi_Handle);
    FtData.VendorID := StrToInt('$'+VendorID.Text);
    ftData.ProductID := StrToInt('$'+ProductID.Text);
    StrNew(StrPCopy(ftData.Manufacturer, (Manufacturer.Text)));
    StrNew(StrPCopy(ftData.ManufacturerID, (ManufacturerID.Text)));
    StrNew(StrPCopy(ftData.Description, (Description.Text)));
    StrNew(StrPCopy(ftData.SerialNumber, ((SerialNumber.Text + IntToStr(DeviceIndex)))));
    ftData.MaxPower := strtoint(MaxPower.Text);
    ftData.PnP := StrToInt(PnP.Items[PnP.ItemIndex]);
    ftData.SelfPowered := StrToInt(SelfPowered.Items[SelfPowered.ItemIndex]);
    ftData.RemoteWakeup := StrToInt(RemoteWakeup.Items[RemoteWakeup.ItemIndex]);
    ftData.Rev4 := False;
    ftData.IsoIn := False;
    ftData.IsoOut := False;
    ftData.PullDownEnable := False;
    ftData.SerNumEnable := True;
    ftData.USBVersionEnable := True;
    if USBVersion.Text = 'USB 2.0then
      ftData.USBVersion := $0200
    else ftData.USBVersion := $0110;
    ProgramEE;
    Close_USB_Device;
    inc(DeviceIndex);
    dec(NumDevs);
  until NumDevs = 0;
  SerialNumber.Text := SerialNumberEdit.Text;
end;
Jedoch stürzt das Prog bei dieser Zeile immer ab!
function FT_EE_Program(fthandle: DWord; PFT_PROGRAM_DATA: Pointer) : FT_Result; stdcall ; External FT_DLL_Name name 'FT_EE_Program'; und der EAccesViolation-Error erscheint...


Hat vielleicht noch jemand eine Idee?

PEACE
STW
  Mit Zitat antworten Zitat