dmordogan Posted June 18, 2021 Author Report Posted June 18, 2021 1 hour ago, John Dowson said: Maybe an example will help you.... Door 1 is bit 0, so to open just that door, you would set bit 0, i.e. write 0x1, or just 1. Door 2 is bit 1, so to open just that door, you would set bit 1, i.e. write 0x2, or just 2. Door 3 is bit 2, so to open that door, you would set bit 2, i.e. write 0x4, or just 4 If you write 0x3, or just 3, that is 0b11, so that would open doors 1 and 2 (bits 0 and 1 set). So, as I said, if you write 100 (in decimal), that is in binary 0b1100100, which is: - door 1 closed 0b1100100 - bold is bit 0 - door 2 closed 0b1100100 - bold is bit 1 - door 3 open 0b1100100 - bold is bit 2 - etc To change single doors, you need to read the offset value as it is, then change the bit (using the lua logic library) for the door you want to control. You should or the original value with the bit flag you want to set, or and to clear. I understand this may sound advanced for your understanding, but it really isn't that difficult. If you can tell me exactly want you want to achieve (i.e which aircraft and, if applicable, which mod, and which doors) then I can maybe help you further if you have issues. John [Note some folks call bit 0 bit 1, which is confusing. But you can usually tell by context] thank you very much again for explanation what i want to do is; taking Lvar value of DOOR_MAIN_DOOR_POS (which is belong to aerosoft crj lvar exist in list and value when closed "0" when open "100") and apply to responding offset (which is 3367) to make sure when door open (main door its probably exit1 or it can de all doors) offset value equals "1" and when closed "0" I want to do it besause our flight management application reads this offset to determine whether door is open or closed.
John Dowson Posted June 18, 2021 Report Posted June 18, 2021 22 minutes ago, dmordogan said: what i want to do is; taking Lvar value of DOOR_MAIN_DOOR_POS (which is belong to aerosoft crj lvar exist in list and value when closed "0" when open "100") and apply to responding offset (which is 3367) to make sure when door open (main door its probably exit1 or it can de all doors) offset value equals "1" and when closed "0" I want to do it besause our flight management application reads this offset to determine whether door is open or closed. Ok, then what you need to do is spoof the offset value with the modified lvar value. Just take the lua script I previously told you about and linked the post where available, change that script to use the offset you want to spoof, i.e this: local spoofOffset = 0x0BC8 -- Parking Brake offset, unsigned word (2 bytes) to this: local spoofOffset = 0x3367 -- Exit Open offset, bit per door (1 byte) Change the variable to read your lvar: ... local pBrakePosition = 0 ... pBrakePosition = ipc.readLvar("L:A32NX_PARK_BRAKE_LEVER_POS"); ... to ... local doorMainState = 0 ... doorMainState = ipc.readLvar("L:DOOR_MAIN_DOOR_POS"); ... Then you can apply whatever transformation on that value you require to write/spoof offset 3367. If it is as you say, its very easy to assign a new local variable to the value you want to set, based upon the lvar value, then adjust the ipc.writeStruct statement to your requirements. Hopefully that should give you enough information to do what you require.
dmordogan Posted June 18, 2021 Author Report Posted June 18, 2021 1 hour ago, John Dowson said: Ok, then what you need to do is spoof the offset value with the modified lvar value. Just take the lua script I previously told you about and linked the post where available, change that script to use the offset you want to spoof, i.e this: local spoofOffset = 0x0BC8 -- Parking Brake offset, unsigned word (2 bytes) to this: local spoofOffset = 0x3367 -- Exit Open offset, bit per door (1 byte) Change the variable to read your lvar: ... local pBrakePosition = 0 ... pBrakePosition = ipc.readLvar("L:A32NX_PARK_BRAKE_LEVER_POS"); ... to ... local doorMainState = 0 ... doorMainState = ipc.readLvar("L:DOOR_MAIN_DOOR_POS"); ... Then you can apply whatever transformation on that value you require to write/spoof offset 3367. If it is as you say, its very easy to assign a new local variable to the value you want to set, based upon the lvar value, then adjust the ipc.writeStruct statement to your requirements. Hopefully that should give you enough information to do what you require. in fsuipc7.ini file i put the "auto" section for crjdoor.lua file [Auto] 1=Lua crjdoor lua script; ------ local spoofOffset = 0x3367 -- Exit Open offset, bit per door (1 byte) local doorMainState = 0 while true do doorMainState = ipc.readLvar("L:DOOR_MAIN_DOOR_POS"); doorMainState = doorMainState / 100 ipc.writeStruct(0x3367, "1UW", doorMainState) ipc.sleep(100) end -------- Lvar value is when door open "0" when closed "100" thats why i divided with 100 if closed 0/100=0 if open 100/100 =1 with ipc.writeStruct i tried to bind to offset(3367) value "0" or "1" but no luck dorr value still always "0" thank you for help...
Pete Dowson Posted June 18, 2021 Report Posted June 18, 2021 55 minutes ago, dmordogan said: with ipc.writeStruct i tried to bind to offset(3367) value "0" or "1" but no luck I think you have ignored much of what John has been telling you. "Spoofing" is done via offset 0x0024. Writing direct to 0x3367 will not work! Please go back and read the whole thread again but more carefully. i'm really surprised John has had so much patience with you! Pete
John Dowson Posted June 19, 2021 Report Posted June 19, 2021 11 hours ago, dmordogan said: ipc.writeStruct(0x3367, "1UW", doorMainState) Try: ipc.writeStruct(0x0024, "1UW", spoofOffset, "1UW", 1, "1UB", doorMainState )
dmordogan Posted June 19, 2021 Author Report Posted June 19, 2021 10 hours ago, John Dowson said: Try: ipc.writeStruct(0x0024, "1UW", spoofOffset, "1UW", 1, "1UB", doorMainState ) It worked thank you very very much John and thank you very very much for your patience
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