Jump to content
The simFlight Network Forums

Problem using lvar


jfri57

Recommended Posts

In my Milviz C310 I have some controls where the documentation list L:lvars for example left and right fuel pumps.
The documentation list this
Left Fuel Pump Switch (L:C310_SW_FUEL_PUMP_LEFT, enum) 0=Up ,1=Center ,2=Down
Right Fuel Pump Switch (L:C310_SW_FUEL_PUMP_RIGHT, enum) 0=Up, 1=Center, 2=Down
Primer Switch (L:C310_SW_PRIMER, enum) 0=Left, 1=Center, 2=Right

I understand that I need these entries in the fsuipic.ini som it contains these lines

[LvarOffsets.C310]
0=L:C310_SW_FUEL_PUMP_LEFT=0x66C0
1=L:C310_SW_FUEL_PUMP_RIGHT=0x66C1
2=L:C310_SW_PRIMER=0x66C2

Then I find it difficult to know what to do

I get the impression that I must create a macro file so I have made one which is attached.
Is that correct ?

Then I don't understand what to do ? How do I make a button to perform the actions ?

C310_SW_FUEL_PUMP_LEFT.mcy

Link to comment
Share on other sites

8 hours ago, jfri57 said:

I understand that I need these entries in the fsuipic.ini som it contains these lines

[LvarOffsets.C310]
0=L:C310_SW_FUEL_PUMP_LEFT=0x66C0
1=L:C310_SW_FUEL_PUMP_RIGHT=0x66C1
2=L:C310_SW_PRIMER=0x66C2

Then I find it difficult to know what to do

Those entries are incorrect - you also need to specify the size if the offset, This tells me that you have not read (or have not understood) the documentation.
I therefore suggest that you read the documentation on adding lvars to offsets which is in the WASM section of the Advanced User guide. This should also tell you what you need to assign your button to.

Please always check the documentation first before requesting support.

John

Link to comment
Share on other sites

15 hours ago, John Dowson said:

Those entries are incorrect - you also need to specify the size if the offset, This tells me that you have not read (or have not understood) the documentation.
I therefore suggest that you read the documentation on adding lvars to offsets which is in the WASM section of the Advanced User guide. This should also tell you what you need to assign your button to.

Please always check the documentation first before requesting support.

John

I had read the documentation otherwise I would not be able to suggest the lines I posted.

I have changed those incorrect entries. Also changed my macro file where I discovered several errors in it and its filetype.
Now I have been able to get the two fuel pumps to work as I intended. One thing that seem a little strange is that my macrofile only contains entries for the left pump but still the right pump could also be assigned to another switch. My new macro file is attached. I might be missing what the macro files need to contain. I first thought a separate macro file was needed for each switch

C310FUELPUMPLEFT.mcro

Link to comment
Share on other sites

11 hours ago, jfri57 said:

One thing that seem a little strange is that my macrofile only contains entries for the left pump but still the right pump could also be assigned to another switch. My new macro file is attached. I might be missing what the macro files need to contain. I first thought a separate macro file was needed for each switch

Quote

[MACROS]
0=L:C310_SW_FUEL_PUMP_LEFT
0.1=L:C310_SW_FUEL_PUMP_LEFT=SET,1
0.1=L:C310_SW_FUEL_PUMP_LEFT=SET,2

From the Advanced User guide, P37:

Quote

The multi-line macro format can still be used with the Lvar macros, as follows:
    N=L:name
    N.1=action1
    N.2=action2
    ... etc.
However, unlike the usual multi-line macros, those using an L:Var cannot be mixed with any other parameter types or other L:Vars.
The single L:Var identifier is the actual macro name as well, so this prevents such complexity

Your macro file is therefore (obviously, I hope...) not correct for various reasons, and should be

Quote

[Macros]
1=L:C310_SW_FUEL_PUMP_LEFT
1.1=SET,1
1.2=SET,2

and if you want to add the right pump. it would be:

Quote

[Macros]
1=L:C310_SW_FUEL_PUMP_LEFT
1.1=SET,1
1.2=SET,2
2=L:C310_SW_FUEL_PUMP_RIGHT
2.1=SET,1
2.2=SET,2

