Jump to content
The simFlight Network Forums

Exporting offsets to a new FSUIPC offset (Jeehell FMGS avionics and BFF control loading software)


Recommended Posts

Posted

Hi - I'm wondering if it is possible to export assigned Jeehell offsets to another offset which the BFF control loading software would be able to read? 

I would like FSUIPC to read the Jeehell offsets for Autopilot (AP1 and/or AP2, offset 7390, function 0 and 1, see first attached file) and trigger an offset which the BFF software can understand.

I can configure the A/P status offset in the BFF program but it it must be in the format 0x0000 (see second attached file). I am not sure how it would be able to read the Jeehell AP offsets directly. 

Thank you.

----

Here is the manual for (Simavionics and Prosim configuration):

Parameter: Sim_A_AP_offset

Sim Aviation custom FSUIPC output offset used to carry the Sim-A A/P status byte. It can also be used to communicate A/P status for other avionics suites (eg ProSim) if they can write A/P status indicators to it.

It becomes active if Item 1 Enable A/P Following = 2.

This output offset must be set in Sim-A or Pro-Sim and output offset monitoring must be enabled.

Default is 0x5300 - this can be changed if this offset is already used in your Sim-A installation.

The following data items must be configured in the Sim-A FSUIPC I/O interface file, [FSUIPC_OUTPUTS] section:

// MCP Lights
MCP_ON=5300b0
MCP_CMD_A=5300b1
MCP_CMD_B=5300b2
MCP_CWS_A=5300b3
MCP_CWS_B=5300b4
MCP_FLTDIR_L=5300b5
MCP_FLTDIR_R=5300b6

NB change "5300" to suit your chosen offset.

NOTE the CL software will issue A/P disengage commands via Sim-A MultiFunction offset 0x53DB. So make sure 

MULTI_FUNCTION=53DB

is also set in your Sim-A file.

This offset can be changed in Item 26. The value sent to the offset to instruct disengage can be set in Item 27 (default is 551 for A-Sim).

PRO-SIM
---------------

Pro-Sim can also be configured to export MCP indicator lights status to a custom FSUIPC offset. 

This is done in the ProSim737 System window - Menu item Config-Configuration- Tab "Inidcators MCP/Throttle". Please see the Pro-Sim user guide for details.

You must first enable FSUIPC Support in the "Drivers" Tab for the offset setting option to become available.

Then in the "Indicators MCP/Throttle" Tab set

MCP CMD A to FSUIPC 8 bit U - 0x5300.1
MCP CMD B to FSUIPC 8 bit U - 0x5300.2
MCP CWS A to FSUIPC 8 bit U - 0x5300.3
MCP CWS B to FSUIPC 8 bit U - 0x5300.4
MCP FCC A Master  to FSUIPC 8 bit U - 0x5300.5
MCP FCC B Master  to FSUIPC 8 bit U - 0x5300.6

Then to configure the offset used to carry the CL software auto A/P disengage instruction, ...in the "Switches MCP/Throttle" Tab set....

MCP AP Disengage Disengage to 
FSUPIC 16bit U 0x53DB = 551

This can be adjusted to suit your offset and value settings in Items 26 and 27 if required.

Screenshot 2023-01-26 190442.jpg

bff.jpg

Posted
16 minutes ago, OmniAtlas said:

I'm wondering if it is possible to export assigned Jeehell offsets to another offset which the BFF control loading software would be able to read? 

I would like FSUIPC to read the Jeehell offsets for Autopilot (AP1 and/or AP2, offset 7390, function 0 and 1, see first attached file) and trigger an offset which the BFF software can understand.

