Hi guys.
I'm trying to build something small , that can lower the gear, set flaps, spoilers, and some rotary encoders to set the autopilot.
I'm a developer , and somethimes in delphi. Therefor i tried to write some code to read/write to and from FSX.
I started with the UIPCHello that is in the FSUIPC SDK. the only thing i could get out of fsx was the speed. And with a conversion
that doesn't make any sense to me. The writing i tried in this example (turn on the autopilot) ends in a crash of the delphi prog.
procedure TFormMain.TimerUpdateTimeTimer(Sender: TObject);
var
dwResult: DWORD;
deger:int64;
Velocidade: longint;
Ap_Alt,Ap_Crs:integer;
Calculo: Double;
begin
if FSUIPC_Read($02BC, 4, @Velocidade, dwResult) then begin
if FSUIPC_Process(dwResult) then begin
Calculo := Round(Velocidade / 128);
LabelFSclock.Caption := FloatToStr(Calculo);
end else begin
LabelFSclock.Caption := 'Processing: ' + ResultText[dwResult];
end;
end else begin
LabelFSclock.Caption := 'Reading: ' + ResultText[dwResult];
end;
if FSUIPC_Read($07D4, 4, @Ap_Alt, dwResult) then begin
if FSUIPC_Process(dwResult) then begin
Label5.Caption := floattostr(round(AP_Alt/65536*3.281));
end else begin
Label5.Caption := 'Processing: ' + ResultText[dwResult];
end;
end else begin
Label5.Caption := 'Reading: ' + ResultText[dwResult];
end;
if FSUIPC_Read($07CC, 4, @Ap_Crs, dwResult) then begin
if FSUIPC_Process(dwResult) then begin
Label7.Caption := floattostr(round(Ap_Crs/65536*3.281));
end else begin
Label7.Caption := 'Processing: ' + ResultText[dwResult];
end;
end else begin
Label7.Caption := 'Reading: ' + ResultText[dwResult];
end;
end;
procedure TFormMain.Button1Click(Sender: TObject);
var dwResult: DWORD;
offset,size:longint;
waarde:byte;
begin
offset:=$7BC;
size:=4;
waarde:=1;
if FSUIPC_Write(offset, size, ptr(waarde), dwResult) then begin
if FSUIPC_Process(dwResult) then begin
button1.caption:='CMD A ON'
end;
end;
end;
doesn't anyone has an explanation why it doesn't work, or does anyone has some sample code ?
thanx allot !!!!!!