问题
I have to do an Android application that reads value via Bluetooth from a Bluetooth device connected to OBD-II port of a car.
I use the UUID SPP UUID 00001101-0000-1000-8000-00805F9B34FB .
If I create 4 threads that want to connect to the OBD-II device, 3 connect()
s fail and only one thread is able to connect to the device.
Is there a way to connect more thread to an OBD-II device via Bluetooth?
I don't know if the elm-237
device is able to communicate with more threads.
回答1:
I am not an expert on OBD/OBD-II, but I know a little on serial ports.
Actually, what you see does not surprise me at all. Serial-port devices usually must operate in exclusive mode, so only one actor can talk to them at a single point of time. There is totally no point in creating multiple threads for that - this will not make your serial port "talk faster", nor it will make the external device (OBD chip) respond faster! This is not a network! To talk to several devices in parallel, you'd need to have actual several cables - and probably also several chips.
ELM327 is the device in your OBD-2 cable. It mediates the communication between the chips in the car and your USB port and exposes a virtual serial port over USB bus. I never heard of any cheap Bluetooth-enabled ELM327 clones, but I know that there are OBD-II Bluetooth adapters - the last I've seen costed about $2000 as it was coming with a large diagnostic software and database of car parts(strike: see comments) and of course worked without any cables. But I think that still it would provide only 1 virtual serial port to talk with 1 device.
来源:https://stackoverflow.com/questions/12227559/how-to-have-multiple-connections-to-a-single-obd2-bluetooth-device-connected-to