-
Notifications
You must be signed in to change notification settings - Fork 88
Description
Hi, I'm trying to make a self-diagnosis application for myself. The objective of my application is to provide a table to the user with all the parameters available to analyze and so that he can select which ones are of interest.
I had thought about using the library like this: (in the example string signal would be the data selected by the user, which would have a PID associated with it)
using SerialConnection connection = new SerialConnection("COM3");
// Se crea el objeto ELM327
using ELM327 dev = new ELM327(connection, new OBDConsoleLogger(OBDLogLevel.Debug));
// Se crea una lista con los posibles datos que se pueden diagnosticar
List OBDparameters = new List
{
new RealOBDParam(typeof(EngineCoolantTemperature),"05"),
new RealOBDParam(typeof(EngineRPM),"0C"),
new RealOBDParam(typeof(VehicleSpeed),"0D")
}
// Parametro seleccionado por el usuario
string signal = "0C"
// Buscar el parametro seleccionado por el usuario en la lista
foreach (var param in this.OBDparameters)
{
// RealTime
if (param.ParameterID == signal)
{
// Suscribirse a la acción correspondiente
dev.SubscribeDataReceived<param.ParameterType>((sender, data) => Console.WriteLine("Engine RPM: " + data.Data.Rpm));
dev.RequestData<param.ParameterType>();
break;
}
}
public class RealOBDParam
{
public Type ParameterType { get; set; } // Para guardar el tipo (como EngineRPM, VehicleSpeed, etc.)
public string ParameterID { get; set; } // Para guardar el nombre/descripción del parámetro
// Constructor para inicializar ambos campos
public RealOBDParam(Type parameterType, string parameterID)
{
this.ParameterType = parameterType;
this.ParameterID = parameterID;
}
}
Using the library in this way is not correct, can someone help me?