ecto / duino

:bulb: Arduino framework for node.js
958 stars 214 forks source link

'connected' event triggers before the SerialPort is opened #48

Open fcovas opened 10 years ago

fcovas commented 10 years ago

If I run the examples/basic.js the application crashes because the serial port is not opened on the 'connected' event. Shouldn't the 'connected' event only be emitted after the SerialPort 'open' event?

Here https://github.com/ecto/duino/blob/master/lib/board.js#L28, instead of:

self.emit('connected');

do this:

self.serial.on('open', function(){
    self.emit('connected');
});