Jump to content
The simFlight Network Forums

First attempt with Lua


Jacob Wiqvist

Recommended Posts

5 minutes ago, John Dowson said:

What does this mean? What is an 'And function'?

If a lua script doesn't work, activate logging for lua plugins and try and determine what the problem is from the log output.

 

God tip I will do that.

 

Maybe it is not called function.

 

But the "And" between 66E1 and 66F5 don't work?

Link to comment
Share on other sites

20 minutes ago, John Dowson said:

What does this mean? What is an 'And function'?

If a lua script doesn't work, activate logging for lua plugins and try and determine what the problem is from the log output.

 

function myFunction(offset, value)

 

    -- read 1st axis offset

     val1 = ipc.readSD(0x66F5)

    -- read 2nd axis offset

     val2 = ipc.readSD(0x66E1)

    -- read Ground Speed offset

     groundSpeed = ipc.readSD(0x02B4)

     -- convert groundSpeed to Knots

     groundSpeed = (groundSpeed / 65536) * 1.94384

 

   if val1 > 14000 and val2 > 14000 and groundSpeed < 20 then

        ipc.writeUB(0x66E9, 1)

   else

        ipc.writeUB(0x66E9, 0)

   end

 

end

 

(Unable to send code on my phone)

 

Also tested this: 

https://share.icloud.com/photos/0OkaoN7e_W6v96khJMdZD0cTg

 

Link to comment
Share on other sites

32 minutes ago, John Dowson said:

But thats just the function I gave you. I have still no idea what you are talking about. What do you mean by 'the "And" between 66E1 and 66F5 don't work'? What does 'don't work' actually mean? what is 'between'? What 'And'? You aren't making any sense to me.

When I press the brake pedal that sends data to offset 66F5 the Offset 66E9 change, from 0 to 1 witch is partly correct.

But when I push the brake pedal that sends data to 66E1 nothing happens.

 

What I want to happen is that I have to push bothe pedals to set 1 on 66E9.

 

And it should not matter if I  start pushing the left pedal that sends data to 66E1 or 66F5. The condition should be that bothe pedals should be pushed, and speed less then 20 knots.

 

When I  sad "and" between 66E1 and 66F5, don't work. I meant that the condition "and" dose not seem to do anything?

This line of code:

if val1 > 14000 and val2 > 14000 and groundSpeed < 20 then

 

It say if val1 and val2?

 

In my understanding the code should tak in to account both val1 and val2?

 

Link to comment
Share on other sites

That line of code is correct. Are you sure that your axis values are being written to the offsets correctly?
Why not log the values before the conditional to see what they are, i.e. add the following line
     ipc.log("0x66F5=" .. val1 .. ", 0x66E1=" .. val2.. ", groundSpeed =" .. groundSpeed )

Also check that you are calling event.offset for those two offsets.

 

Link to comment
Share on other sites

11 minutes ago, John Dowson said:

Also check that you are calling event.offset for those two offsets.

How do I do that in a correct way?

Is this the correct way? :

event.offset(0x66E1, "SD", "myFunction")

event.offset(0x66F5, "SD", "myFunction")

 

Is Ther any spacing I should be aware of, or careful with?

Link to comment
Share on other sites

I am very busy at the moment and do not have time for basic/beginner lua questions. Please just try things out for yourself. We provide plenty of documentation and examples. There are many basic lua tutorials on-line. I have already given you plenty of information to get you started. And of course that is the correct way - if the bit of software that is writing to those offsets is writing it as a 32 bit signed integer. If not, it may be writing it as a 16bit signed integer (as Pete said earlier), in which case you need to change that to "SW" and change the read functions for those offsets from readSD to readSW. You have to make sure that you are reading offsets as the same type/length as you write them.

 

Link to comment
Share on other sites

As well as taking john's good advice, do make good use of the tools at your disposal so you can see what is going on. As well as using Lua tracing (which can sometimes be a bit mind-boggling as it logs every step), try using the ipc.log function to just log details of what you read and write, and also make good use of the FSUIPC monitor facilities (right-hand side of the Logging tab) where you can monitor (to the FSUIPC log) the values of up to 4 offsets of whatever type they are.

To make things easier to see, run the Sim in Windowed mode and enable the FSUIPC console log. You will then see these logging entries in real time, on screen.

Pete

 

Link to comment
Share on other sites

On 2/17/2021 at 3:05 PM, Pete Dowson said:

As well as taking john's good advice, do make good use of the tools at your disposal so you can see what is going on. As well as using Lua tracing (which can sometimes be a bit mind-boggling as it logs every step), try using the ipc.log function to just log details of what you read and write, and also make good use of the FSUIPC monitor facilities (right-hand side of the Logging tab) where you can monitor (to the FSUIPC log) the values of up to 4 offsets of whatever type they are.

To make things easier to see, run the Sim in Windowed mode and enable the FSUIPC console log. You will then see these logging entries in real time, on screen.

Pete

 

I can't get it to work?

The values are fluctuating from the Lua script. But the input signal seems fairly stable?

 

