Jump to content
The simFlight Network Forums

Com ActiveFlag, Hydraulic Toggle


Recommended Posts

Hi Pete,

again we are facing 2 issues with our CRJ-700.

First one:

The radio stack is working a bit difficult here. Switching all the combinations of receiving/not receiving work, but we don't get any visual feedback of which one is actually receiving and which one not. Therefor we implented 2 LEDs representing the status of the com (receiving / not receiving). Since we have to use two buttons doing exactly the same, i can't get those LEDs working properly, so I decided to try a lua plugin, doing the following:

Take 2 user-free offsets.

Look up the value in Offset 3122.

Write it to a variable.

Then i found out, that you can determine the status of both coms from the value received, even though things like dme, nav1 and/or nav2 are up. So i decided to fake a flag for com1 and com2 receive status (1=receive, 0=off) to get the LEDs working with it.

The values are the following:

If value < 95, only com2 is receiving

If 95 < value < 128, both are receiving

If 128 < value < 160, only com1 is receiving

If value > 160, both are receiving

So i wrote a lua file named Ipcinit to load it when FS starts:

function findCom()

local n = ipc.readUB("3122")

if n < 95 then ipc.writeUB("66C0", 1) ipc.writeUB("another userfree offset", 0)

elseif n < 128 then ipc.writeUB("66C0", 1) ipc.writeUB("another userfree offset", 1)

elseif n < 160 then ipc.writeUB("another userfreeoffset", 0) ipc.writeUB("66C0", 0)

elseif n < 191 then ipc.writeUB("66C0", 1) ipc.writeUB("another userfree offset", 1)

end

end

event.offset("3122", UB, findCom)

another userfree offset is of course a real offset in the file. But this one is not working, there's no value displayed at 66C0 when monitoring it via FSUIPC. Any idea why we don't get a value here?

The second issues is about controls sended via offset 3110. We found a control here to toggle the hydraulic switches for the engines, but the control needs a parameter which we are not able to send with the program we use. Is there any way to avoid this one, maybe through another user facility, faking an on/off flag for thosw switches? I tried to send the parameter by just putting it at the end of the control, e.g. 655552 for 65555, parameter 2, but that doesn't work.

You helped us out many times now, so i thought you might be interested in what we are actually doing here. So here's a picture of our current progress (about 2 weeks old, we have built in more buttons now).

http://img194.imageshack.us/img194/9282/imag0044y.jpg

Thanks in advance

Sascha

Link to comment
Share on other sites

Look up the value in Offset 3122.

Write it to a variable.

Then i found out, that you can determine the status of both coms from the value received, even though things like dme, nav1 and/or nav2 are up.

Yes, of course. Offset 3122 is BIT-oriented. There's always one of bits 6 and 7 enabled, as, whilst the radio stack is on, there's always at least one COM device receiving and transmitting. Bit 5 is set to receive on both -- the transmission is still only enabled on 1. So, of the three top bits, 7-5 the combinations are

100 TX & RX on COM1

010 TX & RX on COM2

101 TX on COM1, RX on both

011 TX on COM2, RX on both.

Your "critical" values of 96, 128 and 160 are using those patterns:

64 = 0100 0000

96 = 0110 0000

128 = 1000 0000

160 = 1010 0000

So i wrote a lua file named Ipcinit to load it when FS starts:

function findCom()
  local n = ipc.readUB("3122")
  if n &lt; 95 then ipc.writeUB("66C0", 1) ipc.writeUB("another userfree offset", 0)
  elseif n &lt; 128 then ipc.writeUB("66C0", 1) ipc.writeUB("another userfree offset", 1)
  elseif n &lt; 160 then ipc.writeUB("another userfreeoffset", 0) ipc.writeUB("66C0", 0)
  elseif n &lt; 191 then ipc.writeUB("66C0", 1) ipc.writeUB("another userfree offset", 1)
end
end
event.offset("3122", UB, findCom)

You always need to check the FSUIPC log (or your Lua log if you've enabled Lua logging). In this case it will show that you have a syntax error. The UB in the event.offset() call is a string, it needs to be "UB".

Also, the name of the function being called is a string too. So that last line of your program needs to be:

event.offset("3122", "UB", "findCom")

Incidentally, your program at least found a weakness in my code. With no "" around your "findCom" parameter, FSUIPC crashes FS. It gets a null string pointer and doesn't check it! I'll fix that in the next update.

BTW you have programmed it for no change in 66C0 if the value is >= 191? (not that it should ever be, logically, but you never know with FS! ;-)

The second issues is about controls sended via offset 3110. We found a control here to toggle the hydraulic switches for the engines, but the control needs a parameter which we are not able to send with the program we use. Is there any way to avoid this one, maybe through another user facility, faking an on/off flag for thosw switches?

I don't know. I would need to know what control you were trying to use that needs a parameter. For switches there are very few!

I tried to send the parameter by just putting it at the end of the control, e.g. 655552 for 65555, parameter 2, but that doesn't work.

Of course sending a different number won't work -- the number won't be one FS recognises, or it will do something entirely different!

Regards

Pete

Link to comment
Share on other sites

Hey Pete,

everything working now, i also fixed the issue with those paramaters by taking a user free offset and an lua plugin sending the control via ipc.control(control, paramater) whenever the offset changes from 0 to 1 or the other way around.

Thanks again

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • 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.