Alternatively, it is probably easier to use presets to control lvars these days as they are more powerful. To create presets for these, create a file (in your FSUIPC7 installation folder) called myevents.txt, and add the following content:

Quote

Milviz_C310_Left_Fuel_Pump#$Param (>L:C310_SW_FUEL_PUMP_LEFT)
Milviz_C310_Right_Fuel_Pump#$Param (>
L:C310_SW_FUEL_PUMP_RIGHT)

 You can then assign to the controls Preset:Milviz C310 Left Fuel Pump and  Preset:Milviz C310 Right Fuel Pump giving an appropriate parameter in the assignment.
Again, i advise you to consult the documentation provided.

11 hours ago, jfri57 said:

I had read the documentation otherwise I would not be able to suggest the lines I posted.

Maybe, but the format of the files you are posting is obviously incorrect if you check the format against that specified in the documentation. I am suggesting that if you find that things are not working, check the format against the documentation before posting. This would save us both some time!

John

Link to comment
Share on other sites

2 hours ago, John Dowson said:

 

Your macro file is therefore (obviously, I hope...) not correct for various reasons, and should be

John

If they are not correct I find a little bit strange that the fuel pumps switches are now working as intended for me

Link to comment
Share on other sites

10 minutes ago, jfri57 said:

I find a little bit strange that the fuel pumps switches are now working as intended for me

So do I...it may be ok to duplicate the lvar name (not sure), but your index numbers are '0.1' and '0.1' when they should be '0.1' and '0.2', so there is no way to distinguish between those entries. And as they are both setting the (same) lvar to different values, I do not know which one will be used, although logging should tell you.
Better to use the correct format, or switch to using presets, as advised.

John

Link to comment
Share on other sites

  • 3 weeks later...

I have problem with this again. Some of my assignments does not work. My log files contains these lines

240860 **** Lvar 'C310_SW_PRIMER' not found: cannot add to offset 0x66C2
   240860 **** Lvar 'C310_SW_COWL_LEFT' not found: cannot add to offset 0x66C4
   240860 **** Lvar 'C310_SW_COWL_RIGHT' not found: cannot add to offset 0x66C5

but my fsuipc7.ini has these lines

[LvarOffsets.C310]
0=L:C310_SW_FUEL_PUMP_LEFT=UB0x66C0
1=L:C310_SW_FUEL_PUMP_RIGHT=UB0x66C1
2=L:C310_SW_PRIMER=UB0x66C2
3=L:C310_SW_LIGHTS_LANDING=UB0x66C3
4=L:C310_SW_COWL_LEFT=UB0x66C4
5=L:C310_SW_COWL_RIGHT=UB0x66C5

And I have not edited these files since my last flight with this C310 plane and then it worked as intended.

EDIT When I restarted MSFS it did work. But why not every time. And what could be causing the failure to find the Lvars ?

Edited by jfri57
New information
Link to comment
Share on other sites

1 hour ago, jfri57 said:

EDIT When I restarted MSFS it did work. But why not every time. And what could be causing the failure to find the Lvars ?

It will be a timing issue - the lvars you are using were not yet available when the WASM module scanned for available lvars. You need to increase the LvarScanDelay WASM ini parameter (i.e. in the FSUIPC_WASM.ini and not in the FSUIP7.ini). See the Advanced User guide for details - I recommend you set this in an FSUIPC_WASM.ini in the WASM permanent storage area, not in the one under your Community folder as this will get overwritten (again, see the Advanced User Guide for details).

John

Link to comment
Share on other sites

46 minutes ago, John Dowson said:

It will be a timing issue - the lvars you are using were not yet available when the WASM module scanned for available lvars. You need to increase the LvarScanDelay WASM ini parameter (i.e. in the FSUIPC_WASM.ini and not in the FSUIP7.ini). See the Advanced User guide for details - I recommend you set this in an FSUIPC_WASM.ini in the WASM permanent storage area, not in the one under your Community folder as this will get overwritten (again, see the Advanced User Guide for details).

John

