EricSmekens / node-bluetooth-obd

Node package for communication with Bluetooth OBD connectors.
Other
262 stars 72 forks source link

Commented ATZ command returns no data #5

Closed devoncrouse closed 9 years ago

devoncrouse commented 10 years ago

When testing the module as-is, and setting a poll on rpm, I get OKs for the sets, and then empty objects for all of the poll results:

{ value: 'OK' }
{ value: 'OK' }
{ value: 'OK' }
{ value: 'OK' }
{ value: 'OK' }
{ value: 'OK' }
{}
{}
{}
...

Based on testing/reading, it looks like the problem is the ATZ (ELM327 chip reset) being commented out. Is there a reason for that? Things work for me when it's un-commented.

        //self.write('ATZ');
        //Turns off extra line feed and carriage return
        self.write('ATL0');
        //This disables spaces in in output, which is faster!
        self.write('ATS0');
        //Turns off headers and checksum to be sent.
        self.write('ATH0');
        //Turns off echo.
        self.write('ATE0');
        //Turn adaptive timing to 2. This is an aggressive learn curve for adjusting the timeout. Will make huge difference on slow systems.
        self.write('ATAT2');
        //Set timeout to 10 * 4 = 40msec, allows +20 queries per second. This is the maximum wait-time. ATAT will decide if it should wait shorter or not.
        //self.write('ATST0A');
        //Set the protocol to automatic.
        self.write('ATSP0');
devoncrouse commented 10 years ago

I wish I could make my OBD adapter generate fake data without being hooked up to the car...

EricSmekens commented 10 years ago

That might be it. I normally set up another laptop with OBDsim. https://icculus.org/obdgpslogger/obdsim.html It's kinda hard to set it up for the first time, but it's worth it. It just fakes your laptop as an ELM327 device.

I will try this out this weekend too, might be the case. In general, the whole module should be remade with callbacks maybe, or in any case, it shouldn't have timed polling. But that's the only way to get much results in a second I believe, as with OBD, you have to poll.

When I have time, I'm going to look into this, but time is spare. :/

devoncrouse commented 10 years ago

Yeah, I hear that. Thanks for the tip on obdsim; that'll help. And I'm getting what I need out of the module now more or less, so no rush.

timkendall commented 9 years ago

I'm having the same problem :\ Tried the above solution of un-commenting self.write('ATZ') and still no luck. What device are you guys using (I'm using this)?

EricSmekens commented 9 years ago

What car (year/make) are you trying it on? Does an app like Torque works with it?

timkendall commented 9 years ago

Tried a 2002 Acura TL and got no data. Tried it with a 2009 G37 and got data like this

Debug: Found device: OBDII (00-0d-18-28-08-11)
Debug: Found device channel: 1
{}
{}
{}
{ value: 'OK' }
{}
{ value: 'OK' }
{}
{}
{ mode: '41', pid: '0C', name: 'rpm', value: NaN }
{ mode: '41', pid: '05', name: 'temp', value: 70 }
{ mode: '41', pid: '04', name: 'load_pct', value: NaN }
{}
{}
{}
{}
{ mode: '41', pid: '0C', name: 'rpm', value: NaN }
{ mode: '41', pid: '05', name: 'temp', value: 70 }
{ mode: '41', pid: '04', name: 'load_pct', value: 22.265625 }

...while running this

btOBDReader.on('connected', function () {

    this.addPoller("vss");
    this.addPoller("rpm");
    this.addPoller("temp");
    this.addPoller("load_pct");
    this.addPoller("map");
    this.addPoller("frp");

    this.startPolling(1000); //Request all values each second.
});

Obviously something is a little off (why would it only get a few intermittent values?). And no, I don't have an Android phone to try Torque or a similar app with. Any idea? I was thinking it could be the baud rate but I don't see how to change that.

Thanks for making this library btw, super cool!

timkendall commented 9 years ago

Hmm, weird - it seems to work consistently with the 2009 G37 if I connect to the device before the car is on.

EricSmekens commented 9 years ago

I don't think it's the baudrate, you are getting some of the messages, so that seems to be good. Might be something with the polling, we only see rpm, temp and load_pct returned. Maybe you could try with:

this.requestValueByName("vss");

That way we can see if it's not a timing issue.

Yeah, the library could use some more revision. I made this librarby in my early JS days, so there may be a few things that are strange. Especially on the polling thing.

timkendall commented 9 years ago

Hmm alright, yeah I'll play around with it a little more.

EricSmekens commented 9 years ago

Closing issue, will make a list of upcoming changes soon, and this will also be mentioned.