[REL] rF2 Shared Memory Tools for Developers

Discussion in 'Other' started by The Iron Wolf, Jan 19, 2017.

  1. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    984
    Likes Received:
    984
    CC thread has all documented, but still a good point, will do on next refresh.
     
  2. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    984
    Likes Received:
    984
    Plugin is updated to 1.0.0.1, minor bug fixes.
     
    Erick3331 likes this.
  3. I_Bellett

    I_Bellett Registered

    Joined:
    Jan 12, 2012
    Messages:
    200
    Likes Received:
    277
    Nice work.
     
  4. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    984
    Likes Received:
    984
    Thank you! :)
     
  5. Rich Goodwin

    Rich Goodwin Registered

    Joined:
    May 3, 2012
    Messages:
    1,219
    Likes Received:
    9
    How does one properly utilise this?

    I'm working on an Arduino dash and I guess I can use this to take the data from the sim and put it on the arduino. An app of some sort in the middle to read from this and send it to the Arduino.

    Any help would be appreciated.
     
  6. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    984
    Likes Received:
    984
    Hi Rich,
    See the Monitor application sample included with this project. Briefly, plugin writes to a shared memory file, and you can map it to structure in C# or possibly other languages. Arduino sounds low level to me so is it C? (wild guess) Then, you would just include my rF2state.h, read the file, and access memory through pointer to rF2State struct (respecting the pack).

    The best thing about this approach is minimal FPS impact, you don't do any heavy logic inside of rF2 this way. Cheers!
    Vytautas
     
    Last edited: Mar 21, 2017
  7. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    984
    Likes Received:
    984
    new version is, please note it breaks the layout (added one byte), so if anyone is using this but me, update your header.

    3/22/2017 - v1.1.0.1

    Plugin:

    • Replaced rF2State::mInRealTime with mInRealTimeFC and mInRealTimeSU values, to distiguish between InRealtime state reported via ScoringUpdate, and via Enter/ExitRealtime calls.
    • rF2State::mCurrentET is no longer updated between Scoring Updates, and matches value last reported by the game.
    Monitor:

    • Extended monitor to dislay more information
    • Implemented correct "Best Split" time calculation logic.
     
    alpha-bravo likes this.
  8. k3nny

    k3nny Registered

    Joined:
    Jan 20, 2013
    Messages:
    84
    Likes Received:
    2
    Hi Iron Wolf,

    thanks for this plugin, it is very cool that you share your work.

    Now to my question, I want to use your plugin to fill my LCD Display, because I realized that my first UDP solution is to slow.

    Now I´m hanging at the point that I can access the mmap file via Python, but I don´t find out how the order of the data realy are, because my knowledge of C# or C++ are not very great, I don´t understand in which order you save the data in the mmap. I have tried a bit but the data I expect at a certain point are not the ones that are stored in the mmap. The debug text file confused me in the same way, because the expected data are not on the position I search.
    Now I hope for your help, do you maybe have an overview in which order the data are stored?

    Thanks for your help.
    kind regards
    k3nny
     
  9. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    984
    Likes Received:
    984
    Hi K3nny,

    Thanks for the kind words :) Having this in the open is the only way to ensure project won't die if I decide to go away into say, Arma :D It is great to see people find this work useful.

    We are somewhat in a same boat, I know nothing about Python, other than it is a pain :). That said:
    C struct to rF2 internals: https://github.com/TheIronWolfModding/rF2SharedMemoryMapPlugin/blob/master/Include/rF2State.h
    C# marshaling struct: https://github.com/TheIronWolfModdi.../Monitor/rF2SMMonitor/rF2SMMonitor/rF2Data.cs

    I did a quick research, and from what I understand, copy mapped buffer to local bytes using mmap (if 15FPS is enough, read just one buffer). Then, https://docs.python.org/2/library/struct.html you need to map those bytes into C like struct respecting my pack/padding. It is not clear to me if you will be able to use 16 byte pack in Python, and my structures are using 16 bytes for 64bit binary.

    There's a caveat though, I am working on version 2 of a plugin, which will very different internally, but not so different to consume (1 day of rework for clients). There will be separate buffers for Telemetry/Scoring/Rules etc. V2 will have 4byte pack, so if for some reason you can't read 16byte pack easily in Python, you may want to wait for V2.

    Hope this helps, let me know how it goes.
    Vytautas
     
    Last edited: May 19, 2017
  10. k3nny

    k3nny Registered

    Joined:
    Jan 20, 2013
    Messages:
    84
    Likes Received:
    2
    Hi Iron Wolf,

    thanks for your help, that I don´t find the right position of the mSpeed value was my fault. I forget to assign 3 values to mPos, mLocalVel and mLocalAccel and the result was 6 values I can´t assign.:rolleyes:
    That what I mean, my knowledge of this kind of programming are very limited with inheritance in C, but now I´m smarter.
    Python has no problem with 16 Byte instead of 4 Byte. I choose Python because it is very simple and you earn big result with a short code and less complexity. Now it is diligently to apply all the data to my program.

    Attached a picture of the one of the screens of the new display that I want realize with a nextion 2.8 TFT Display.
    Unbenannt.jpg

    Neverless thanks for your and sorry for the cunfusion and my inexperience.

    regards k3nny
     
    Last edited: May 19, 2017
  11. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    984
    Likes Received:
    984
    Glad you figured it out, keep me posted, and expect breaking changes coming soon :)
     
  12. k3nny

    k3nny Registered

    Joined:
    Jan 20, 2013
    Messages:
    84
    Likes Received:
    2
    Hi Iron Wolf, after a few frustration evenings, I´m glad to say, the display works as espected and thank you for your great work.
    I have 3 display pages with the following informations.

    Weather conditions
    Tire and brake temp
    status info ( like position, fuel, lap, track position, time left etc..)

    For first I´m happy with the result and maybe I will expand it in the future.

    Regards k3nny
     
  13. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    984
    Likes Received:
    984
    Hi Kenny,

    I am glad you are making progress.

    I hope you still have some patience left, because a bit more frustration is coming. V2 is almost ready, you may want to start porting to it, because I'll start porting Crew Chief to it next week (and CC will overwrite plugin as soon as update ships). It is unfortunate that V2 is not backwards compatible, but I needed to change architecture to fully expose rF2 model.

    V2 is currently in experimental_rules branch, monitor is 80% ported. Let me know if you've questions.
    Vytautas
     
    Last edited: Jun 4, 2017
  14. k3nny

    k3nny Registered

    Joined:
    Jan 20, 2013
    Messages:
    84
    Likes Received:
    2
    Hi Iron Wolf,

    nice to see that you make progress with the V2 version.

    I have one question, I have found a strange behavior which I can´t figure out where is the error. I use mTotalLaps to indicate how many laps I already drove. But everytime when I´m not alone on the server the value jumps several times between my laps count and the other driver on the server.
    I checked everything but I didn´t find a solution why the laps count jump, because the mTotalLaps are in rF2VehicleScoring and not in rF2ScoringInfo, in my opinion, mTotalLaps should have no reference to the other driver but only to me, or?

    Do you have any idea why the value jump?

    Regrads k3nny
     
  15. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    984
    Likes Received:
    984
    Hi Kenny,

    This is the known issue, see here: https://github.com/TheIronWolfModding/rF2SharedMemoryMapPlugin/issues/2

    I haven't bothered releasing the fix because V2 is coming and I am wrapping that up. V2 is not making this simple assumption (that entry 0 is the player) - client applications will have to figure out which vehicle player is themselves. If you want, I can release the patch, but old version will be overwritten by the Crew Chief as soon as I am done migrating, so I really think you should start migrating to V2 instead.

    Is your program something you use only yourself? Do you use Crew Chief? If not, I could release a patch?

    Cheers!
    Vytautas
     
    Last edited: Jun 21, 2017
  16. k3nny

    k3nny Registered

    Joined:
    Jan 20, 2013
    Messages:
    84
    Likes Received:
    2
    Hi Iron Wolf,

    oh that I overlooked, I only read the first post of the issue with the speed and didn´t combine it with my behavior. But it would be very nice when you release the patch, when it is not too much work for you.

    I don´t use crew chief. My script for the nextion display is only for my use.

    Thanks for your help
    cheers k3nny
     
  17. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    984
    Likes Received:
    984
    Oh good, if it's only for your use, I'll patch it, no problem :) Will send you binary in the next couple of days.
     
  18. k3nny

    k3nny Registered

    Joined:
    Jan 20, 2013
    Messages:
    84
    Likes Received:
    2
    I have checked the answer in the issue thread, have you assume the code in the last comment, when yes, you don´t have to release it, that I can insert for my self in the branch of version V1 you released.
     
  19. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    984
    Likes Received:
    984
    That's best possible fix :) no work for me :D let me know if it works.
     
  20. k3nny

    k3nny Registered

    Joined:
    Jan 20, 2013
    Messages:
    84
    Likes Received:
    2
    It works so long, now I have to wait for my maite, that he comes on the server to check if the correct value is shown.
     
    The Iron Wolf likes this.

Share This Page