Falcon BMS Forum
    • Register
    • Login
    • Search
    • Categories
    • Unread
    • Recent
    • Unsolved
    • Popular
    • Website
    • Wiki

    Shared memory reading

    Technical Support (BMS Only)
    2
    6
    156
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • fdsa
      fdsa last edited by

      Hello,

      I want to make my own C++ program to read the data located inside the Falcon shared memory. Then I will make this program communicate with my external devices for cockpit motor, display and led controls.

      I have searched this forum and saw that Flight data.h is provided inside the Falcon as a memory map and includes class/function declarations. From where can I read those values dynamically while the sim is running? And where are the implementations of those functions (.cpp file)? There are some functions like that I might use as well, such as:

      (quoting from) Flight data.h:
      ….
      // getters for external reader programs
      bool UfcTacanIsAA(void) {return ((tacanInfo[UFC] & mode) ? true : false); }
      ….

      1 Reply Last reply Reply Quote 0
      • roccio
        roccio last edited by

        As I replied to another your post, all you have to do is initialize the shared memory handle and the data will be available automagically when Falcon is running. If you need source code I can provide.

        fdsa 1 Reply Last reply Reply Quote 0
        • fdsa
          fdsa @roccio last edited by

          That would be great if you can provide me some example. You can share it here or as a PM.

          Thanks in advance!

          roccio 1 Reply Last reply Reply Quote 0
          • roccio
            roccio @fdsa last edited by

            Don’t cross post. Use this one only.
            Here a little code

            #include <iostream>#include <windows.h>#include <stdio.h>#include “Flight Data.h”
            using namespace std;

            TCHAR sharedMemoryAreaName[] = TEXT( “FalconSharedMemoryArea” );
            int main()
            {
            const HANDLE hMapFile = OpenFileMapping(FILE_MAP_READ, FALSE, sharedMemoryAreaName);
            if (hMapFile != NULL)
            {
            const FlightData * data = (FlightData *) MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, sizeof(FlightData));
            if (data != NULL)
            {
            while (true)
            {
            std::cout << data->kias << std::endl;
            Sleep(1000);
            }
            UnmapViewOfFile(data);
            }
            else
            {
            cout << “Could not map view of file”;
            }
            CloseHandle(hMapFile);
            }
            else
            {
            DWORD err = GetLastError();
            cout << "Could not open file mapping object: " << err;
            }
            return 0;
            }</stdio.h></windows.h></iostream>

            In the example it will print the speed you are flying to the output console.

            fdsa 1 Reply Last reply Reply Quote 0
            • fdsa
              fdsa @roccio last edited by

              This worked, big thanks!

              roccio 1 Reply Last reply Reply Quote 0
              • roccio
                roccio @fdsa last edited by

                Your welcome! Show your work when ready!!:)

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post

                58
                Online

                10.1k
                Users

                19.2k
                Topics

                327.5k
                Posts

                Benchmark Sims - All rights reserved ©