FSUIPC log

   118890 LUA.1: 16255
   118906 LUA.1: SOLENOID 1
   118937 LUA.1: HandleParkingBrake end:
   118969 LUA.1: HandleParkingBrake start:
   118984 LUA.1: rightRudderPedalValue
   119000 LUA.1: 32767
   119015 LUA.1: leftRudderPedalValue
   119031 LUA.1: 16255
   119047 LUA.1: SOLENOID 1
   119078 LUA.1: HandleParkingBrake end:
   119109 LUA.1: HandleParkingBrake start:
   119125 LUA.1: rightRudderPedalValue
   119140 LUA.1: 32767
   119156 LUA.1: leftRudderPedalValue
   119172 LUA.1: 16255
   119187 LUA.1: SOLENOID 1
   119219 LUA.1: HandleParkingBrake end:
   119250 LUA.1: HandleParkingBrake start:
   119265 LUA.1: rightRudderPedalValue
   119281 LUA.1: 32767
   119297 LUA.1: leftRudderPedalValue
   119312 LUA.1: 16255
   119328 LUA.1: SOLENOID 1
   119359 LUA.1: HandleParkingBrake end:
   119390 LUA.1: HandleParkingBrake start:
   119406 LUA.1: rightRudderPedalValue
   119422 LUA.1: 32767
   119437 LUA.1: leftRudderPedalValue
   119453 LUA.1: 16255
   119469 LUA.1: SOLENOID 1
   119484 LUA.1: HandleParkingBrake end:
   119515 LUA.1: HandleParkingBrake start:
   119531 LUA.1: rightRudderPedalValue
   119547 LUA.1: 32767
   119562 LUA.1: leftRudderPedalValue
   119578 LUA.1: 16255
   119594 LUA.1: SOLENOID 1
   119625 LUA.1: HandleParkingBrake end:
   119656 LUA.1: HandleParkingBrake start:
   119672 LUA.1: rightRudderPedalValue
   119687 LUA.1: 32767
   119703 LUA.1: leftRudderPedalValue
   119719 LUA.1: 16255
   119734 LUA.1: SOLENOID 1
   119765 LUA.1: HandleParkingBrake end:
   119797 LUA.1: HandleParkingBrake start:
   119812 LUA.1: rightRudderPedalValue
   119828 LUA.1: 32767
   119844 LUA.1: leftRudderPedalValue
   119859 LUA.1: 16255
   119875 LUA.1: SOLENOID 1
   119906 LUA.1: HandleParkingBrake end:
   119937 LUA.1: HandleParkingBrake start:
   119953 LUA.1: rightRudderPedalValue
   119969 LUA.1: 32767
   119984 LUA.1: leftRudderPedalValue
   120000 LUA.1: 16255
   120015 LUA.1: SOLENOID 1
   120047 LUA.1: HandleParkingBrake end:
   120078 LUA.1: HandleParkingBrake start:
   120094 LUA.1: rightRudderPedalValue
   120109 LUA.1: 32767
   120125 LUA.1: leftRudderPedalValue
   120140 LUA.1: 16255
   120156 LUA.1: SOLENOID 1
   120187 LUA.1: HandleParkingBrake end:
   120219 LUA.1: HandleParkingBrake start:
   120234 LUA.1: rightRudderPedalValue
   120250 LUA.1: 32767
   120265 LUA.1: leftRudderPedalValue
   120281 LUA.1: 16255
   120297 LUA.1: SOLENOID 1
   120328 LUA.1: HandleParkingBrake end:
   120359 LUA.1: HandleParkingBrake start:
   120375 LUA.1: rightRudderPedalValue
   120390 LUA.1: 32767
   120406 LUA.1: leftRudderPedalValue
   120422 LUA.1: 16255
   120437 LUA.1: SOLENOID 1
   120453 LUA.1: HandleParkingBrake end:
   120484 LUA.1: HandleParkingBrake start:
   120500 LUA.1: rightRudderPedalValue
   120515 LUA.1: 32767
   120531 Monitor IPC:66F6 (S16) = 15743
   120531 LUA.1: leftRudderPedalValue
   120547 Monitor IPC:66F6 (S16) = 15678
   120547 LUA.1: 16255
   120562 Monitor IPC:66F5 (S16) = 16127
   120562 LUA.1: SOLENOID 1
   120578 Monitor IPC:66F6 (S16) = 16383
   120594 Monitor IPC:66F5 (S16) = -1
   120594 LUA.1: HandleParkingBrake end:
   120609 Monitor IPC:66F6 (S16) = 14975
   120625 Monitor IPC:66F5 (S16) = 32639
   120625 LUA.1: HandleParkingBrake start:
   120640 LUA.1: rightRudderPedalValue
   120640 Monitor IPC:66F6 (S16) = 11007
   120656 Monitor IPC:66F5 (S16) = -256
   120656 LUA.1: -129
   120672 LUA.1: leftRudderPedalValue
   120687 Monitor IPC:66F6 (S16) = 5760
   120687 LUA.1: 13055
   120703 Monitor IPC:66F5 (S16) = -32640
   120703 Monitor IPC:66F6 (S16) = 1664
   120703 LUA.1: SOLENOID 0
   120719 Monitor IPC:66F5 (S16) = -32516
   120734 LUA.1: HandleParkingBrake end:
   120750 Monitor IPC:66F6 (S16) = -7672
   120765 Monitor IPC:66F5 (S16) = 2056
   120765 LUA.1: HandleParkingBrake start:
   120781 LUA.1: rightRudderPedalValue
   120781 Monitor IPC:66F6 (S16) = -15474
   120797 LUA.1: -18473
   120797 Monitor IPC:66F5 (S16) = -28993
   120812 Monitor IPC:66F6 (S16) = -16384
   120812 LUA.1: leftRudderPedalValue
   120812 Monitor IPC:66F5 (S16) = 41
   120828 LUA.1: -12873
   120844 Monitor IPC:66F6 (S16) = -16189
   120844 LUA.1: SOLENOID 0
   120859 Monitor IPC:66F5 (S16) = -15604
   120875 LUA.1: HandleParkingBrake end:
   120875 Monitor IPC:66F6 (S16) = -16192
   120890 Monitor IPC:66F5 (S16) = -16384
   120906 LUA.1: HandleParkingBrake start:
   120922 LUA.1: rightRudderPedalValue
   120937 LUA.1: -16384
   120953 LUA.1: leftRudderPedalValue
   120969 LUA.1: -16192
   120984 LUA.1: SOLENOID 0
   121015 LUA.1: HandleParkingBrake end:
   121047 LUA.1: HandleParkingBrake start:
   121062 LUA.1: rightRudderPedalValue
   121078 LUA.1: -16384
   121094 LUA.1: leftRudderPedalValue
   121109 LUA.1: -16192
   121125 LUA.1: SOLENOID 0
   121156 LUA.1: HandleParkingBrake end:
   121187 LUA.1: HandleParkingBrake start:
   121203 LUA.1: rightRudderPedalValue
   121219 LUA.1: -16384
   121234 LUA.1: leftRudderPedalValue
   121250 LUA.1: -16192
   121265 LUA.1: SOLENOID 0
   121297 LUA.1: HandleParkingBrake end:
   121328 LUA.1: HandleParkingBrake start:
   121344 LUA.1: rightRudderPedalValue
   121359 LUA.1: -16384
   121375 LUA.1: leftRudderPedalValue
   121390 LUA.1: -16192
   121406 LUA.1: SOLENOID 0
   121422 LUA.1: HandleParkingBrake end:
   121453 LUA.1: HandleParkingBrake start:
   121469 LUA.1: rightRudderPedalValue
   121484 LUA.1: -16384
   121500 LUA.1: leftRudderPedalValue
   121515 LUA.1: -16192
   121531 LUA.1: SOLENOID 0
   121562 LUA.1: HandleParkingBrake end:
   121594 LUA.1: HandleParkingBrake start:
   121609 LUA.1: rightRudderPedalValue
   121625 Monitor IPC:66F6 (S16) = -16191
   121625 LUA.1: -16384
   121640 Monitor IPC:66F5 (S16) = -16124
   121640 LUA.1: leftRudderPedalValue
   121656 Monitor IPC:66F6 (S16) = -16188
   121656 LUA.1: -16192
   121672 Monitor IPC:66F5 (S16) = -15214
   121672 LUA.1: SOLENOID 0
   121687 Monitor IPC:66F6 (S16) = -16185
   121703 LUA.1: HandleParkingBrake end:
   121703 Monitor IPC:66F5 (S16) = -14433
   121703 Monitor IPC:66F6 (S16) = -16174
   121719 Monitor IPC:66F5 (S16) = -11573
   121734 LUA.1: HandleParkingBrake start:
   121750 Monitor IPC:66F6 (S16) = -16168
   121750 LUA.1: rightRudderPedalValue
   121765 Monitor IPC:66F5 (S16) = -10012
   121765 LUA.1: -10012
   121781 Monitor IPC:66F6 (S16) = -15214
   121781 LUA.1: leftRudderPedalValue
   121797 Monitor IPC:66F5 (S16) = -28030
   121797 LUA.1: -16168
   121797 Monitor IPC:66F6 (S16) = -13523
   121812 Monitor IPC:66F5 (S16) = 11540
   121812 LUA.1: SOLENOID 0
   121828 Monitor IPC:66F6 (S16) = -12353
   121844 LUA.1: HandleParkingBrake end:
   121844 Monitor IPC:66F5 (S16) = -16473
   121875 Monitor IPC:66F6 (S16) = -10533
   121875 LUA.1: HandleParkingBrake start:
   121890 Monitor IPC:66F5 (S16) = -9411
   121890 Monitor IPC:66F6 (S16) = -10272
   121890 LUA.1: rightRudderPedalValue
   121906 Monitor IPC:66F5 (S16) = -8123
   121906 LUA.1: -8123
   121906 Monitor IPC:66F6 (S16) = -9232
   121922 Monitor IPC:66F5 (S16) = -3873
   121922 LUA.1: leftRudderPedalValue
   121937 LUA.1: -10272
   121937 Monitor IPC:66F6 (S16) = -7932
   121953 LUA.1: SOLENOID 0
   121953 Monitor IPC:66F5 (S16) = 1276
   121984 Monitor IPC:66F6 (S16) = -6372
   121984 LUA.1: HandleParkingBrake end:
   121984 Monitor IPC:66F5 (S16) = 7168
   122015 LUA.1: HandleParkingBrake start:
   122015 Monitor IPC:66F6 (S16) = -4941
   122031 Monitor IPC:66F5 (S16) = -19584
   122031 LUA.1: rightRudderPedalValue
   122047 LUA.1: -19584
   122047 Monitor IPC:66F6 (S16) = -4031
   122062 LUA.1: leftRudderPedalValue
   122062 Monitor IPC:66F5 (S16) = 16768
   122062 Monitor IPC:66F6 (S16) = -3251
   122078 LUA.1: -4941
   122078 Monitor IPC:66F5 (S16) = 19840
   122094 Monitor IPC:66F6 (S16) = -2861
   122094 LUA.1: SOLENOID 0
   122094 Monitor IPC:66F5 (S16) = -11520
   122109 Monitor IPC:66F6 (S16) = -2341
   122109 Monitor IPC:66F5 (S16) = -9344
   122125 LUA.1: HandleParkingBrake end:
   122140 Monitor IPC:66F6 (S16) = -1691
   122156 LUA.1: HandleParkingBrake start:
   122156 Monitor IPC:66F5 (S16) = 25984
   122172 LUA.1: rightRudderPedalValue
   122172 Monitor IPC:66F6 (S16) = 1152
   122187 LUA.1: 25984
   122187 Monitor IPC:66F5 (S16) = -32641
   122203 Monitor IPC:66F6 (S16) = 2048
   122203 LUA.1: leftRudderPedalValue
   122203 Monitor IPC:66F5 (S16) = 127
   122219 Monitor IPC:66F6 (S16) = 3200
   122219 LUA.1: -1691
   122219 Monitor IPC:66F5 (S16) = -32513
   122234 LUA.1: SOLENOID 0
   122250 Monitor IPC:66F6 (S16) = 6272
   122265 LUA.1: HandleParkingBrake end:
   122265 Monitor IPC:66F6 (S16) = 7168
   122281 Monitor IPC:66F5 (S16) = 255
   122297 LUA.1: HandleParkingBrake start:
   122297 Monitor IPC:66F6 (S16) = 9215
   122312 LUA.1: rightRudderPedalValue
   122312 Monitor IPC:66F5 (S16) = -1
   122328 LUA.1: -1
   122344 LUA.1: leftRudderPedalValue
   122344 Monitor IPC:66F6 (S16) = 12159
   122344 Monitor IPC:66F5 (S16) = 32767
   122359 LUA.1: 9215
   122359 LUA.1: SOLENOID 0
   122375 Monitor IPC:66F6 (S16) = 13823
   122390 Monitor IPC:66F5 (S16) = -1
   122390 Monitor IPC:66F6 (S16) = 14463
   122390 LUA.1: HandleParkingBrake end:
   122406 Monitor IPC:66F5 (S16) = 32767
   122406 Monitor IPC:66F6 (S16) = 14847
   122422 Monitor IPC:66F5 (S16) = -1
   122422 LUA.1: HandleParkingBrake start:
   122437 LUA.1: rightRudderPedalValue
   122437 Monitor IPC:66F6 (S16) = 15999
   122453 Monitor IPC:66F5 (S16) = 32767
   122453 LUA.1: -1
   122469 LUA.1: leftRudderPedalValue
   122484 Monitor IPC:66F6 (S16) = 16383
   122484 LUA.1: 15615
   122500 Monitor IPC:66F5 (S16) = -1
   122500 LUA.1: SOLENOID 0
   122531 LUA.1: HandleParkingBrake end:
   122562 LUA.1: HandleParkingBrake start:
   122578 LUA.1: rightRudderPedalValue
   122594 LUA.1: -1
   122609 LUA.1: leftRudderPedalValue
   122625 LUA.1: 16383
   122640 LUA.1: SOLENOID 0
   122672 LUA.1: HandleParkingBrake end:
   122703 LUA.1: HandleParkingBrake start:
   122719 LUA.1: rightRudderPedalValue
   122734 LUA.1: -1
   122750 LUA.1: leftRudderPedalValue
   122765 LUA.1: 16383
   122781 LUA.1: SOLENOID 0
   122812 LUA.1: HandleParkingBrake end:
   122844 LUA.1: HandleParkingBrake start:
   122859 LUA.1: rightRudderPedalValue
   122875 LUA.1: -1
   122890 LUA.1: leftRudderPedalValue
   122906 LUA.1: 16383
   122922 LUA.1: SOLENOID 0
   122953 LUA.1: HandleParkingBrake end:
   122984 LUA.1: HandleParkingBrake start:
   123000 LUA.1: rightRudderPedalValue
   123015 LUA.1: -1
   123031 LUA.1: leftRudderPedalValue
   123047 LUA.1: 16383
   123062 LUA.1: SOLENOID 0
   123094 LUA.1: HandleParkingBrake end:
   123125 LUA.1: HandleParkingBrake start:
   123140 LUA.1: rightRudderPedalValue
   123156 LUA.1: -1
   123172 LUA.1: leftRudderPedalValue
   123187 LUA.1: 16383
   123203 LUA.1: SOLENOID 0
   123234 LUA.1: HandleParkingBrake end:
   123265 LUA.1: HandleParkingBrake start:
   123265 Monitor IPC:66F6 (S16) = 16190
   123281 LUA.1: rightRudderPedalValue
   123281 Monitor IPC:66F5 (S16) = 15999
   123297 LUA.1: 15999
   123297 Monitor IPC:66F6 (S16) = 16175
   123312 LUA.1: leftRudderPedalValue
   123312 Monitor IPC:66F5 (S16) = 12287
   123328 LUA.1: 16190
   123328 Monitor IPC:66F6 (S16) = 16161
   123328 LUA.1: SOLENOID 1
   123359 Monitor IPC:66F5 (S16) = 8703
   123359 LUA.1: HandleParkingBrake end:
   123375 Monitor IPC:66F6 (S16) = 15743
   123390 Monitor IPC:66F5 (S16) = 32569
   123390 Monitor IPC:66F6 (S16) = 15103
   123390 LUA.1: HandleParkingBrake start:
   123406 Monitor IPC:66F5 (S16) = -244
   123406 LUA.1: rightRudderPedalValue
   123422 Monitor IPC:66F6 (S16) = 13951
   123422 Monitor IPC:66F5 (S16) = 32585
   123422 LUA.1: -9492
   123437 LUA.1: leftRudderPedalValue
   123453 Monitor IPC:66F6 (S16) = 12415
   123453 LUA.1: 15066
   123469 Monitor IPC:66F5 (S16) = 32671
   123469 LUA.1: SOLENOID 0
   123484 Monitor IPC:66F6 (S16) = 6656
   123500 Monitor IPC:66F5 (S16) = 151
   123500 Monitor IPC:66F6 (S16) = 2304
   123500 LUA.1: HandleParkingBrake end:
   123515 Monitor IPC:66F5 (S16) = 12
   123531 LUA.1: HandleParkingBrake start:
   123547 Monitor IPC:66F6 (S16) = -9492
   123547 LUA.1: rightRudderPedalValue
   123562 Monitor IPC:66F5 (S16) = -5120
   123562 LUA.1: -5120
   123578 Monitor IPC:66F6 (S16) = -16384
   123578 LUA.1: leftRudderPedalValue
   123594 Monitor IPC:66F5 (S16) = 0
   123594 LUA.1: -9492
   123609 LUA.1: SOLENOID 0
   123640 LUA.1: HandleParkingBrake end:
   123672 LUA.1: HandleParkingBrake start:
   123687 LUA.1: rightRudderPedalValue
   123703 LUA.1: 0
   123719 LUA.1: leftRudderPedalValue
   123734 LUA.1: -16384
   123750 LUA.1: SOLENOID 0
   123781 LUA.1: HandleParkingBrake end:
   123812 LUA.1: HandleParkingBrake start:
   123828 LUA.1: rightRudderPedalValue
   123844 LUA.1: 0
   123859 LUA.1: leftRudderPedalValue
   123875 LUA.1: -16384
   123890 LUA.1: SOLENOID 0
   123922 LUA.1: HandleParkingBrake end:
   123953 LUA.1: HandleParkingBrake start:
   123969 LUA.1: rightRudderPedalValue
   123984 LUA.1: 0
   124000 LUA.1: leftRudderPedalValue
   124015 LUA.1: -16384
   124031 LUA.1: SOLENOID 0
   124062 LUA.1: HandleParkingBrake end:
   124094 LUA.1: HandleParkingBrake start:
   124109 LUA.1: rightRudderPedalValue
   124125 LUA.1: 0
   124140 LUA.1: leftRudderPedalValue
   124156 LUA.1: -16384
   124172 LUA.1: SOLENOID 0
   124203 LUA.1: HandleParkingBrake end:
   124234 LUA.1: HandleParkingBrake start:
   124250 LUA.1: rightRudderPedalValue
   124265 LUA.1: 0
   124281 LUA.1: leftRudderPedalValue
   124297 LUA.1: -16384
   124297 LUA.1: SOLENOID 0
   124328 LUA.1: HandleParkingBrake end:
   124359 LUA.1: HandleParkingBrake start:
   124375 LUA.1: rightRudderPedalValue
   124390 LUA.1: 0
   124406 LUA.1: leftRudderPedalValue
   124422 LUA.1: -16384
   124437 LUA.1: SOLENOID 0
   124469 LUA.1: HandleParkingBrake end:
   124500 LUA.1: HandleParkingBrake start:
   124515 LUA.1: rightRudderPedalValue
   124531 LUA.1: 0
   124547 LUA.1: leftRudderPedalValue
   124562 LUA.1: -16384
   124578 LUA.1: SOLENOID 0
   124609 LUA.1: HandleParkingBrake end:
   124640 LUA.1: HandleParkingBrake start:
   124656 LUA.1: rightRudderPedalValue
   124672 LUA.1: 0
   124687 LUA.1: leftRudderPedalValue
   124703 LUA.1: -16384
   124719 LUA.1: SOLENOID 0
   124750 LUA.1: HandleParkingBrake end:
   124781 LUA.1: HandleParkingBrake start:
   124797 LUA.1: rightRudderPedalValue
   124812 LUA.1: 0
   124828 LUA.1: leftRudderPedalValue
   124844 LUA.1: -16384
   124859 LUA.1: SOLENOID 0
   124890 LUA.1: HandleParkingBrake end:
   124922 LUA.1: HandleParkingBrake start:
   124937 LUA.1: rightRudderPedalValue
   124953 LUA.1: 0
   124969 LUA.1: leftRudderPedalValue
   124984 LUA.1: -16384
   125000 LUA.1: SOLENOID 0
   125031 LUA.1: HandleParkingBrake end:
   125062 LUA.1: HandleParkingBrake start:
   125078 LUA.1: rightRudderPedalValue
   125094 LUA.1: 0
   125109 LUA.1: leftRudderPedalValue
   125125 LUA.1: -16384
   125140 LUA.1: SOLENOID 0
   125172 LUA.1: HandleParkingBrake end:
   125203 LUA.1: HandleParkingBrake start:
   125219 LUA.1: rightRudderPedalValue
   125234 LUA.1: 0
   125250 LUA.1: leftRudderPedalValue
   125265 LUA.1: -16384
   125265 LUA.1: SOLENOID 0
   125297 LUA.1: HandleParkingBrake end:
   125328 LUA.1: HandleParkingBrake start:
   125344 LUA.1: rightRudderPedalValue
   125359 LUA.1: 0
   125375 LUA.1: leftRudderPedalValue
   125390 LUA.1: -16384
   125406 LUA.1: SOLENOID 0
   125437 LUA.1: HandleParkingBrake end:
   125469 LUA.1: HandleParkingBrake start:
   125484 LUA.1: rightRudderPedalValue
   125500 LUA.1: 0
   125515 LUA.1: leftRudderPedalValue
   125531 LUA.1: -16384
   125547 LUA.1: SOLENOID 0
   125578 LUA.1: HandleParkingBrake end:
   125609 LUA.1: HandleParkingBrake start:
   125625 LUA.1: rightRudderPedalValue
   125640 LUA.1: 0
   125656 LUA.1: leftRudderPedalValue
   125672 LUA.1: -16384
   125687 LUA.1: SOLENOID 0
   125719 LUA.1: HandleParkingBrake end:
   125750 LUA.1: HandleParkingBrake start:
   125765 LUA.1: rightRudderPedalValue
   125781 LUA.1: 0
   125797 LUA.1: leftRudderPedalValue
   125812 LUA.1: -16384
   125828 LUA.1: SOLENOID 0
   125859 LUA.1: HandleParkingBrake end:
   125890 LUA.1: HandleParkingBrake start:
   125906 LUA.1: rightRudderPedalValue
   125922 LUA.1: 0
   125937 LUA.1: leftRudderPedalValue
   125953 LUA.1: -16384
   125969 LUA.1: SOLENOID 0
   126000 LUA.1: HandleParkingBrake end:
   126031 LUA.1: HandleParkingBrake start:
   126047 LUA.1: rightRudderPedalValue
   126062 LUA.1: 0
   126078 LUA.1: leftRudderPedalValue
   126094 LUA.1: -16384
   126109 LUA.1: SOLENOID 0
   126140 LUA.1: HandleParkingBrake end:
   126172 LUA.1: HandleParkingBrake start:
   126187 LUA.1: rightRudderPedalValue
   126203 LUA.1: 0
   126219 LUA.1: leftRudderPedalValue
   126219 LUA.1: -16384
   126234 LUA.1: SOLENOID 0
   126265 LUA.1: HandleParkingBrake end:
   126297 LUA.1: HandleParkingBrake start:
   126312 LUA.1: rightRudderPedalValue
   126328 LUA.1: 0
   126344 LUA.1: leftRudderPedalValue
   126359 LUA.1: -16384
   126375 LUA.1: SOLENOID 0
   126406 LUA.1: HandleParkingBrake end:
   126437 LUA.1: HandleParkingBrake start:
   126453 LUA.1: rightRudderPedalValue
   126469 LUA.1: 0
   126484 LUA.1: leftRudderPedalValue
   126500 LUA.1: -16384
   126515 LUA.1: SOLENOID 0
   126547 LUA.1: HandleParkingBrake end:
   126578 LUA.1: HandleParkingBrake start:
   126594 LUA.1: rightRudderPedalValue
   126609 LUA.1: 0
   126625 LUA.1: leftRudderPedalValue
   126640 LUA.1: -16384
   126656 LUA.1: SOLENOID 0
   126687 LUA.1: HandleParkingBrake end:
   126719 LUA.1: HandleParkingBrake start:
   126734 LUA.1: rightRudderPedalValue
   126750 LUA.1: 0
   126765 LUA.1: leftRudderPedalValue
   126781 LUA.1: -16384
   126797 LUA.1: SOLENOID 0
   126828 LUA.1: HandleParkingBrake end:
   126859 LUA.1: HandleParkingBrake start:
   126875 LUA.1: rightRudderPedalValue
   126890 LUA.1: 0
   126906 LUA.1: leftRudderPedalValue
   126922 LUA.1: -16384
   126937 LUA.1: SOLENOID 0
   126969 LUA.1: HandleParkingBrake end:
   127000 LUA.1: HandleParkingBrake start:
   127015 LUA.1: rightRudderPedalValue
   127031 LUA.1: 0
   127047 LUA.1: leftRudderPedalValue
   127062 LUA.1: -16384
   127078 LUA.1: SOLENOID 0
   127109 LUA.1: HandleParkingBrake end:
   127140 LUA.1: HandleParkingBrake start:
   127156 LUA.1: rightRudderPedalValue
   127172 LUA.1: 0
   127187 LUA.1: leftRudderPedalValue
   127187 LUA.1: -16384
   127203 LUA.1: SOLENOID 0
   127234 LUA.1: HandleParkingBrake end:
   127265 LUA.1: HandleParkingBrake start:
   127281 LUA.1: rightRudderPedalValue
   127297 LUA.1: 0
   127312 LUA.1: leftRudderPedalValue
   127328 LUA.1: -16384
   127344 LUA.1: SOLENOID 0
   127375 LUA.1: HandleParkingBrake end:
   127406 LUA.1: HandleParkingBrake start:
   127422 LUA.1: rightRudderPedalValue
   127437 LUA.1: 0
   127453 LUA.1: leftRudderPedalValue
   127469 LUA.1: -16384
   127484 LUA.1: SOLENOID 0
   127515 LUA.1: HandleParkingBrake end:
   127547 LUA.1: HandleParkingBrake start:
   127562 LUA.1: rightRudderPedalValue
   127578 LUA.1: 0
   127594 LUA.1: leftRudderPedalValue
   127609 LUA.1: -16384
   127625 LUA.1: SOLENOID 0
   127656 LUA.1: HandleParkingBrake end:
   127687 LUA.1: HandleParkingBrake start:
   127703 LUA.1: rightRudderPedalValue
   127719 LUA.1: 0
   127734 LUA.1: leftRudderPedalValue
   127750 LUA.1: -16384
   127765 LUA.1: SOLENOID 0
   127797 LUA.1: HandleParkingBrake end:
   127828 LUA.1: HandleParkingBrake start:
   127844 LUA.1: rightRudderPedalValue
   127859 LUA.1: 0
   127875 LUA.1: leftRudderPedalValue
   127890 LUA.1: -16384
   127906 LUA.1: SOLENOID 0
   127937 LUA.1: HandleParkingBrake end:
   127969 LUA.1: HandleParkingBrake start:
   127984 LUA.1: rightRudderPedalValue
   128000 LUA.1: 0
   128015 LUA.1: leftRudderPedalValue
   128031 LUA.1: -16384
   128047 LUA.1: SOLENOID 0
   128078 LUA.1: HandleParkingBrake end:
   128109 LUA.1: HandleParkingBrake start:
   128125 LUA.1: rightRudderPedalValue
   128140 LUA.1: 0
   128156 LUA.1: leftRudderPedalValue
   128156 LUA.1: -16384
   128172 LUA.1: SOLENOID 0
   128203 LUA.1: HandleParkingBrake end:
   128234 LUA.1: HandleParkingBrake start:
   128250 LUA.1: rightRudderPedalValue
   128265 LUA.1: 0
   128281 LUA.1: leftRudderPedalValue
   128297 LUA.1: -16384
   128312 LUA.1: SOLENOID 0
   128344 LUA.1: HandleParkingBrake end:
   128375 LUA.1: HandleParkingBrake start:
   128390 LUA.1: rightRudderPedalValue
   128406 LUA.1: 0
   128422 LUA.1: leftRudderPedalValue
   128437 LUA.1: -16384
   128453 LUA.1: SOLENOID 0
   128484 LUA.1: HandleParkingBrake end:
   128515 LUA.1: HandleParkingBrake start:
   128531 LUA.1: rightRudderPedalValue
   128547 LUA.1: 0
   128562 LUA.1: leftRudderPedalValue
   128578 LUA.1: -16384
   128594 LUA.1: SOLENOID 0
   128625 LUA.1: HandleParkingBrake end:
   128656 LUA.1: HandleParkingBrake start:
   128672 LUA.1: rightRudderPedalValue
   128687 LUA.1: 0
   128703 LUA.1: leftRudderPedalValue
   128719 LUA.1: -16384
   128734 LUA.1: SOLENOID 0
   128765 LUA.1: HandleParkingBrake end:
   128797 LUA.1: HandleParkingBrake start:
   128812 LUA.1: rightRudderPedalValue
   128828 LUA.1: 0
   128844 LUA.1: leftRudderPedalValue
   128859 LUA.1: -16384
   128875 LUA.1: SOLENOID 0
   128906 LUA.1: HandleParkingBrake end:
   128937 LUA.1: HandleParkingBrake start:
   128953 LUA.1: rightRudderPedalValue
   128969 LUA.1: 0
   128984 LUA.1: leftRudderPedalValue
   129000 LUA.1: -16384
   129015 LUA.1: SOLENOID 0
   129047 LUA.1: HandleParkingBrake end:
   129078 LUA.1: HandleParkingBrake start:
   129094 LUA.1: rightRudderPedalValue
   129109 LUA.1: 0
   129125 LUA.1: leftRudderPedalValue
   129125 LUA.1: -16384
   129140 LUA.1: SOLENOID 0
   129172 LUA.1: HandleParkingBrake end:
   129203 LUA.1: HandleParkingBrake start:
   129219 LUA.1: rightRudderPedalValue
   129234 LUA.1: 0
   129250 LUA.1: leftRudderPedalValue
   129265 LUA.1: -16384
   129281 LUA.1: SOLENOID 0
   129312 LUA.1: HandleParkingBrake end:
   129344 LUA.1: HandleParkingBrake start:
   129359 LUA.1: rightRudderPedalValue
   129375 LUA.1: 0
   129390 LUA.1: leftRudderPedalValue
   129406 LUA.1: -16384
   129422 LUA.1: SOLENOID 0
   129453 LUA.1: HandleParkingBrake end:
   129484 LUA.1: HandleParkingBrake start:
   129500 LUA.1: rightRudderPedalValue
   129515 LUA.1: 0
   129531 LUA.1: leftRudderPedalValue
   129547 LUA.1: -16384
   129562 LUA.1: SOLENOID 0
   129594 LUA.1: HandleParkingBrake end:
   129625 LUA.1: HandleParkingBrake start:
   129640 LUA.1: rightRudderPedalValue
   129656 LUA.1: 0
   129672 LUA.1: leftRudderPedalValue
   129687 LUA.1: -16384
   129703 LUA.1: SOLENOID 0
   129734 LUA.1: HandleParkingBrake end:
   129765 LUA.1: HandleParkingBrake start:
   129781 LUA.1: rightRudderPedalValue
   129797 LUA.1: 0
   129812 LUA.1: leftRudderPedalValue
   129828 LUA.1: -16384
   129844 LUA.1: SOLENOID 0
   129875 LUA.1: HandleParkingBrake end:
   129906 LUA.1: HandleParkingBrake start:
   129922 LUA.1: rightRudderPedalValue
   129937 LUA.1: 0
   129953 LUA.1: leftRudderPedalValue
   129969 LUA.1: -16384
   129984 LUA.1: SOLENOID 0
   130015 LUA.1: HandleParkingBrake end:
   130047 LUA.1: HandleParkingBrake start:
   130062 LUA.1: rightRudderPedalValue
   130078 LUA.1: 0
   130078 LUA.1: leftRudderPedalValue
   130094 LUA.1: -16384
   130109 LUA.1: SOLENOID 0
   130140 LUA.1: HandleParkingBrake end:
   130172 LUA.1: HandleParkingBrake start:
   130187 LUA.1: rightRudderPedalValue
   130203 LUA.1: 0
   130219 LUA.1: leftRudderPedalValue
   130234 LUA.1: -16384
   130250 LUA.1: SOLENOID 0
   130281 LUA.1: HandleParkingBrake end:
   130312 LUA.1: HandleParkingBrake start:
   130328 LUA.1: rightRudderPedalValue
   130344 LUA.1: 0
   130359 LUA.1: leftRudderPedalValue
   130375 LUA.1: -16384
   130390 LUA.1: SOLENOID 0
   130422 LUA.1: HandleParkingBrake end:
   130453 LUA.1: HandleParkingBrake start:
   130469 LUA.1: rightRudderPedalValue
   130484 LUA.1: 0
   130500 LUA.1: leftRudderPedalValue
   130515 LUA.1: -16384
   130531 LUA.1: SOLENOID 0
   130562 LUA.1: HandleParkingBrake end:
   130594 LUA.1: HandleParkingBrake start:
   130609 LUA.1: rightRudderPedalValue
   130625 LUA.1: 0
   130640 LUA.1: leftRudderPedalValue
   130656 LUA.1: -16384
   130672 LUA.1: SOLENOID 0
   130703 LUA.1: HandleParkingBrake end:
   130734 LUA.1: HandleParkingBrake start:
   130750 LUA.1: rightRudderPedalValue
   130765 LUA.1: 0
   130781 LUA.1: leftRudderPedalValue
   130797 LUA.1: -16384
   130812 LUA.1: SOLENOID 0
   130844 LUA.1: HandleParkingBrake end:
   130844 === Hot key unregistered
   130844 === Stop called ...
   130859 === Closing external processes we started ...
   130875 LUA.1: HandleParkingBrake start:
   130890 LUA.1: rightRudderPedalValue
   130906 LUA.1: 0
   130922 LUA.1: leftRudderPedalValue
   130937 LUA.1: -16384
   130953 LUA.1: SOLENOID 0
   131875 === About to kill any Lua plug-ins still running ...
   132015 Lua threads being terminated:
   132015       1 = "E:\FSUIPC7\test.lua"
   132594 LUA: "E:\FSUIPC7\test.lua": killed
   132594 === Closing global Lua thread
   133625 === About to kill my timers ...
   133844 === Restoring window procs ...
   133844 === Unloading libraries ...
   133844 === stopping other threads ...
   133844 === ... Button scanning ...
   133937 === ... Axis scanning ...
   134047 === Releasing joystick devices ...
   134047 === Freeing macro memory
   134047 === Removing any offset overrides
   134047 === Clearing any displays left
   134062 === Calling SimConnect_Close ...
   134265 === SimConnect_Close done!
   134265 === AI slots deleted!
   134265 === Freeing button memory ...
   134265 === Closing my Windows ...
   134265 === Freeing FS libraries ...
   135281 === Closing devices ...
   135281 === Closing the Log ... Bye Bye! ...
   135281 System time = 18/02/2021 22:12:09
   135281 *** FSUIPC log file being closed
