Coder Social home page Coder Social logo

FalconSharedMemoryArea2 about simscript HOT 8 CLOSED

dglava avatar dglava commented on June 26, 2024
FalconSharedMemoryArea2

from simscript.

Comments (8)

nmeier avatar nmeier commented on June 26, 2024

Hi

I reviewed up to pilotsStatus, and believe you have to use the multipliers for the array lengths. After that the fields might be from a newer version of FlightData.h? Where can I see the latest?

Nils

redacted

from simscript.

dglava avatar dglava commented on June 26, 2024

Here's a link to a copy of version 4.35 FlightData.h: https://gist.github.com/dglava/55a823cb6d8f899f11790b2a4c3e4356

Thanks for looking into this.

from simscript.

nmeier avatar nmeier commented on June 26, 2024

ok, try the struct description in my post #2 (comment), that looks right atm

from simscript.

dglava avatar dglava commented on June 26, 2024

I have tried it, but I'm still getting weird data. I tried a few things:

  • "caraAlow" is giving me"1.3508517196091237e-42" instead of the CARA ALOW value.
  • "turnRate" is giving me constantly 0.0

But then stuff like "cmdsMode" seems to give me the correct data. Do you reckon it's an issue with the FlightData2 class or with the shared memory in Falcon BMS itself?

from simscript.

nmeier avatar nmeier commented on June 26, 2024

Ok, found another mistake that would break anything after RTT_*, see below

class FLIGHTDATA2(ctypes.Structure):
    _fields_ = (
        ("nozzlePos2", ctypes.wintypes.FLOAT),
        ("rpm2", ctypes.wintypes.FLOAT),
        ("ftit2", ctypes.wintypes.FLOAT),
        ("oilPressure2", ctypes.wintypes.FLOAT),
        ("navMode", ctypes.wintypes.BYTE),
        ("AAUZ", ctypes.wintypes.FLOAT),
        ("tacanInfo", ctypes.wintypes.CHAR * 2),
        
        ("AltCalReading", ctypes.wintypes.INT),
        ("altBits", ctypes.wintypes.INT),
        ("powerBits", ctypes.wintypes.INT),
        ("blinkBits", ctypes.wintypes.INT),
        
        ("cmdsMode", ctypes.wintypes.INT),
        ("BupUhfPreset", ctypes.wintypes.INT),
        
        ("BupUhfFreq", ctypes.wintypes.INT),
        ("cabinAlt", ctypes.wintypes.FLOAT),
        ("hydPressureA", ctypes.wintypes.FLOAT),
        ("hydPressureB", ctypes.wintypes.FLOAT),
        ("currentTime", ctypes.wintypes.INT),
        ("vehicleACD", ctypes.wintypes.SHORT),
        ("VersionNum", ctypes.wintypes.INT),

        ("fuelFlow2", ctypes.wintypes.FLOAT),

        ("RwrInfo", ctypes.wintypes.CHAR * 512),
        ("lefPos", ctypes.wintypes.FLOAT),
        ("tefPos", ctypes.wintypes.FLOAT),

        ("vtolPos", ctypes.wintypes.FLOAT),

        ("pilotsOnline", ctypes.wintypes.CHAR),
        ("pilotsCallsign", ctypes.wintypes.CHAR * 32 * 12),
        ("pilotsStatus", ctypes.wintypes.CHAR * 32),

        ("bumpIntensity", ctypes.wintypes.FLOAT),

        ("latitude", ctypes.wintypes.FLOAT),
        ("longitude", ctypes.wintypes.FLOAT),

        ("RTT_size", ctypes.wintypes.USHORT * 2),
        ("RTT_area", ctypes.wintypes.USHORT) * 7 * 4,

        ("iffBackupMode1Digit1", ctypes.wintypes.CHAR),
        ("iffBackupMode1Digit2", ctypes.wintypes.CHAR),
        ("iffBackupMode3Digit1", ctypes.wintypes.CHAR),
        ("iffBackupMode3Digit2", ctypes.wintypes.CHAR),

        ("instrLight", ctypes.wintypes.CHAR),

        ("bettyBits", ctypes.wintypes.UINT),
        ("miscBits", ctypes.wintypes.UINT),
        ("RALT", ctypes.wintypes.FLOAT),
        ("bingoFuel", ctypes.wintypes.FLOAT),
        ("caraAlow", ctypes.wintypes.FLOAT),
        ("bullseyeX", ctypes.wintypes.FLOAT),
        ("bullseyeY", ctypes.wintypes.FLOAT),
        ("BMSVersionMajor", ctypes.wintypes.INT),
        ("BMSVersionMinor", ctypes.wintypes.INT),
        ("BMSVersionMicro", ctypes.wintypes.INT),
        ("BMSBuildNumber", ctypes.wintypes.INT),
        ("StringAreaSize", ctypes.wintypes.UINT),
        ("StringAreaTime", ctypes.wintypes.UINT),
        ("DrawingAreaSize", ctypes.wintypes.UINT),

        ("turnRate", ctypes.wintypes.FLOAT),
)

