Hello developers (and Pete offcourse!),
I'm currently busy programming for FSUIPC via Lazarus/Delphi. I'm building a program which is able to read and change radio frequencies from FSUIPC, and will eventually be controllable via Arduino.
Currently the program doesn't work and it states an error about the offset is not an integer..., but it did work in the past (most of the time some frequencies work, and other don't). It seems to be a data-conversion issue, which seems to be different every time I start FS. I know that the offset-data is in BCD format. Can anyone please help me out with the conversion?
procedure TFormMain.FormCreate(Sender: TObject);
var
dwResult : DWORD;
begin
// Verbinding maken met FSUIPC
if FSUIPC_Open(SIM_Any, dwResult) then begin
// Status wanneer verbonden tonen
Lbl_FSUIPC_Conn_status.Caption := 'Connected'
end else begin
// Status wanneer niet verbonden tonen
Lbl_FSUIPC_Conn_status.Caption := 'Not connected'
end;
end;
procedure TFormMain.TimerRefreshDataTimer(Sender: TObject);
var
dwResult : DWORD;
int_COMM1_Active_FS_frequency, int2_COMM1_Active_FS_frequency, int_NAV1_Active_FS_frequency, int2_NAV1_Active_FS_frequency, int_COMM1_Standby_FS_frequency, int2_COMM1_Standby_FS_frequency, int_NAV1_Standby_FS_frequency, int2_NAV1_Standby_FS_frequency: integer;
str_COMM1_Active_FS_frequency, str_NAV1_Active_FS_frequency, str_COMM1_Standby_FS_frequency, str_NAV1_Standby_FS_frequency : string;
begin
// COMM1 Active uit FS lezen
if FSUIPC_Read($034E, 2, @int_COMM1_Active_FS_frequency, dwResult) then begin
// "Read" voltooid, dan:
if FSUIPC_Process(dwResult) then begin
// "Process" wanneer voltooid, dan:
str_COMM1_Active_FS_frequency := IntToHex(int_COMM1_Active_FS_frequency,1);
int2_COMM1_Active_FS_frequency := StrToInt(str_COMM1_Active_FS_frequency);
int2_COMM1_Active_FS_frequency := 10000 + int2_COMM1_Active_FS_frequency;
Lbl_COMM1_Active_frequency.Caption := IntToStr(int2_COMM1_Active_FS_frequency);
end
end;
// NAV1 uit FS lezen
if FSUIPC_Read($0350, 2, @int_NAV1_Active_FS_frequency, dwResult) then begin
// "Read" voltooid, dan:
if FSUIPC_Process(dwResult) then begin
// "Process" wanneer voltooid, dan:
str_NAV1_Active_FS_frequency := IntToHex(int_NAV1_Active_FS_frequency,1);
int2_NAV1_Active_FS_frequency := StrToInt(str_NAV1_Active_FS_frequency);
int2_NAV1_Active_FS_frequency := 10000 + int2_NAV1_Active_FS_frequency;
Lbl_NAV1_Active_frequency.Caption := IntToStr(int2_NAV1_Active_FS_frequency);
end
end;
// COMM1 Standby uit FS lezen
// COMM1 Standby uit FS lezen
if FSUIPC_Read($311A, 2, @int_COMM1_Standby_FS_frequency, dwResult) then begin
// "Read" voltooid, dan:
if FSUIPC_Process(dwResult) then begin
// "Process" wanneer voltooid, dan:
str_COMM1_Standby_FS_frequency := IntToHex(int_COMM1_Standby_FS_frequency,1);
int2_COMM1_Standby_FS_frequency := StrToInt(str_COMM1_Standby_FS_frequency);
int2_COMM1_Standby_FS_frequency := 10000 + int2_COMM1_Standby_FS_frequency;
Lbl_COMM1_Standby_frequency.Caption := IntToStr(int2_COMM1_Standby_FS_frequency);
end
end;
// NAV1 Standby uit FS lezen
if FSUIPC_Read($311E, 2, @int_NAV1_Standby_FS_frequency, dwResult) then begin
// "Read" voltooid, dan:
if FSUIPC_Process(dwResult) then begin
// "Process" wanneer voltooid, dan:
str_NAV1_Standby_FS_frequency := IntToHex(int_NAV1_Standby_FS_frequency,1);
int2_NAV1_Standby_FS_frequency := StrToInt(str_NAV1_Standby_FS_frequency);
int2_NAV1_Standby_FS_frequency := 10000 + int2_NAV1_Standby_FS_frequency;
Lbl_NAV1_Standby_frequency.Caption := IntToStr(int2_NAV1_Standby_FS_frequency);
end
end;
end;
I hope you can help me with my problem!
Jesse