DarthAffe / OBD.NET

C#-Library to read data from car through an ELM327-/STN1170-Adapter
GNU General Public License v2.0
178 stars 82 forks source link

Establishing connection #31

Open Szabzi opened 9 months ago

Szabzi commented 9 months ago

Hi there, thanks for the library. I have a question which might be really dumb but if I implement this into a unity project, do I need to implement the connection with my own code before connecting OBD.NET to that comport or is that all done in your library? I can't seem to connect my app to the obd even though other apps work. In the unity project the script to connect is mostly taken from the example console program you provided. Am I missing something? Thanks.

DarthAffe commented 9 months ago

In the example everything regarding the connection is handled in the SerialConnection that you configure with the serial-port. The connection is opened when dev.Initialize is called.

What's perfectly possible though is, that this implementation does not work in unity-apps (They might have some limitations/different way of handling IO) in that case you might need to implement the ISerialConnection-interface with something Unity-specific. But I don't have any experience with unity, which makes it quite hard to be sure if that's really the case. Do you see any exceptions when requesting data?

Szabzi commented 9 months ago

I figured out that the freeze happens because of _serialPort.Open() in SerialConnections. No exceptions because if I don't comment out this line the whole editor freezes. I found some people online having issues with this function so maybe I can go from there. Btw it definately is a Unity thing because I can get your console project to open the port. Anyways thanks your help and this repo.