You can use a lua script that monitors an offset and when it changes the handling function can write the required value to another offset, using event.offset  - or, if it is a bit change as in your case, use event.offsetmask. See the FSUI{C Lua Library document on using this function.

18 minutes ago, OmniAtlas said:

I can configure the A/P status offset in the BFF program but it it must be in the format 0x0000 (see second attached file). I am not sure how it would be able to read the Jeehell AP offsets directly. 

Presumably you just want to monitor the bits 0 and/or 1 values of offset 0x7390, and write those to a free byte offset for the BFF program to read.

John

Posted

Thanks for the help John, I will take a look. 

I had ChatGPT write a script this is what it came up with - 

-- Import the FSUIPC library
local fsuipc = require("fsuipc")

-- Connect to FSUIPC
fsuipc.Open()

-- Register an event handler to be called when offset 0x7390 changes
fsuipc.AddOffset(0x7390, fsuipc.BIT, function(event)
    -- Read bit 0 from the event offset
    local bit0 = event.offset:get()
    
    -- Read bit 1 from the event offset
    local bit1 = event.offset:get(1)
    
    -- Combine the two bits into a single byte
    local byteValue = bit0 + (bit1 * 2)
    
    -- Write the byte value to offset 0x8000
    fsuipc.Write(0x8000, byteValue, fsuipc.BYTE)
end)

 


Regards,

Ben

Posted

That is a load of rubbish...just read the documentation and try it - it will be a simple script (that you also need to auto-start) using event.offsetmask and in the handling function ipc.writeUB. Yoiu can use logging (ipc.log) and FSUIPC's lua debug log facilitiies to help you.
Start with the lua plugin documentation and lua library documentation look at a few of the provided examples. The Advanced User guide shows you how to auto-start the lua.

John

Posted

Thanks John - this is what I have so far and will experiment more - 

 

-- Log Jeehell FMGS AP1 & AP2 LED outputs to offset 0x5300 

function autopilot()
    
    ipc.writeUB(0x5300,1)

end

event.offsetmask(0x7390, 0, "UB", "autopilot")
event.offsetmask(0x7390, 1, "UB", "autopilot")

ipc.log

Posted

Hi John - some success, 

When the lua script startups I can see that it automatically writes S8 = 1 to 0x5300.

Is it possible not to write 1, and only do so when 0x7390 bits are triggered? 

I would like the offset to work like a toggle switch - e.g. when 0x7390 bits 0 or 1 are triggered, then write 1 to 0x5300.

When they are turned off (no AP annunciation), then 0 is written to 0x5300.

Thank you.

Posted

Well, a lot better than chapGPT's attempt!

10 hours ago, OmniAtlas said:

event.offsetmask(0x7390, 0, "UB", "autopilot")
event.offsetmask(0x7390, 1, "UB", "autopilot")

The mask for bit 0 is 1, for bit 1 2, for bit 2 4, etc (i.e. the value the bit represents). And you sum to get the mask, so for the function to be called when bit 0 or 1 is changed, so you want:
    event.offsetmask(0x7390, 3, "UB", "autopilot")
Your handling function will then be called when either bit 0 or 1 is changed, and pass in the value represented by the 2 bits specified in the mask, so 0 if both bits are set, 1 if bit 0 is set and bit 2 is off, 2 if bit 0 is off and bit 1 is set and 3 if both bits are set.
Next, the handling function needs to both set and clear your new flag offset, depending on the state of both APs (represented by the 2 bits). Presumably you want this new offset/flag to be set when either autopilot is on, and cleared only when both are off. So you need to test the value received in the handling function. So, the script should be:

-- Log Jeehell FMGS AP1 & AP2 LED outputs to offset 0x5300 

function autopilot(offset, value)
--    ipc.log("**** autopilot lua: value received = " .. value)
	if value == 0 then -- both AP's are off
		ipc.writeUB(0x5300,0)
	else -- at least one AP is on
	    ipc.writeUB(0x5300,1)
	end
end

event.offsetmask(0x7390, 3, "UB", "autopilot")

ipc.log("Jeehell FMGS AP1 & AP2 LED outputs lua started")

John

Posted
18 minutes ago, John Dowson said:

Well, a lot better than chapGPT's attempt!

The mask for bit 0 is 1, for bit 1 2, for bit 2 4, etc (i.e. the value the bit represents). And you sum to get the mask, so for the function to be called when bit 0 or 1 is changed, so you want:
    event.offsetmask(0x7390, 3, "UB", "autopilot")
Your handling function will then be called when either bit 0 or 1 is changed, and pass in the value represented by the 2 bits specified in the mask, so 0 if both bits are set, 1 if bit 0 is set and bit 2 is off, 2 if bit 0 is off and bit 1 is set and 3 if both bits are set.
Next, the handling function needs to both set and clear your new flag offset, depending on the state of both APs (represented by the 2 bits). Presumably you want this new offset/flag to be set when either autopilot is on, and cleared only when both are off. So you need to test the value received in the handling function. So, the script should be:

-- Log Jeehell FMGS AP1 & AP2 LED outputs to offset 0x5300 

function autopilot(offset, value)
--    ipc.log("**** autopilot lua: value received = " .. value)
	if value == 0 then -- both AP's are off
		ipc.writeUB(0x5300,0)
	else -- at least one AP is on
	    ipc.writeUB(0x5300,1)
	end
end

event.offsetmask(0x7390, 3, "UB", "autopilot")

ipc.log("Jeehell FMGS AP1 & AP2 LED outputs lua started")

John

 

Hi John, you are amazing. I've tested the code and it works perfectly!

Thank you so much and appreciate the assistance.

Cheers,

Ben

www.soarbywire.com

 

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.