How to write program in Visual Studio to get data from Race0
Publicado: 16 Feb 2012 21:56
por xpolhecx
Hello
I need to write plugin in Visual Studio to get telemetry data from Race07 such as tire temperature, tire usage, fuel, rpm, speed.... Can someone give me information or link me some documentation on how to do it for Race07. I managed to write plugin for rfactor only :/
Can someone please help me how to start
Thanks in advance.
Re: How to write program in Visual Studio to get data from R
Publicado: 17 Feb 2012 02:09
por crobol
Hi, I have no experience on this kind of things, but I think you must read on RAM to get the data from Race07.
Re: How to write program in Visual Studio to get data from R
Publicado: 17 Feb 2012 14:23
por xpolhecx
Yes, that was the answer from Simbin support. Does somebody have experience or some information, how can i read data from RAM? Some example would be very helpful.
Hello,
Unfortunately, due to licence contracts, we cannot provide this kind of information.
I know some guys have made tools to display information on the HUd, but as far as I know, they just look for that data in the RAM and have to update the tool everytime we re-compile our binaries.
I'm sorry to have to answer you it's impossible...
Best regards,
J-F
Re: How to write program in Visual Studio to get data from R
Publicado: 17 Feb 2012 16:06
por willynovi
hi, as I know you need to do this:
Open \UserData\[playername]\[playername].plr with text editor and change line:
Write Shared Memory="0" to line: Write Shared Memory="1"
then find the name of the memory mapped file that Race07 use to share values.
write an aplication that manage mmf and take those values to use in your display.
Declare Function OpenFileMapping Lib "kernel32" Alias "OpenFileMappingA" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal lpName As String) As Long
Declare Function MapViewOfFile Lib "kernel32" (ByVal hFileMappingObject As Long, ByVal dwDesiredAccess As Long, ByVal dwFileOffsetHigh As Long, ByVal dwFileOffsetLow As Long, ByVal dwNumberOfBytesToMap As Long) As Long
Declare Function UnmapViewOfFile Lib "kernel32" (lpBaseAddress As Any) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal numbytes As Long)
Declare Sub GetMem4 Lib "msvbvm60.dll" (ByRef inSrc As Any, ByRef inDst As Long)
Declare Sub RtlMoveMemory2 Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByVal Source As Long, ByVal Length As Long)
Public Const GENERIC_READ As Long = &H80000000
Public Const GENERIC_WRITE As Long = &H40000000
Public Const FILE_SHARE_READ As Long = 1
Public Const FILE_SHARE_WRITE As Long = 2
Public Const CREATE_NEW As Long = 1
Public Const CREATE_ALWAYS As Long = 2
Public Const OPEN_EXISTING As Long = 3
Public Const OPEN_ALWAYS As Long = 4
Public Const TRUNCATE_EXISTING As Long = 5
Public Const INVALID_HANDLE_value As Long = -1
Public Const FILE_ATTRIBUTE_NORMAL As Long = &H80
Public Const FILE_ATTRIBUTE_READONLY = &H1
Public Const SECTION_MAP_READ = &H4
Public Const STANDARD_RIGHTS_REQUIRED = &HF0000
Public Const FILE_MAP_ALL_ACCESS = &HF0000
Public Const FILE_MAP_READ = SECTION_MAP_READ
Public Const SECTION_ALL_ACCESS = &HF0000
Public Type AAA_MMFR
MarxaActual As Long ' // -1=reverse, 0=neutral, 1+=forward gears
End Type
'Variables globals per l'us de MMF
Public hOldMMF As Long
Public SharedMemHandle As Long
Public SharedMemPointer As Long
Public MMFR As AAA_MMFR
Y luego ya puedes usarlo en tu form o en el bas principal de tu proyecto.
If SharedMemHandle = 0 Then
SharedMemHandle = OpenFileMapping(FILE_MAP_READ, True, "MiMMF")
If SharedMemHandle Then SharedMemPointer = MapViewOfFile(SharedMemHandle, FILE_MAP_READ, 0, 0, 0)
End If
Esto para liberar la MMF una vez salgas del programa o cuando tu creas conveniente:
'Allibero els punters i la MMF si estaven assignats i s'ha tancat el joc
If SharedMemPointer <> 0 Then
UnmapViewOfFile (SharedMemPointer)
SharedMemPointer = 0
End If
If SharedMemHandle <> 0 Then
CloseHandle (SharedMemHandle)
SharedMemHandle = 0
End If
Y esto para leer los valores que vienen del rFactor y mostrarlos donde tu quieras:
Re: How to write program in Visual Studio to get data from R
Publicado: 18 Feb 2012 13:38
por xpolhecx
Thank you. Its bad because i dont speak spanish and dont understand spanish comments :/ But you gave me an idea how to start with memory mapped files.
I managed to open MMF, now i just need to read some bytes and thats it. Any ideas?
Re: How to write program in Visual Studio to get data from R
Publicado: 21 Feb 2012 15:33
por xpolhecx
Problem solved, thanks
Re: How to write program in Visual Studio to get data from R
Publicado: 22 Feb 2012 03:17
por willynovi
I´m happy you find the solution,
and I hope soon you show us your project
Re: How to write program in Visual Studio to get data from R
Publicado: 23 Feb 2012 14:47
por xpolhecx
One more problem When i open MMF file ($Race$) i cant find scoring data like user standings, user best and last lap time, etc.... Any idea where those informations are located?
This is my DIY F1 Steering Wheel with my SLI BOARD electronics. Now i need to write plugins for many other games
Re: How to write program in Visual Studio to get data from R
Publicado: 23 Feb 2012 23:46
por willynovi
hey, this is your display? nice work
I use this struct for manage MMF for SimBin games, may it help you
Re: How to write program in Visual Studio to get data from R
Publicado: 24 Feb 2012 00:02
por xpolhecx
Thanks for edit my post
Yes this is my custom LCD display Thank you. I tryed to use structure but i didnt know how to, so i used second method. I am converting bytes to floating numbers. Can you explain or show me some example how do you use structure to get data?
This is my code. It's working fine, but its not perfect solution. I prefer if i could use structure So byte 24 represents actual RPM, byte 28 is max RPM? How come MAX RPM is around 800. Shouldnt be at least couple of thousand?
Re: How to write program in Visual Studio to get data from R
Publicado: 04 Mar 2012 16:57
por xpolhecx
Ok i am finally on right track I have to find pointers to RAM address to access data i need It will took me some time to finish my project and write support for many, many games, but no problem
Re: How to write program in Visual Studio to get data from R
Publicado: 20 Mar 2012 20:44
por xpolhecx
Re: How to write program in Visual Studio to get data from R
Publicado: 16 Nov 2012 09:14
por KayPetri
Hello im from germany. im looking for a tool to integrate a tv plugin for simbin products. for simbin there is nothing in web to find, so i will code such think. i read this thread i find some very interesting snipets. the user "xpolhecx" could solve his problems. Now im need more informations how to get the mmf data and how to use in vb.
Could anyone write down a tutorial?
Excuse me for my bad english, but i think someone understand me and my opinion.
Re: How to write program in Visual Studio to get data from R
Publicado: 04 Mar 2013 23:53
por henrikl2000
Hi KayPetri,
Maybe I can help you a little or we could join forces. I am programming in VB too. Let me know if you are interested. My email is henrik@nuhme.dk
I speak German if that helps.
Re: How to write program in Visual Studio to get data from R
Publicado: 05 Mar 2013 10:25
por henrikl2000
Hi,
Where can I find the MMF Visualizer ?
TIA
Re: How to write program in Visual Studio to get data from R
Publicado: 06 Mar 2013 17:31
por henrikl2000
Hi,
Anyone who could help me out. I am new to C# / C++. My test prgm connects with the Memory Mapped File but how do I get data from it ?
Any source code (VB, C# or C++) that could help solving my problem is welcome. I speak Danish, English and German but no Spanish :-)
Thank's in advance.
Re: How to write program in Visual Studio to get data from R
Publicado: 07 Mar 2013 12:19
por crobol
Sorry, at this moment seems people who can help on VB and C programming are not visiting our forum.
Have you tried at http://www.x-simulator.de/forum/ ??
Re: How to write program in Visual Studio to get data from R
Publicado: 07 Mar 2013 12:45
por henrikl2000
Thank you for your reply. I've been there, but no luck. I am close to a solution now (I think) but I am not a C programmer. I have done a lot of programming in VB. I have a new friend in racedepartment.com and he has helped me with C++.
Why does the screen get black when you click on this page ?