from simscript.

dglava avatar dglava commented on June 26, 2024

Thanks, it's working!

Sorry for bothering you, but would you also know why this additional Falcon BMS shared memory part isn't working when trying to access it? It's the IntelliVibe values which can be seen in the "IVibe" tab inside Falcon BMS shared memory viewer. It's not documented in the FlightData.h file. Here's a related thread and the only documentation I could find.

I have created a new class and defined those fields according to the info above. The first few ones (BYTE and INT) are working, but the BOOL fields aren't.

Here's what I have:

class IVDATA(ctypes.Structure):
    _fields_ = (
        ("AAMissileFired", ctypes.wintypes.BYTE),
        ("AGMissileFired", ctypes.wintypes.BYTE),
        ("BombDropped", ctypes.wintypes.BYTE),
        ("FlareDropped", ctypes.wintypes.BYTE),
        ("ChaffDropped", ctypes.wintypes.BYTE),
        ("BulletsFired", ctypes.wintypes.BYTE),
        ("CollisionCounter", ctypes.wintypes.INT),
        ("IsFiringGun", ctypes.wintypes.BOOL),
        ("IsEndFlight", ctypes.wintypes.BOOL),
        ("IsEjecting", ctypes.wintypes.BOOL),
        ("In3D", ctypes.wintypes.BOOL),
        ("IsPaused", ctypes.wintypes.BOOL),
        ("IsFrozen", ctypes.wintypes.BOOL),
        ("IsOverG", ctypes.wintypes.BOOL),
        ("IsOnGround", ctypes.wintypes.BOOL),
        ("IsExitGame", ctypes.wintypes.BOOL),
        ("Gforce", ctypes.wintypes.FLOAT),
        ("eyex", ctypes.wintypes.FLOAT),
        ("eyey", ctypes.wintypes.FLOAT),
        ("eyez", ctypes.wintypes.FLOAT),
        ("lastdamage", ctypes.wintypes.INT),
        ("damageforce", ctypes.wintypes.FLOAT),
        ("whendamage", ctypes.wintypes.INT)
)

def getIV():
    global _pIV
 
    if _pIV == None:
 
        handle = ctypes.windll.kernel32.OpenFileMappingA(FILE_MAP_READ|FILE_MAP_WRITE, False, "FalconIntellivibeSharedMemoryArea".encode())
        if handle:
            ctypes.windll.kernel32.MapViewOfFile.restype = ctypes.POINTER(IVDATA)
            _pIV = ctypes.windll.kernel32.MapViewOfFile(handle, FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, 0)
 
    if not _pIV:
        raise EnvironmentError("can't access falcon shared memory area")
 
    return _pIV.contents

When I do print(getIV().In3D) it's giving me 1065307441 instead of something resembling a boolean value. I don't know anything about this really, but was wondering if it could have something to do with this?

from simscript.

nmeier avatar nmeier commented on June 26, 2024

Glad it works, can you create a pull request so your shared memory area 2 ends up in code?

For your additional example try ctypes.wintypes.BOOLEAN (not BOOL which seems to be a long)

from simscript.

dglava avatar dglava commented on June 26, 2024

Using BOOLEAN instead of BOOL fixed it!

from simscript.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.