YankeeFan Posted August 17, 2003 Report Posted August 17, 2003 I am having a bit of a hard time figuiring out how to determine exactly which light switch is on by simply reading the [0D0C] offset. According to the SDK the light switches are defined as follows; 0D0C 2 bytes Lights (FS2k/CFS2), a switch for each one: 0 Navigation 1 Beacon 2 Landing 3 Taxi 4 Strobes 5 Instruments 6 Recognition 7 Wing 8 Logo If somebody has some sample code written in VB that would be great. Basically I am trying to determine each of the possible light switches if ON or OFF. When testing and had all lights off except for NAV the value in [0D0C] = 33, when I used the "L" key to switch everything on the value was 1023. Does the value of the offset just need a conversion like Decimal to Binary? Thanks! John
YankeeFan Posted August 18, 2003 Author Report Posted August 18, 2003 Never mind on this post, that's exactly what it appears I needed to do is convert the decimal value returned from the offset to a binary string and read each byte from right to left to make the determination of ON/OFF.
Pete Dowson Posted August 18, 2003 Report Posted August 18, 2003 Never mind on this post, that's exactly what it appears I needed to do is convert the decimal value returned from the offset to a binary string and read each byte from right to left to make the determination of ON/OFF. Ernothing returns a DECIMAL number as such. Everything is in binary in any case. All you needed to do was test for each bit in turn. The bits are simple "flags". So, if the value of 0D0C is in an integer variable called nLights you can test for Strobes, say, by seeing if nLights AND 16 is non-zero (replace "AND" by whatever is used in your programming language for logical AND). The value 16 arises from the value of bit 4 (2 to the power 4 = 16). Here are the values to save you calculating them: 0 value 1 Navgation 1 value 2 Beacon 2 value 4 Landing 3 value 8 Taxi 4 value 16 Strobes 5 value 32 Instruments 6 value 64 Recognition 7 value 128 Wing 8 value 256 Logo 9 value 512 Cabin The last one is new in FS2004. Pete
YankeeFan Posted August 18, 2003 Author Report Posted August 18, 2003 Many thanks Pete, that makes alot more sense now! Also, thanks for sheading some light(no pun intended) on the new Cabin light switch as well.
MattWise Posted July 9, 2006 Report Posted July 9, 2006 YankeeFan can you give me an example of your code. I am having the same problem. If YankeeFan is no longer on the form can someone give me an example. I can't figure out how to declear the variables. I see they are a S16 int but I don't know how to declear that in VB6. Thanks.
Pete Dowson Posted July 9, 2006 Report Posted July 9, 2006 YankeeFan can you give me an example of your code. I am having the same problem. If YankeeFan is no longer on the form can someone give me an example. I can't figure out how to declear the variables. I see they are a S16 int but I don't know how to declear that in VB6. Thanks. I don't think VB supports short integers, so just declare an ordinary Integer and set it to zero before reading the 2 bytes from offset 0D0C into it. The bits representing the light switches will still be in the right places, the top 16 bits (bit numbers 16 to 31) will be zero, is all. Regards, Pete
MattWise Posted July 9, 2006 Report Posted July 9, 2006 Thanks that helped a lot. I just pulled out the decimal value that was held in the offset. Then converted the decimal to binary as YankeeFan said and it works great. Thanks!
joeherwig Posted January 13, 2021 Report Posted January 13, 2021 In case someone wants to play around with it in JS... Just open your webbrowsers Dev-Tools [F12] and execute the below snipet in your browsers console: // set the numeric value as reported from FSUIPC Offset 0x0D0C fsuipc_0d0c = 234 fsuipc_0d0c = (fsuipc_0d0c >>> 0).toString(2); // log the bit-sequence as string to console console.log(fsuipc_0d0c) light = {} light.navigation = fsuipc_0d0c.charAt(0)* 1 light.beacon = fsuipc_0d0c.charAt(1) * 1 light.landing = fsuipc_0d0c.charAt(2)* 1 light.taxi = fsuipc_0d0c.charAt(3)* 1 light.strobes = fsuipc_0d0c.charAt(4)* 1 light.instruments = fsuipc_0d0c.charAt(5)* 1 light.recognition = fsuipc_0d0c.charAt(6)* 1 light.wing = fsuipc_0d0c.charAt(7)* 1 light.logo = fsuipc_0d0c.charAt(8)* 1 light.cabin = fsuipc_0d0c.charAt(9)* 1 // log as object console.log(light) // log as beautified string console.log(JSON.stringify(light,null, '\t')) which results in { "navigation": 1, "beacon": 1, "landing": 1, "taxi": 0, "strobes": 1, "instruments": 0, "recognition": 1, "wing": 0, "logo": 0, "cabin": 0 }
PetziK Posted July 12, 2021 Report Posted July 12, 2021 Hi there, I am so happy I have found this chat / thread here. I have been looking for some red beacon light in my sim for a long time and came across several addon tools / payware panel maker tools, but none of them addressed the here given issue. the purpose of my request is very similar. I am using several different aircrafts in MSFS 2020, I am flying from SETL everything up to Jets. Some aircrafts show a "red beacon" switch in their cockpit, some don't. Some only have NAV lights or some kind of Pulse light... (e.g. TBM Daher). I am using an external career mode: OnAir Company. This tool connects via simconnect to Flightsimulator and checks if RED BEACON is on prior starting the engine and if it's running until the shutdown of the engine. I bind the RED BEACON light toggle to a keyboard, but since it is not shown in the cockpit I can't verify if its on. I am also using an external hardware panel with buttons and flip switches. I assigned all light switches via FSUIPC7 and have it set like this. e.g. while Button 13 = pressed (flip switch) -> Assign Panel Light ON, when release assign Panel Light OFF. This seems to work for all lights with the exception of: BEACON LIGHT. I don't find BEACON LIGHT ON and OFF. It also doesn't exist in the built in MSFS keyboard assignments. There is only... BEACON LIGHT SET and BEACON LIGHT TOGGLE. --> Any Idea why this is so different from all the other lights? Has anybody made a working executable (*.exe) tool that reads the light switches as proposed above. My programming skills are limited. I would be very happy to have simple panel that shows all Light switches, or simply says if a certain light is ON or OFF. Thanks, happy landings, Peter
John Dowson Posted July 12, 2021 Report Posted July 12, 2021 1 hour ago, PetziK said: I don't find BEACON LIGHT ON and OFF. It also doesn't exist in the built in MSFS keyboard assignments. There is only... BEACON LIGHT SET and BEACON LIGHT TOGGLE. The following MSFS controls/events are available in MSFS, but are not currently exposed via SimConnect and so cannot be assigned directly in FSUIPC7: Taxi Light On Taxi Lights Off Beacon Lights On Beacon Lights Off Nav Lights On Nav Lights Off I reported this to MSFS/Asobo quite a while ago but nothing has been done so far. I will chase this up. There are no default keyboard assignments to these controls, but alt + h is the default keyboard assignment to toggle the beacon lights. What you can do to control these lights, is assign a key or key combination to those events in MSFS, then assign buttons to those key presses in FSUIPC7. Alternatively, have you tried the Beacon Lights Set control, with a parameter for 1 for on and 0 for off? Or you could try with Toggle Beacon Lights, with an offset condition on offset ODOC for bit 1 (ie W0D0C&0002 for beacon lights on to turn off, W0D0C&0002=0 for beacon lights off to turn on). I am assuming that the light bits in offset 0D0C are showing the correct state of the lights. Those offset is also documented as ok for both reading and writing, so you should also be able to control the lights by updating that offset. Have you tried that? If you cannot get it working via one of those methods, let me know which aircraft you are using and I will take a look. There are some additional simvars (documented at the end of the Offset status spreadsheet) that are available but currently not used that I could look into adding if needed: LIGHT BEACON ON LIGHT BRAKE ON LIGHT CABIN ON LIGHT HEAD ON LIGHT LANDING ON LIGHT LOGO ON LIGHT NAV ON LIGHT ON STATES LIGHT PANEL ON LIGHT RECOGNITION ON LIGHT STATES LIGHT STROBE ON LIGHT TAXI ON LIGHT WING ON John
PetziK Posted July 12, 2021 Report Posted July 12, 2021 Dear John, thank you so very much for answering and answering so soon! You just gave me a hint. I see that the "BEACON LIGHT SET" Requires a Parameter. I didn't put anything there in the parameter line yet. I will try this first prior going into the other optional solutions you recommend. So, my perception of a missing BEACON ON and BEACON OFF wasn't that wrong then. Thank you for keeping track of it. I just couldn't understand if it was a problem with MSFS or the simconnect, as you say. Basically my request is not for a specific aircraft model. I had the same issue back then with FSX as well. Some addons require proper light setting and you had no chance to verify if everything was set correctly because some models didn't have the red light beacon switch "depicted" in their 2D or 3D panels. I managed to install some default 2D panels as addon panels into some aircrafts, but I didn't like that solution either. I have my external hardware Switchboard that connects via USB, it works like a game controller. I prefer using this for all aircrafts, disregard appearance / simulation of the switch itself in the 3D cockpit. I will come back here and let you know if I managed with the Parameter setting 0 or 1... maybe thats also the cause for some other similar issues I had. I did not understand the "Parameter" - but its obvious... 0 is off, 1 is on... just a different way to address those "flags" or binary information. until next time, OE-PKR over and out,
PetziK Posted July 12, 2021 Report Posted July 12, 2021 Hi there again. It worked! The hardware switches now work. On switch hold (active) SET BEACON LIGHT - Parameter 1 Resend command while button pressed: YES On switch release (inactive) SET BEACON LIGHT - Parameter 0 I used this logic for several other SET xyz Commands. It works now almost seamlessly. Sometimes the USB Switchpad doesn't send or update signals in time, but with some Miliseconds delay MSFS reacts and sets the lights / features accordingly. Issue solved, Thanks, Peter
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