Air Manager reads dataref wrong

Questions about deployment and use of Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
nikyukuu
Posts: 3
Joined: Fri Apr 02, 2021 9:12 pm

Air Manager reads dataref wrong

#1 Post by nikyukuu »

Hi. I am trying to build panels for the Airfoil Labs King Air 350. For some reason, Air Manager does not read the datarefs correctly. I adapted the Air Manager example for switches, as there are commands for toggling the switches as well as datarefs showing the switch position, but somehow Air Manager reads the switch datarefs as 0 instead of whatever they are set to. The Air Manager Data Viewer shows the datarefs as 0, while DataRefTool in X-Plane shows the correct values. I already tried setting the King Air to the pre-configured states, reinstalling the King Air and reinstalling Air Manager. Anybody got an idea what the error could be?

I tried with version 3.7 as well as 4.0 Beta.

Here is the Lua code, if anyone can find an error in those few lines.

Code: Select all

backdrop = img_add_fullscreen("panel.png")

function p_auto_comm_swcb(position, direction)
    xpl_command("KA350/cmd/avpanel/pAutoComm")
end

function p_auto_comm_drcb(position)
  if position == 0 then
    switch_set_position(p_auto_comm, 0)
  else switch_set_position(p_auto_comm, 1)
  end
end

p_auto_comm = switch_add("sw_down.png", "sw_up.png", 14,42,32,42,p_auto_comm_swcb)
xpl_dataref_subscribe("KA350/ianim/avpanel/pAutoComm", "INT", p_auto_comm_drcb)


User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Air Manager reads dataref wrong

#2 Post by Sling »

Do you have the dataref type correct. Sometimes it seems obvious that a dataref type is an “INT” and the dev uses a “FLOAT”. Remember to restart the sim and AM when changing dataref subscriptions to be absolutely sure.

No need for the if..else in the subscribe callback. This won’t stop it from working but is extra code for no benefit.

User avatar
Ralph
Posts: 7878
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Air Manager reads dataref wrong

#3 Post by Ralph »

As Tony said, sounds like you subscribed with the wrong type.

nikyukuu
Posts: 3
Joined: Fri Apr 02, 2021 9:12 pm

Re: Air Manager reads dataref wrong

#4 Post by nikyukuu »

Thank you, that was the cause!

Post Reply