Telemetry outputs?

Discussion in 'Plugins' started by Mike Crimlis, Dec 15, 2016.

  1. Mike Crimlis

    Mike Crimlis Registered

    Joined:
    Jan 22, 2015
    Messages:
    12
    Likes Received:
    2
    Hi all.

    I have trawled through the forums for ages and looked into several dead ends before posting a new topic, my question is pretty simple but it seems the answer might not be.

    All I'm looking for is a nice simple way to access the G values of the sim so that I can hook up my motion base using a Velleman K8055.
    With iRacing, all I have to do is reference the SDK Wrapper (through VB.NET Visual Studio) and I have anything I require. With RFactor, there doesn't seem to be any such simple output to referenceable wrapper or .dll or anything else simple.
    I don't really want to get into writing .mas files and .mfts and .rfcmps. All I want is a few values available without the hassle.

    I've been using X-Sim but apart from having to keep it online all the time it is in use, I've had a fair few other problems like losing connection with the K8055 and difficulties loggin in.
    Difficulties with internet connection means I can't use iRacing for now and my project is stalled with no way of accessing any outputs.
    I'm not good with C# or ++ but I could possibly modify something written in those and add the reference for the K8055 .dll to get something working.


    Any help would be very much appreciated.

    Mike.
     
  2. Marcel Offermans

    Marcel Offermans Registered

    Joined:
    Oct 4, 2010
    Messages:
    653
    Likes Received:
    2,961
    The way to interface with rFactor 2 and get live telemetry to be used to control a motion base is through the "internals plugin" which can be found in the Dev Corner of our website:

    https://www.studio-397.com/modding-resources/

    If you scroll down towards the bottom you will find it. A word of warning, this is a C++ SDK and even though we do provide a sample plugin, you will need to learn some C++ to get this going.
     
  3. Mike Crimlis

    Mike Crimlis Registered

    Joined:
    Jan 22, 2015
    Messages:
    12
    Likes Received:
    2
    Hi Marcel.

    Thank you for your reply.
    I downloaded the Internals Plugin and the Example Plugin. I copied the .exe files to the Plugins directory and followed the brief .pdf guide on starting with RF2 windowed etc.
    I got nothing. No console, no resultant .txt file.

    I'm running Windows7 x64 so I changed the target platform in the Internals Plugin configuration and I'm now getting output to the "ExampleInternalsTelemetryOutput.txt" file.
    I think I can make some progress from here, C++ isn't too difficult to understand. But with the Example Plugin, it isn't possible to change the target platform.

    Does anyone know how the values are named and accessed?
    For instance, to get values from my K8055, I import the value like so:
    [DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
    static int ReadAnalogChannel(int Channel);
    I saw from the text file that there is a value named "UnfilteredThrottle" which will be fine to use as a reference value to know I have it working but so far, I've not been able to access this value from my K8055 code.

     
    Last edited: Dec 17, 2016
  4. Marcel Offermans

    Marcel Offermans Registered

    Joined:
    Oct 4, 2010
    Messages:
    653
    Likes Received:
    2,961
    The result of compiling that plugin should be a DLL file that should be copied to the plugins folder, not an EXE. But I think you've figured that out already. If I remember correctly, we provide configurations for both 32 and 64 bits.
     
  5. Mike Crimlis

    Mike Crimlis Registered

    Joined:
    Jan 22, 2015
    Messages:
    12
    Likes Received:
    2
    Yes. Sorry, I meant .dll.
     
  6. Mike Crimlis

    Mike Crimlis Registered

    Joined:
    Jan 22, 2015
    Messages:
    12
    Likes Received:
    2
    I have the .dll working now and I can access the static outputs giving GetPluginName(), GetPluginType() and GetPluginVersion() using VB.NET code like this:

    Private Declare Function GetPluginVersion Lib "C:.........\InternalsPlugin.dll" () As Integer

    but now I need to create some dynamic outputs.
    I need to implement something similar to:

    extern "C" __declspec( dllexport )
    const char * __cdecl GetPluginName()

    and then call it in the void ExampleInternalsPlugin::UpdateTelemetry section ( I think). Once I have some dynamic outputs that are readable in the same way as the static values, I can leave the InternalsPlugin.dll alone and concentrate on the VB.NET code which will take those values, make sense of them and then tell my rams when, where and how to move.

    Any help will gratefully received
     
  7. Marcel Offermans

    Marcel Offermans Registered

    Joined:
    Oct 4, 2010
    Messages:
    653
    Likes Received:
    2,961
    Nice to hear you're making progress on this. I am not sure what your exact question (if any) is?!
     
  8. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    984
    Likes Received:
    984
    I am not super familiar with VB, but those internals .dll functions will get called by rF2 with data. Internals plugins writes that to the file. Calling those DLL functions from other won't give you telemetry info as they are receiving the info.

    BTW I am working on a plugin that writes out Telemetry and interpolated Scoring updates into shared memory file. I have it working, but just want to optimize some interpolation math in there. That shared memory file will be readable from other processes, and using most languages, so if you can wait, you may save yourself a bit of time :)
     
  9. Mike Crimlis

    Mike Crimlis Registered

    Joined:
    Jan 22, 2015
    Messages:
    12
    Likes Received:
    2
    Thank you both.
    That sounds good Iron Wolf, It may help a lot.

    My question really is: can anyone explain how I would change the fprintf commands such as:

    fprintf( fo, "LocalVel=(%.2f,%.2f,%.2f)\n", info.mLocalVel.x, info.mLocalVel.y, info.mLocalVel.z );

    To instead give an "entry point" that I can access the same way as I do for the values I'm getting from the extern "C" __declspec( dllexport ) functions?
    Once the values are shared with the outside world, I can use them and my problems will be over. If it weren't for the issue of access time, I would simply read them out of the ExampleInternalsTelemetryOutput.txt file.
    This is the way I'm used to dealing with .dll files. Declare the funtions and then access the data.
    I'm sure I will work it out eventually but it is really frustrating at the moment. I was all set to go with X-Sim but then realised that it has some very severe limitations so I decided to bite the bullet and go with the InternalsPlugin but this is not working so well.

    Maybe I will just put the motion on hold until I can go back to iRacing. The SDK/Wrapper is a much better method.

    Regards.

    Mike.
     
  10. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    984
    Likes Received:
    984
    I do not think there's entry point you're asking for (unless you create some COM object in plugin and call it via RPC, which is overkill) If you will wait a bit (2-4 weeks) you will be able to have object of rF2State in your code. I'll have C# sample on how to get that. Then, it will be xVelocity = state.mLocalVel.x :) Please note, my current plan is to do ~30FPS refresh if you use mutex, and 15FPS if not, not sure this is precise enough for you.
     

Share This Page