outlandnish / strados

Transform OBD2 data from your car into human readable data
MIT License
35 stars 10 forks source link

General Start Up: Connections, Etc. #1

Open matthewjonesvsp opened 6 years ago

matthewjonesvsp commented 6 years ago

This seems like a great platform. Is anyone following this? Not new to programming but I am no expert neither. Looking for a general foundation to get started on connection.

Any ideas?

outlandnish commented 6 years ago

Hey, thanks for taking a look! I wrote this code about 4 or so years ago but I still remember a decent amount of it. What would you like help with?

matthewjonesvsp commented 6 years ago

Well its some very solid code in regards to OBDII and probably some of the more organized code I have seen.

Honestly I am looking for some start up to get started on developing a connection with a OBDII USB device. I am actually writing some code in VB.net but could probably copy over to C# with minimal issues.

I have looked through the code and was just curious is you could help me get started on developing an actual connection with your code. Once I get the connection between the computer and vehicle, I think I would be good to go, for now.

matthewjonesvsp commented 6 years ago

In short, I have an already established connection using some generic VB code. Working great with the OBDII USB device. Primarily I need help with: obtaining the VIN of the vehicle.

I like your code way better than any other code I have seen. It appears our code is producing a lot more information than other code I have come across.

outlandnish commented 5 years ago

@matthewjonesvsp sorry, I completely forgot to revisit your question. Depending on the chipset you use, you can write an IVehicleService implementation. The example provided uses the popular Elm327 chipset (and works for STN chipsets with ELM backward compatability).

In your code, you would open up a connection to the device. If via USB, this would be a COM connection with an input stream and an output stream. If via Bluetooth, it would be the same using your platform's C# Bluetooth implementation. The code is generic enough to take any type of Stream object and read and write from them.

Once you have a stream setup, you can then run the following methods:

ConnectToVehicle() - which for the ELM327 sends a reset command, turns off headers, and detects the vehicle protocol. This in turn calls GetReportedPids to see what the OBD2 bus "officially supports" and then GetSupportedPids to see what the ECUs respond with (which might be different).

From here, you can use the Run methods to get OBD2 data from the bus and pass the data to the OBDParser class. You will have to write your own implementation because I had never gotten around to that implementation when I originally wrote this library.

Good luck and feel free to ping me for any other help!