Merci d'être réactif !!
Oui effectivement...
Voici les étapes que j'ai suivi (je fais peut-être un grosse gaffe

) :
1)j'ai versé dans l'arduino ce code :
- Code: Select all
// X-Sim Sample code for receiving OBD2 values from the extractor without using the converter
// OBD2 is industry standard, X-Sim will additionally expand the OBD2 PID with gear and other values
//
// Usage:
// Arduino has to be connected to a free USB port on the computer where the extractor is running
// Open the extractor and open the settings menu, there you have to select the OBD2 menu
// Add now your arduino comport to the OBD2 list.
// After closing the dialog you will see the arduino LED will be enabled which represents receiving data.
// After closing the extractor application the LED will switch off.
// Use this code to insert your own display code at the fitting positions
// Copyright 2013 Martin Wiedenbauer, X-Sim.de
//
// References:
// http://en.wikipedia.org/wiki/OBD-II_PIDs
// http://elmelectronics.com/DSheets/ELM327DS.pdf
// http://www.x-sim.de
#include <LiquidCrystal.h>
bool extractordetected=false; //Will get updated from last positive or negative receive
int receivebuffer[20]={0}; //Receive buffer
LiquidCrystal lcd(11,10,9,8,7,6,5,4,3,2);// initialise l'écran avec les bonnes broches
// ATTENTION, REMPLACER LES NOMBRES PAR VOS BRANCHEMENTS À VOUS !
char rapport[5] = "Gear";
char trmin[5] = "Rpm";
char speed1[8] = "Speed";
char speedunit[5] = "km/h";
char message[16] = "";
char message1[16] = "";
void setup()
{
pinMode(13, OUTPUT); //Arduino UNO LED off
digitalWrite(13, HIGH);
Serial.begin(9600);
//Do here stuff to init display and zero to default
lcd.begin(16, 2);
lcd.print("test OBD2 com !");
delay(3000);
lcd.clear();
}
int HexToInt(int c)
{
if (c >= '0' && c <= '9')
{
return c - '0';
}
else if (c >= 'a' && c <= 'f')
{
return c - 'a' + 10;
}
else if (c >= 'A' && c <= 'F')
{
return c - 'A' + 10;
}
else
{
return -1; // getting here is bad: it means the character was invalid
}
}
int ParseReceiveBuffer(int commandhighbyte, int commandlowbyte, int receivelength)
{
//First character is removed of the receivebuffer string and must not be verified again
if( receivebuffer[0]=='1' && receivebuffer[2]==commandhighbyte && receivebuffer[3]==commandlowbyte )
{
//Parse 2 byte values on position 5 and 6 in the buffer string
if(receivelength==7)
{
int highresult=HexToInt(receivebuffer[5]);
int lowresult =HexToInt(receivebuffer[6]);
if(highresult==-1 || lowresult==-1){return -1;}
return ((16*highresult) + lowresult);
}
//Parse 4 byte values on position 5,6,8 and 9 in the buffer string
if(receivelength==10)
{
int tophighresult=HexToInt(receivebuffer[5]);
int toplowresult =HexToInt(receivebuffer[6]);
int highresult=HexToInt(receivebuffer[8]);
int lowresult =HexToInt(receivebuffer[9]);
if(tophighresult==-1 || toplowresult==-1 || highresult==-1 || lowresult==-1){return -1;}
return ((4096*tophighresult) + (256*toplowresult) + (highresult) + lowresult);
}
}
return -1; //Something is wrong with the returned OBD2 echo command byte
}
//This function will wait for the first character in receivetrigger and will parse the result
int ReceiveValueWithTimeout(int receivetrigger, int commandhighbyte, int commandlowbyte, int receivelength)
{
int arduinoserialbuffer=0;
int buffercount=-1;
for(int z=0; z < 1500; z++) //1500ms timeout should be enough
{
while(Serial.available())
{
if(buffercount==-1)
{
arduinoserialbuffer = Serial.read();
if(arduinoserialbuffer != receivetrigger) //Wait until the trigger is reached, ignore echo, first character is not in the buffer
{
buffercount=-1;
}
else
{
buffercount=0;
}
}
else
{
arduinoserialbuffer = Serial.read();
receivebuffer[buffercount]=arduinoserialbuffer;
buffercount++;
if(buffercount > receivelength) //buffer has now waitlen character length
{
return ParseReceiveBuffer(commandhighbyte, commandlowbyte, receivelength);
buffercount=-1;
}
}
}
delay(1);
}
return -1;
}
void SendEchoDisabled() //not used here and a part of the OBD2 ELM327 specifications, as INFO
{
//ATE0 Echo disabled
Serial.write('A');
Serial.write('T');
Serial.write('E');
Serial.write('0');
Serial.write('\r');
}
//010c Request RPM, remember: OBD2 RPM is ((A*256)+B)/4
int GetOBD2RpmValue()
{
//010c
Serial.write('0');
Serial.write('1');
Serial.write('0');
Serial.write('c');
Serial.write('\r');
return ReceiveValueWithTimeout('4','0','C',10);
}
//010d Request speed in kmh
int GetOBD2SpeedValue()
{
//010d
Serial.write('0');
Serial.write('1');
Serial.write('0');
Serial.write('d');
Serial.write('\r');
return ReceiveValueWithTimeout('4','0','D',7);
}
//01e0 Request gear number
int GetOBD2GearValue()
{
//01e0
Serial.write('0');
Serial.write('1');
Serial.write('e');
Serial.write('0');
Serial.write('\r');
return ReceiveValueWithTimeout('4','E','0',7);
}
void loop()
{
int speed=0;
int rpm=0;
int gear=GetOBD2GearValue();
while(gear >= 0)
{
if(extractordetected==false)
{
SendEchoDisabled(); //Will cause a OK\r as answer from the extractor, ignored in this code
extractordetected=true;
}
//Read all values
gear = GetOBD2GearValue(); //Notice: offset +1 because of reverse gear
speed= GetOBD2SpeedValue();
rpm = GetOBD2RpmValue();
rpm=rpm/4;
if(gear!=-1 && speed!=-1 && rpm!=-1)
{
digitalWrite(13, LOW); //We have connection and all values are ok, turn on the LED
//Do here your LCD or display stuff
char* neutral = "n"; // sets the character for neutral
char* reverse = "r"; // sets the character for reverse
//
if (gear==0){
sprintf(message,"%s:%s %s:%5d",rapport, reverse , trmin, rpm);
sprintf(message1,"%s:%3d %s",speed1, speed , speedunit);
lcd.setCursor(0,0);
lcd.write(message); //envoi le message sur l'écran 1 ere ligne
lcd.setCursor(0,1);
lcd.write(message1); //envoi le message sur l'écran 2 eme ligne
}
if (gear==1){
sprintf(message,"%s:%s %s:%5d",rapport, neutral , trmin, rpm);
sprintf(message1,"%s:%3d %s",speed1, speed , speedunit);
lcd.setCursor(0,0);
lcd.write(message); //envoi le message sur l'écran 1 ere ligne
lcd.setCursor(0,1);
lcd.write(message1); //envoi le message sur l'écran 2 eme ligne
}
if (gear >= 2 and gear <10 ){
sprintf(message,"%s:%d %s:%5d",rapport, gear-1 , trmin, rpm);
sprintf(message1,"%s:%3d %s",speed1, speed , speedunit);
lcd.setCursor(0,0);
lcd.write(message); //envoi le message sur l'écran 1 ere ligne
lcd.setCursor(0,1);
lcd.write(message1); //envoi le message sur l'écran 2 eme ligne
}
}
}
extractordetected=false;
digitalWrite(13, HIGH); //No connection, turn off the LED
//Do here stuff to set display to zero or default
lcd.setCursor(0,0);
lcd.write("-Extractor OFF!-");
delay(2000); //No serial connection, poll serial port all two seconds + readtimeout until a running extractor is detected
lcd.clear();
}
Ce qui a fonctionné.
2)Ensuite, je lance extractor. Je vais dans OBD2 interface settings puis sélectionne le port dans lequel l'arduino apparait.
3) Je lance le jeu : LFS en particulier par le bouton Play.
3bis

) J'essai également un reset de l'arduino, qui remet "OBD2 test com" puis de nouveau "Extractor OFF".
Remarque, le prog OUTSIM ressort bien les valeurs de télémétrie, donc à priori le plugin est le bon...