Minimum frame rate was 45.3 fps, Maximum was 60.1 fps
Average frame rate for running time of 123 secs = 56.3 fps
Maximum AI traffic for session was 1 aircraft
Traffic deletions 0 aircraft
Memory managed: 4 Allocs, 3 Freed
********* FSUIPC Log file closed ***********

 

The code I have used. The lua script seem to send some strange values, could it be bad pedals? Is it in som way possible to filter in the lua script?

function HandleParkingBrake(time)

    ipc.log("HandleParkingBrake start:")
   
    rightRudderPedalValue = ipc.readSW(0x66F5)
    leftRudderPedalValue = ipc.readSW(0x66F6)
   
    ipc.log("rightRudderPedalValue")
    ipc.log(rightRudderPedalValue)
    ipc.log("leftRudderPedalValue")
    ipc.log(leftRudderPedalValue)
  

   if rightRudderPedalValue > 14000 and leftRudderPedalValue > 14000 then
        ipc.log("SOLENOID 1")
        ipc.writeUB(0x66E9, 1)
   else
        ipc.log("SOLENOID 0")
        ipc.writeUB(0x66E9, 0)
   end
   
   ipc.log("HandleParkingBrake end:")

end


event.timer(10, "HandleParkingBrake")

 

 

 

 

 