I copied the fsuipc_wasm.ini to the suggested work folder. I found no LvarScanDelay entry in it so I inserted one with value 7 (since I should increase the value which seem be 5 by default) I hope things were correctly understood

Link to comment
Share on other sites

10 hours ago, jfri57 said:

I copied the fsuipc_wasm.ini to the suggested work folder. I found no LvarScanDelay entry in it so I inserted one with value 7 (since I should increase the value which seem be 5 by default) I hope things were correctly understood

Yes, that sounds correct.
The value for this parameter really depends upon what aircraft you are flying (as well as which lvars you are using). For example, in the FBW A320 you need to set to somewhere between 45-60 seconds (or more) to load most/all lvars. The more complex the aircraft, the longer it takes for the lvars to be initialised.
If you see that the lvars you are using are not available, you can also either reload the WASM (Add-ons->WASM->Reload) or re-connect to MSFS (MSFS->Disconnect, MSDS->Connect).

John

Link to comment
Share on other sites

  • 4 weeks later...
On 6/18/2022 at 12:41 PM, John Dowson said:

Alternatively, it is probably easier to use presets to control lvars these days as they are more powerful. To create presets for these, create a file (in your FSUIPC7 installation folder) called myevents.txt, and add the following content:

 You can then assign to the controls Preset:Milviz C310 Left Fuel Pump and  Preset:Milviz C310 Right Fuel Pump giving an appropriate parameter in the assignment.
Again, i advise you to consult the documentation provided.

I am now trying to apply that method on my newly purchased SWS Kodiak 100 and in some instances it does not work.

First in the FSUIPC control menu I see that there already are some presets for the Kodiak to choose from. I did so and got the Aux bus and fuel pump to work. But doing the same thing for Ignition did not work. Why not I am doing the same thing as with the aux bus.

Finally for the starter switch there are no preset already available so I created a file myevents.txt according to your instructions. In  it I have the line

Kodiak_Starter_Switch#$(>L:SWS_ENGINE_Switch_Starter_ThreeState_1)

Then I assign a three way switch on my TM Hotas Warthog throttle to it. This does not work and I don't see way.
My fsuipc.ini is attached

EDIT I discovered that I missed the param word, my line in myevents are corrected to
Kodiak_Starter_Switch#$Param(>L:SWS_ENGINE_Switch_Starter_ThreeState_1)

But that did not help. It still does not work

FSUIPC7.ini

Edited by jfri57
New information
Link to comment
Share on other sites

13 hours ago, jfri57 said:

Finally for the starter switch there are no preset already available

Looking at the MF HubHop site, I see 3 presets available for the Kodiak 100 starter switch: Starter Switch Off, Starter Switch Lo, Starter Switch Hi.
These use the same lvar that your preset is using - L:SWS_ENGINE_Switch_Starter_ThreeState_1.

There are a few other things you can check:
   - when you change the lvar value, does that stick (i.e. if you red/log the value afterwards, does it have thee value that you have set)?
   - when you change the state of the starter switch un the UI, does the lvar value change? Are any other events logged?
   - try setting the lvar using the WASM->Addons-<Execute Calculator Code menu option to set/change the lvar value. If that works, then there is a problem in your assignments. 

