Hi,
I'm trying to emit event from serial port 'on data' function but the event
doesn't pass through to my implmentation. When I directly call parse
function event is emitted correctly. Can you please advice what I'm doing
wrong here? Here is my code:
function GPS(device, baudrate) {
events.EventEmitter.call(this);
this.port = new serialport.SerialPort(this.device, {
baudrate: this.baudrate,
parser: serialport.parsers.readline('\r\n')
});
this.port.on('data', this.parse);
}
util.inherits(GPS, events.EventEmitter);
GPS.prototype.parse = function(line) {
(...)
this.emit('data', data)
};
module.exports = GPS;
// Implementation
var gps = new GPS('/dev/ttyACM0', 115200);
gps.on("data", function(data) {
// Handle data
});
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/50d706ad-8582-4bfa-a711-51bb050c1a18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.