EricSmekens / node-bluetooth-obd

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

Get Error: Error finding serialport: undefined #14

Closed YimengZhu closed 8 years ago

YimengZhu commented 8 years ago

Hi Eric, Thank you for the excellent work. Now i can connect my OBD with my server. But i always get the Error: Error finding serialport: undefined before i can receive the data. As soon as this error is thrown the OBD will disconnect. Do you know how can i fix this Problem?

EricSmekens commented 8 years ago

Always to troubleshoot, I suggest if it's possible to connect with another app that uses OBD-II. Is that possible?

YimengZhu commented 8 years ago

I just tried a Android OBD App to connect to the same device. It seems to be ok. Does this error finding serial port undefined mean, i can't find a running serial port service on the device? So maybe the problem is on my local bluetooth adapter? Thanks for answer

EricSmekens commented 8 years ago

Can you try an app or commandline something like putty on the same machine you are running node on? Also, post the code you're using, it might help.

At this point it looks like it's on the side of the machine that node is running on, but can't tell it's something in my library or some configuration setting on the machine.

YimengZhu commented 8 years ago

Actually i use your package in typescript. Following are the typescript file and the compiled javascript file. I will try the putty as soon as possible(maybe tomorrow. The machine is not at home). As I get the result i will post here. Thanks for answer :) bluetooth-obd2.zip

YimengZhu commented 8 years ago

Hi I just run the node on a macbook pro and other node server app runs unproblematic. What kind of information do you need about the configuration and library?

YimengZhu commented 8 years ago

Hi, Now I have better connection. But the received data ist always only a question mark. I read somewhere else that it may be because the command sent to OBD is not terminated by a carriage character (hex ‘0D’). In which command do you send the command to OBD?

EricSmekens commented 8 years ago

That seems to be quite strange. Pity I don't have a suggestion at this moment, been a while since I was actively working on this repo (on obd at all).

I still think it's the connection though, but I will check where I send it.

EricSmekens commented 8 years ago
            self.btSerial.write(new Buffer(queue.shift(), "utf-8"), function (err, count) {
                if (err)
                    self.emit('error', err);
            });

That's the writing part, where it actually writes to the bluetooth-port. At this moment I don't like how it works, but I don't have time and testing tools to refactor the whole library.

YimengZhu commented 8 years ago

I just read the specification of the ELM327. It says, that the AT Command sent to the OBD port should be a Hexstring. I think may be the mode in the responsPIDS should be "01" but not "modeRealTime" so that the OBD can understand it. Anyhow i still don't get the right response from OBD. I will continue to find the potential reason.

EricSmekens commented 8 years ago

It actually sends the string, 'modeRealTime'? You're right, it should send '01'.

YimengZhu commented 8 years ago

I just edited something in the obdInfo.js. Can I merge my code to the master branch?

EricSmekens commented 8 years ago

Of course! Just submit a Pull Request, and we will discuss the change there!