However, remember FSUIPC only provides the mechanism for you to assign such calculator code to controllers and have it sent to the FS for action. If the calculator code/preset doesn't work, I cannot really help with this. especially i do not own the aircraft. I cannot possible know how all functions work for all aircraft...
If FSUIPC7 is functioning correctly, i.e. the code you assigned is being sent to the FS/aircraft (which logging would tell you), and the calculator code (or whatever you are using) is not working, then the best place to ask about this is either on the Kodiak discord server (
https://discord.com/invite/Ns7GkWW) or on the MobiFlight Discord server.

In this post over on avsim, one user indicated he could get most things working using lvars/calculator code except for the ignition switch, while another user indicates that he got everything working with the help of MobiFlight: https://www.avsim.com/forums/topic/614394-sws-kodiak-100-control-problems

John

Link to comment
Share on other sites

4 hours ago, John Dowson said:

Looking at the MF HubHop site, I see 3 presets available for the Kodiak 100 starter switch: Starter Switch Off, Starter Switch Lo, Starter Switch Hi.
These use the same lvar that your preset is using - L:SWS_ENGINE_Switch_Starter_ThreeState_1.

There are a few other things you can check:
   - when you change the lvar value, does that stick (i.e. if you red/log the value afterwards, does it have thee value that you have set)?
   - when you change the state of the starter switch un the UI, does the lvar value change? Are any other events logged?
   - try setting the lvar using the WASM->Addons-<Execute Calculator Code menu option to set/change the lvar value. If that works, then there is a problem in your assignments. 

However, remember FSUIPC only provides the mechanism for you to assign such calculator code to controllers and have it sent to the FS for action. If the calculator code/preset doesn't work, I cannot really help with this. especially i do not own the aircraft. I cannot possible know how all functions work for all aircraft...
If FSUIPC7 is functioning correctly, i.e. the code you assigned is being sent to the FS/aircraft (which logging would tell you), and the calculator code (or whatever you are using) is not working, then the best place to ask about this is either on the Kodiak discord server (
https://discord.com/invite/Ns7GkWW) or on the MobiFlight Discord server.

In this post over on avsim, one user indicated he could get most things working using lvars/calculator code except for the ignition switch, while another user indicates that he got everything working with the help of MobiFlight: https://www.avsim.com/forums/topic/614394-sws-kodiak-100-control-problems

John

I don't see any presets for Kodiak 100 starter switch.
When I manually change the lvar value from inside FSUIPC the switch moves in the cockpit.
When execute calculator code from WASM
Kodiak_Starter_Switch#$Param(>L:SWS_ENGINE_Switch_Starter_ThreeState_1)
nothing happens

Link to comment
Share on other sites

2 hours ago, jfri57 said:

I don't see any presets for Kodiak 100 starter switch.

Then you are not searching/looking correctly:

image.thumb.png.6e85e0c0d9c0d1beddcb1d6d6cc9b5a2.png

2 hours ago, jfri57 said:

When I manually change the lvar value from inside FSUIPC the switch moves in the cockpit.

How are you doing this? This indicates that changing the lvar has the desired affect. But if thats the case, I don't know what your issue is as you have also said that this is not working, so I'm confused now...

2 hours ago, jfri57 said:

When execute calculator code from WASM
Kodiak_Starter_Switch#$Param(>L:SWS_ENGINE_Switch_Starter_ThreeState_1)
nothing happens

Of course not! $Param can only be used in preset definitions, when the value will be substituted with the parameter you enter when you assign. If using calculator code directly, you need to put in the value. So, try
    0 (>L:SWS_ENGINE_Switch_Starter_ThreeState_1)
or
    1 (>L:SWS_ENGINE_Switch_Starter_ThreeState_1)
or
    2 (>L:SWS_ENGINE_Switch_Starter_ThreeState_1)

But there is no need if you have already confirmed that changing the lvar has the desired affect. 

If you need further assistance, please attach a relevant FSUIPC7.log file (i.e. with Event logging and Button & Key logging activated, and also Debug level logging activated for the WAPI, and showing your issue) together with your latest FSUIPC7.ini file.

Also, maybe try reading the section on the WASM module and how to use presets, in the Advanced User guide.

John 

Link to comment
Share on other sites

1 hour ago, John Dowson said:

Then you are not searching/looking correctly:

image.thumb.png.6e85e0c0d9c0d1beddcb1d6d6cc9b5a2.png

How are you doing this? This indicates that changing the lvar has the desired affect. But if thats the case, I don't know what your issue is as you have also said that this is not working, so I'm confused now...

Of course not! $Param can only be used in preset definitions, when the value will be substituted with the parameter you enter when you assign. If using calculator code directly, you need to put in the value. So, try
    0 (>L:SWS_ENGINE_Switch_Starter_ThreeState_1)
or
    1 (>L:SWS_ENGINE_Switch_Starter_ThreeState_1)
or
    2 (>L:SWS_ENGINE_Switch_Starter_ThreeState_1)

But there is no need if you have already confirmed that changing the lvar has the desired affect. 

If you need further assistance, please attach a relevant FSUIPC7.log file (i.e. with Event logging and Button & Key logging activated, and also Debug level logging activated for the WAPI, and showing your issue) together with your latest FSUIPC7.ini file.

Also, maybe try reading the section on the WASM module and how to use presets, in the Advanced User guide.

John 

I was not using that HubHop which I am unfamiliar with. I have found it now and did find those presets. I tried the Add Preset button and Export button.

Regarding how I set the lvar manually. In FSUIPC7 I select Addons WASM Set lvar
and enter
SWS_ENGINE_Switch_Starter_threestate_10271
and a value for example 2 then press SET button
Then the switch moves in the cockpit

But when I select switch assignment and press my switch on throttle quadrant which is detected and then select a KODIAK listed preset like ignition or starter and a value then it does not work. So I still have an issue. The two files you asked for is attached

FSUIPC7.log FSUIPC7.ini

Link to comment
Share on other sites

1 hour ago, jfri57 said:

I was not using that HubHop which I am unfamiliar with.

You should familiarise yourself with that resource as it is the source of the presets in the events.txt file,  and can contain additional information on how to use a preset (e.g. some presets require an update to an MSFS aircraft xml config file to work properly). You can also download the latest preset file as new presets are being added, as well as existing ones updated, all the time.

1 hour ago, jfri57 said:

I tried the Add Preset button and Export button.

Why? You need to register (which you should) to use those features. 'Add Preset' allows you to add your own preset to share with others in the Community (check not already available before doing this!), and the Export button allows you to export the events.txt file, which you can use to replace the one in your FSUIPC7 installation folder.

1 hour ago, jfri57 said:

Regarding how I set the lvar manually. In FSUIPC7 I select Addons WASM Set lvar
and enter
SWS_ENGINE_Switch_Starter_threestate_10271
and a value for example 2 then press SET button
Then the switch moves in the cockpit

Ok, that makes sense and shows that the lvars are working.

You are using the presets KODIAK_100_IGNITION_SWITCH_ON (and _OFF, _TOGGLE). Your log shows that these are being triggered:

Quote

...
  1061750 Button changed: bRef=0, Joy=5 (E), Btn=16, Pressed
  1061750 [Buttons.Kodiak 100 Aviation Sans Frontieres] 14=PE,16,CPKODIAK_100_IGNITION_SWITCH_ON,1
  1061750 Executing preset 'KODIAK_100_IGNITION_SWITCH_ON' [6545]
...
  1062765 Button changed: bRef=0, Joy=5 (E), Btn=16, Released
  1062765 [Buttons.Kodiak 100 Aviation Sans Frontieres] 15=UE,16,CPKODIAK_100_IGNITION_SWITCH_OFF,0
  1062765 Executing preset 'KODIAK_100_IGNITION_SWITCH_OFF' [6544]
 

If you look at the code for those presets, they use the TURBINE_IGNITION_SWITCH_SET1 event, not the lvar. The description of these presets also says 'Intended for latching switch.'.

If presets don't work, then you need to ask about this on the MobiFlight Discord server - they manage the community-driven effort for these presets.
But, if you know that the lvars work, as you have tested them, why don't you just use the presets that use the lvars (Starter Switch Off/Lo/Hi) instead?
Or add the lvars to offsets and assign to the appropriate offset control instead, as you do with the C310?

Note that you are using an old version of FSUIPC7, v7.3.6. Please update to the latest version, v7.3.7. Only the latest version is supported. There is also a beta version available in the Announcements forum - v7.3.8b. I will release this in the coming days (hopefully, pending info I am waiting to receive from PMDG).

John

Link to comment
Share on other sites

2 hours ago, John Dowson said:

You are using the presets KODIAK_100_IGNITION_SWITCH_ON (and _OFF, _TOGGLE). Your log shows that these are being triggered:

If you look at the code for those presets, they use the TURBINE_IGNITION_SWITCH_SET1 event, not the lvar. The description of these presets also says 'Intended for latching switch.'.

If presets don't work, then you need to ask about this on the MobiFlight Discord server - they manage the community-driven effort for these presets.
But, if you know that the lvars work, as you have tested them, why don't you just use the presets that use the lvars (Starter Switch Off/Lo/Hi) instead?
 

John

I got the starter switch working after following your suggestion. 

But the ignition switch is still a problem. Selecting TURBINE_IGNITION_SWITCH_SET1 did not work

Link to comment
Share on other sites

12 hours ago, jfri57 said:

But the ignition switch is still a problem. Selecting TURBINE_IGNITION_SWITCH_SET1 did not work

I cannot help with this - either try asking on the Asobo SimWorks Studios  forum or ask on the MobiFlight discord forum about those KODIAK_100_IGNITION_SWITCH_* presets.

John

Link to comment
Share on other sites

I am very surprised that that macro is working...from the documentation:

Quote

The multi-line macro format can still be used with the Lvar macros, as follows:
          N=L:name
          N.1=action1
          N.2=action2
          ... etc.
However, unlike the usual multi-line macros, those using an L:Var cannot be mixed with any other parameter types or other L:Vars.
The single L:Var identifier is the actual macro name as well, so this prevents such complexity

 

Also, TURBINE_IGNITION_SWITCH_SET1 is an event (k-type variable) and not an lvar
Not 100% sure what that macro is actually doing due to these problems, but I suspect that, if anything, it will set the lvar L:SWS_ENGINE_Switch_Ignition_1 to 1 and then 0 (logging would tell).

John

Link to comment
Share on other sites

2 hours ago, John Dowson said:

I am very surprised that that macro is working...from the documentation:

Also, TURBINE_IGNITION_SWITCH_SET1 is an event (k-type variable) and not an lvar
Not 100% sure what that macro is actually doing due to these problems, but I suspect that, if anything, it will set the lvar L:SWS_ENGINE_Switch_Ignition_1 to 1 and then 0 (logging would tell).

John

Well my log file is attached here

FSUIPC7.log

Link to comment
Share on other sites

Your log only shows two offset control assignments on a button press and a release (same button), most probably setting the value of the lvar L:SWS_ENGINE_Switch_Ignition_1 (to 1 then 0), although I can't tell as I haven't seen your latest ini file:

Quote

...
   188953 Button changed: bRef=0, Joy=5 (E), Btn=16, Pressed
   188953 [Buttons.Kodiak 100 Aviation Sans Frontieres] 14=PE,16,Cx010066C6,x01
   188953 IPC Offsets Control: Ctrl=x0100, Length=1, Offset=66C6, Param=x1
...
   190719 Button changed: bRef=0, Joy=5 (E), Btn=16, Released
   190719 [Buttons.Kodiak 100 Aviation Sans Frontieres] 15=UE,16,Cx010066C6,x00
   190719 IPC Offsets Control: Ctrl=x0100, Length=1, Offset=66C6, Param=x0
 

I see no use of that macro file.

John

Link to comment
Share on other sites

5 hours ago, John Dowson said:

Your log only shows two offset control assignments on a button press and a release (same button), most probably setting the value of the lvar L:SWS_ENGINE_Switch_Ignition_1 (to 1 then 0), although I can't tell as I haven't seen your latest ini file:

I see no use of that macro file.

John

My latest ini file here

FSUIPC7.ini

Link to comment
Share on other sites

38 minutes ago, jfri57 said:

My latest ini file here

Ok - so that shows that the lvar L:SWS_ENGINE_Switch_Ignition_1 is being held in offset 0x66C6, and you have a button assigned to set the lvar value to 1 on press and 0 on release (as I suspected). Your macro file isn't being used. In fact, it can't be - as well as the contents being invalid, the filename contains more than 16 characters. From the Advanced User Guide, section on macro files:

Quote

It is important that the file name (xxxx.mcro) is limited to 16 characters maximum, (plus the ".mcro"). This will be used
as part of the name of the added controls in the drop-downs. Best to keep the names short and to the point—probably
the name of the program or program function for which the controls are being added.

 

But if this is working, then its not an issue. Just delete that duff macro file.

John

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.