How to write program in Visual Studio to get data from Race0

For non-spanish speakers. (Type in English please)

Moderador: XRStaff

Responder
xpolhecx
Espectador
Espectador
Mensajes: 10
Registrado: 16 Feb 2012 21:44

How to write program in Visual Studio to get data from Race0

Mensaje por xpolhecx » 16 Feb 2012 21:56

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.
Avatar de Usuario
crobol
Maestro al volante
Maestro al volante
Donante
Donante
Licencia B
Licencia B
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

Mensaje por crobol » 17 Feb 2012 02:09

Hi, I have no experience on this kind of things, but I think you must read on RAM to get the data from Race07.
xpolhecx
Espectador
Espectador
Mensajes: 10
Registrado: 16 Feb 2012 21:44

Re: How to write program in Visual Studio to get data from R

Mensaje por xpolhecx » 17 Feb 2012 14:23

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
Avatar de Usuario
willynovi
Piloto Histórico
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

Mensaje por willynovi » 17 Feb 2012 16:06

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
xpolhecx
Espectador
Espectador
Mensajes: 10
Registrado: 16 Feb 2012 21:44

Re: How to write program in Visual Studio to get data from R

Mensaje por xpolhecx » 17 Feb 2012 16:43

Thank you for that. I will try and report back.
xpolhecx
Espectador
Espectador
Mensajes: 10
Registrado: 16 Feb 2012 21:44

Re: How to write program in Visual Studio to get data from R

Mensaje por xpolhecx » 17 Feb 2012 20:25

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?
Avatar de Usuario
willynovi
Piloto Histórico
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

Mensaje por willynovi » 17 Feb 2012 20:43

Nye would answer in just one minute :lol:

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':

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
Y luego ya puedes usarlo en tu form o en el bas principal de tu proyecto.

Esto para abrir la MMF desde VB:

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
Esto para liberar la MMF una vez salgas del programa o cuando tu creas conveniente:

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
Y esto para leer los valores que vienen del rFactor y mostrarlos donde tu quieras:

Código: Seleccionar todo

GetMem4 ByVal SharedMemPointer, hOldMMF
  RtlMoveMemory2 MMFR, (SharedMemPointer), LenB(MMFR) + 4 '+4 perque sino el primer valor no es rep.
El tipo de usuario MMFR contiene ahora los datos que vienen del rFactor.
Si haces algo asi como:

Código: Seleccionar todo

label1.caption=MMFR.MarxaActual
En el label1 de tu form se mostrará la marcha del coche. O debería
Avatar de Usuario
willynovi
Piloto Histórico
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

Mensaje por willynovi » 17 Feb 2012 20:50

and no so far away, this helpfull link
viewtopic.php?f=84&t=4965&start=50
xpolhecx
Espectador
Espectador
Mensajes: 10
Registrado: 16 Feb 2012 21:44

Re: How to write program in Visual Studio to get data from R

Mensaje por xpolhecx » 18 Feb 2012 13:38

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?
xpolhecx
Espectador
Espectador
Mensajes: 10
Registrado: 16 Feb 2012 21:44

Re: How to write program in Visual Studio to get data from R

Mensaje por xpolhecx » 21 Feb 2012 15:33

Problem solved, thanks
Avatar de Usuario
willynovi
Piloto Histórico
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

Mensaje por willynovi » 22 Feb 2012 03:17

I´m happy you find the solution, :cheers:
and I hope soon you show us your project :wink:
xpolhecx
Espectador
Espectador
Mensajes: 10
Registrado: 16 Feb 2012 21:44

Re: How to write program in Visual Studio to get data from R

Mensaje por xpolhecx » 23 Feb 2012 14:47

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?

Imagen

This is my DIY F1 Steering Wheel with my SLI BOARD electronics. Now i need to write plugins for many other games :)

http://www.youtube.com/watch?v=cAUrHhqHcFU

Imagen Imagen Imagen Imagen
Imagen Imagen Imagen Imagen
Imagen Imagen
Última edición por xpolhecx el 25 Feb 2012 16:40, editado 1 vez en total.
Avatar de Usuario
willynovi
Piloto Histórico
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

Mensaje por willynovi » 23 Feb 2012 23:46

hey, this is your display? nice work :oks:

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;
I dont know how to get scoring data :blush:
xpolhecx
Espectador
Espectador
Mensajes: 10
Registrado: 16 Feb 2012 21:44

Re: How to write program in Visual Studio to get data from R

Mensaje por xpolhecx » 24 Feb 2012 00:02

Thanks for edit my post :wink:

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);
xpolhecx
Espectador
Espectador
Mensajes: 10
Registrado: 16 Feb 2012 21:44

Re: How to write program in Visual Studio to get data from R

Mensaje por xpolhecx » 04 Mar 2012 16:57

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 :)
KayPetri
Espectador
Espectador
Mensajes: 1
Registrado: 16 Nov 2012 08:52

Re: How to write program in Visual Studio to get data from R

Mensaje por KayPetri » 16 Nov 2012 09:14

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.
henrikl2000
Espectador
Espectador
Mensajes: 4
Registrado: 04 Mar 2013 23:37

Re: How to write program in Visual Studio to get data from R

Mensaje por henrikl2000 » 04 Mar 2013 23:53

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.
henrikl2000
Espectador
Espectador
Mensajes: 4
Registrado: 04 Mar 2013 23:37

Re: How to write program in Visual Studio to get data from R

Mensaje por henrikl2000 » 05 Mar 2013 10:25

Hi,
Where can I find the MMF Visualizer ?
TIA
henrikl2000
Espectador
Espectador
Mensajes: 4
Registrado: 04 Mar 2013 23:37

Re: How to write program in Visual Studio to get data from R

Mensaje por henrikl2000 » 06 Mar 2013 17:31

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.
Avatar de Usuario
crobol
Maestro al volante
Maestro al volante
Donante
Donante
Licencia B
Licencia B
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

Mensaje por crobol » 07 Mar 2013 12:19

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/ ??
henrikl2000
Espectador
Espectador
Mensajes: 4
Registrado: 04 Mar 2013 23:37

Re: How to write program in Visual Studio to get data from R

Mensaje por henrikl2000 » 07 Mar 2013 12:45

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 ?
Responder

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 1 invitado