Snooky Posted July 21, 2009 Report Posted July 21, 2009 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
Pete Dowson Posted July 21, 2009 Report Posted July 21, 2009 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 < 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) 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
Snooky Posted July 21, 2009 Author Report Posted July 21, 2009 Thanks Pete, i'll try this tomorrow morning when I'm back at university and will report back with the control i use and the parameters needed, thanks :)
Snooky Posted July 22, 2009 Author Report Posted July 22, 2009 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now