Link to comment
Share on other sites

Could this code work?

That it disregard a -1 value?

Or is there any other filtering methods in lua?

 

function HandleParkingBrake(time)

 

    ipc.log("HandleParkingBrake start:")

   

    rightRudderPedalValue = ipc.readSW(0x66F5)

    leftRudderPedalValue = ipc.readSW(0x66F6)

   

    ipc.log("rightRudderPedalValue")

    ipc.log(rightRudderPedalValue)

    ipc.log("leftRudderPedalValue")

    ipc.log(leftRudderPedalValue)

  

   if leftRudderPedalValue <> -1 then

 

   if rightRudderPedalValue > 14000 and leftRudderPedalValue > 14000 then

        ipc.log("SOLENOID 1")

        ipc.writeUB(0x66E9, 1)

   else

        ipc.log("SOLENOID 0")

        ipc.writeUB(0x66E9, 0)

   end

   

  else

      

   ipc.log("HandleParkingBrake end:")

 

end

 

end

 

 

event.timer(10, "HandleParkingBrake")

Link to comment
Share on other sites

12 hours ago, Jacob Wiqvist said:

rightRudderPedalValue = ipc.readSW(0x66F5)
leftRudderPedalValue = ipc.readSW(0x66F6)

I see you have changed to using signed words now. Did you verify that this is correct, using FSUIPCs offset monitoring, as suggested by Pete?
If you have confirmed that it is indeed a signed word, then good - some progress...

But you are making the same mistake again. A Signed word is two bytes, so if you have one at offset  0x66F5, it will cover 0x66F5-0x66F6 (2 bytes) inclusive,  and the next should be at 0x66F7, and not 0x66F6. So your values are overwriting each other, which is most probably why you are seeing strange values.

Please don't post should large (and useless) log extracts. You have gone way overboard with the logging. A single log line, or maybe two, would help you see things a lot clearer (and shorten the log considerably). Remove ALL your current log lines, and use something more like what I previously advised, something like
 

Quote

if rightRudderPedalValue > 14000 and leftRudderPedalValue > 14000 then
        ipc.writeUB(0x66E9, 1)
        ipc.log("rightPedal=" .. rightRudderPedalValue .. ", leftPedal=" .. leftRudderPedalValue .. " : ON ")
else
        ipc.writeUB(0x66E9, 0)
        ipc.log("rightPedal=" .. rightRudderPedalValue .. ", leftPedal=" .. leftRudderPedalValue ... " :  ")

   end

(two dots is the string concatenation operator in lua, FYI)

Why have you gone back to using event.timer instead of event.offset? Up to you of course, either will work.

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.