How to write program in Visual Studio to get data from Race0
Moderador: XRStaff
How to write program in Visual Studio to get data from Race0
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.
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.
- crobol
- Maestro al volante
- Mensajes: 13867
- Registrado: 28 Abr 2007 00:00
- Volante: DFP
- Ubicación: BCN
- Contactar:
Re: How to write program in Visual Studio to get data from R
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
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
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
- willynovi
- Piloto Histórico
- Mensajes: 1177
- Registrado: 17 Mar 2009 01:00
- Volante: 100% DIY, prox. con FFB
- Ubicación: Argentina
- Contactar:
Re: How to write program in Visual Studio to get data from R
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.
here you have a very useful link in X-Sim Forum
http://www.x-simulator.de/wiki/How-to_f ... _%28MMF%29
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.
here you have a very useful link in X-Sim Forum
http://www.x-simulator.de/wiki/How-to_f ... _%28MMF%29
Re: How to write program in Visual Studio to get data from R
Thank you for that. I will try and report back.
Re: How to write program in Visual Studio to get data from R
Ok i managed to see data in MMF Visualizer. Can someone give me example, how to use this MMF file in Visual Studio and read data from it?
- willynovi
- Piloto Histórico
- Mensajes: 1177
- Registrado: 17 Mar 2009 01:00
- Volante: 100% DIY, prox. con FFB
- Ubicación: Argentina
- Contactar:
Re: How to write program in Visual Studio to get data from R
Nye would answer in just one minute
maybe this quote help you, it is an example with rFactor but with minors modification should work with Race07
maybe this quote help you, it is an example with rFactor but with minors modification should work with Race07
Esto es mas o menos lo que va en la parte de VB
En un módulo BAS define las cosas 'gordas':Y luego ya puedes usarlo en tu form o en el bas principal de tu proyecto.Código: Seleccionar todo
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
Esto para abrir la MMF desde VB:Esto para liberar la MMF una vez salgas del programa o cuando tu creas conveniente:Código: Seleccionar todo
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
Y esto para leer los valores que vienen del rFactor y mostrarlos donde tu quieras:Código: Seleccionar todo
'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
El tipo de usuario MMFR contiene ahora los datos que vienen del rFactor.Código: Seleccionar todo
GetMem4 ByVal SharedMemPointer, hOldMMF RtlMoveMemory2 MMFR, (SharedMemPointer), LenB(MMFR) + 4 '+4 perque sino el primer valor no es rep.
Si haces algo asi como:En el label1 de tu form se mostrará la marcha del coche. O deberíaCódigo: Seleccionar todo
label1.caption=MMFR.MarxaActual
- willynovi
- Piloto Histórico
- Mensajes: 1177
- Registrado: 17 Mar 2009 01:00
- Volante: 100% DIY, prox. con FFB
- Ubicación: Argentina
- Contactar:
Re: How to write program in Visual Studio to get data from R
and no so far away, this helpfull link
viewtopic.php?f=84&t=4965&start=50
viewtopic.php?f=84&t=4965&start=50
Re: How to write program in Visual Studio to get data from R
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?
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
Problem solved, thanks
- willynovi
- Piloto Histórico
- Mensajes: 1177
- Registrado: 17 Mar 2009 01:00
- Volante: 100% DIY, prox. con FFB
- Ubicación: Argentina
- Contactar:
Re: How to write program in Visual Studio to get data from R
I´m happy you find the solution,
and I hope soon you show us your project
and I hope soon you show us your project
Re: How to write program in Visual Studio to get data from R
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
This is my DIY F1 Steering Wheel with my SLI BOARD electronics. Now i need to write plugins for many other games
Última edición por xpolhecx el 25 Feb 2012 16:40, editado 1 vez en total.
- willynovi
- Piloto Histórico
- Mensajes: 1177
- Registrado: 17 Mar 2009 01:00
- Volante: 100% DIY, prox. con FFB
- Ubicación: Argentina
- Contactar:
Re: How to write program in Visual Studio to get data from R
hey, this is your display? nice work
I use this struct for manage MMF for SimBin games, may it help you
I dont know how to get scoring data
I use this struct for manage MMF for SimBin games, may it help you
Código: Seleccionar todo
struct MMFSimBin
{
float userInputs[6]; // 0 - 23
float ActualEngineRPM; // 24
float EngineMaxRPM; // 28
float ActualFuelPressure; // 32
float ActualFuelLiters; // 36
float FuelCapacityLiters; // 40
float ActualEngineWaterTemp; // 44
float ActualEngineOilTemp; // 48
float ActualEngineOilPressure;// 52
float ActualVel; // 56
float costants[7]; // 60 - 87
long ActualGear; // 88
}MMFGTR;
Re: How to write program in Visual Studio to get data from R
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?
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?
Código: Seleccionar todo
typedef unsigned char uchar;
float bytesToFloat(uchar b3, uchar b2, uchar b1, uchar b0)
{
float output;
*((uchar*)(&output) + 3) = b0;
*((uchar*)(&output) + 2) = b1;
*((uchar*)(&output) + 1) = b2;
*((uchar*)(&output) + 0) = b3;
return output;
}
BYTE *pFile;
TCHAR szName[] = TEXT("$Race$");
HANDLE hMapFile;
LPCTSTR pBuf;
hMapFile = OpenFileMapping(FILE_MAP_READ, true, szName);
if(hMapFile == NULL) {
this->label12->Text = "Error opening MMF";
}
else {
pFile = (BYTE*)MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);
if(pFile == NULL) {
this->label12->Text = "Error reading MMF";
}
else {
float speed = bytesToFloat(pFile[56], pFile[57], pFile[58], pFile[59]) * 3.6;
speed = floor(speed + 0.5);
gear = pFile[88].ToString();
}
}
UnmapViewOfFile(pFile);
CloseHandle(hMapFile);
Re: How to write program in Visual Studio to get data from R
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
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.
Could anyone write down a tutorial?
Excuse me for my bad english, but i think someone understand me and my opinion.
-
- Espectador
- Mensajes: 4
- Registrado: 04 Mar 2013 23:37
Re: How to write program in Visual Studio to get data from R
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.
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.
-
- Espectador
- Mensajes: 4
- Registrado: 04 Mar 2013 23:37
Re: How to write program in Visual Studio to get data from R
Hi,
Where can I find the MMF Visualizer ?
TIA
Where can I find the MMF Visualizer ?
TIA
-
- Espectador
- Mensajes: 4
- Registrado: 04 Mar 2013 23:37
Re: How to write program in Visual Studio to get data from R
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.
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.
- crobol
- Maestro al volante
- Mensajes: 13867
- Registrado: 28 Abr 2007 00:00
- Volante: DFP
- Ubicación: BCN
- Contactar:
Re: How to write program in Visual Studio to get data from R
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/ ??
Have you tried at http://www.x-simulator.de/forum/ ??
-
- Espectador
- Mensajes: 4
- Registrado: 04 Mar 2013 23:37
Re: How to write program in Visual Studio to get data from R
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 ?
Why does the screen get black when you click on this page ?