x-plane dataref communication problem

Peer support for Air Manager desktop users

Moderators: russ, Ralph

Post Reply
Message
Author
whbossert
Posts: 9
Joined: Thu Jun 10, 2021 2:42 pm

x-plane dataref communication problem

#1 Post by whbossert »

I am developing a number of panels for the x-crafts E175. Things are going very well with an overhead panel and the Tekton MCDU in use. HOWEVER, I'm having a problem with a simple switch subpanel. The following lua script produces the expected initial instrument but it doesn't communicate with the x-plane dataref used. I can send 0 or 1 to the dataref listed in the Air Manager subscription panel and it flips the switch just fine but it doesn't change the x-plane dataref of the same name in x-plane as witnessed on DataRefTool. Writing the dataref in DatRefTool opens and closes the door ok but doesn't change the Air Manager value and doesn't cause a dataref subscription callback. I cut and pasted the dataref name from DataRefTool to my script to make sure I had the name correct. Since this is a non-Laminar dataref setup by loading the plane, I have waited until x-plane and the aircraft are loaded before starting Air Manager and my instrument. Other custom datarefs for the same plane, such as the Tekton ones for the MCDU work just fine. I've tried lots of combinations of hopeful fixes with no luck. I would appreciate any suggestions.....

-- Add images --
img_add_fullscreen("switches.png")

t1 = txt_add(" DOORS","font:arimo_bold.ttf; size:20; color: white; halign:center; valign:center",160,5,100,30)
t2 = txt_add("FNT MAIN FNT CARGO","font:arimo_bold.ttf; size:20; color: white; halign:center; valign:center",80,30,300,30)


-- Switches --

function door1control(position)
xpl_dataref_write("xcraft/doors/front_main","INT",1)
end

function door1switchposition(position)
print(position)
switch_set_position(door1switch,position)
end

door1switch = switch_add("toggle1down.png","toggle1up.png",125,50,83,124,door1control)

xpl_dataref_subscribe("xcraft/doors/front_main","INT",door1switchposition)
mouse_setting(door1switch,"CURSOR","hand_cursor.png")

lonespace
Posts: 64
Joined: Wed Mar 25, 2020 1:58 am

Re: x-plane dataref communication problem

#2 Post by lonespace »

Might be a long shot but try subscribing to it as a float instead of an int

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: x-plane dataref communication problem

#3 Post by Keith Baxter »

Hi and welcome to the forum,

We are going to help you by guiding you the right way.

Please post code within the </> button ^ so that it makes it easier for all to follow.

First thing is ...
Is there a command that changes the state of the switch?
Some datarefs are writable but only change state if triggered by a command.

Keith
Last edited by Keith Baxter on Thu Jun 10, 2021 6:57 pm, edited 1 time in total.
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

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

Re: x-plane dataref communication problem

#4 Post by Ralph »

You can check the type with the datareftool:
https://github.com/leecbaker/datareftool/releases

If it contains a . then it's a float, if not then it's probably an integer.

whbossert
Posts: 9
Joined: Thu Jun 10, 2021 2:42 pm

Re: x-plane dataref communication problem

#5 Post by whbossert »

Thanks so much. It WAS a FLOAT. I was jumping between types, with and int for the switch position and a float for the dataref and sending the wrong type to the wrong place. Oh, it's so tough to be starting out... You guys are great!

lonespace
Posts: 64
Joined: Wed Mar 25, 2020 1:58 am

Re: x-plane dataref communication problem

#6 Post by lonespace »

As someone who basically only develops for Arduino and similar embedded types, it sometimes boggles my mind how careless some programmers can be with memory. A float for a switch position just seems so wasteful, but it’s actually pretty common from what I’ve seen

User avatar
BradyBrother100
Posts: 54
Joined: Tue Oct 13, 2020 4:21 pm
Location: United States MDT

Re: x-plane dataref communication problem

#7 Post by BradyBrother100 »

I've wondered that too. A switch is never going to be in a half position. But, I bet there is some reason why they use FLOATs instead of INTs.

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

Re: x-plane dataref communication problem

#8 Post by Sling »

Yes sometimes it’s a waste. However sometimes a FLOAT is used to indicate position. In this case it’s for a door and a door can be part way open, hence it’s not digital. They tend to be used for other similar things such as cowl flaps, speed brakes, choke etc.

Post Reply