node-serialport icon indicating copy to clipboard operation
node-serialport copied to clipboard

TypeError: Object #<SerialPort> has no method 'drain'

Open 5043165356 opened this issue 13 years ago • 3 comments

Hi, when drain method is called

serialPort.drain(function(err, result){
    console.log(err, result);
});

I am getting the error

TypeError: Object #<SerialPort> has no method 'drain'

Also

cat node_modules/serialport/serialport.js | grep drain

returns nothing.

How can I empty the serial port?

5043165356 avatar Nov 14 '13 13:11 5043165356

All data the port has read will be emitted (usually by the raw parser as a data event). You would need to use the event emitter syntax however.

port.on('data', function(){}))

Only the line parser will buffer any data, and there is no way to drain it. It is simple to construct your own if you need access to its buffer. On Nov 14, 2013 8:39 AM, "ediazal" [email protected] wrote:

Hi, when drain method is called

serialPort.drain(function(err, result){ console.log(err, result); });

I am getting the error

TypeError: Object # has no method 'drain'

Also

cat node_modules/serialport/serialport.js | grep drain

returns nothing.

How can I empty the serial port?

— Reply to this email directly or view it on GitHubhttps://github.com/voodootikigod/node-serialport/issues/260 .

reconbot avatar Nov 14 '13 14:11 reconbot

Thanks. It helped to know data isn't buffered to solve my problem :)

Anyways, It would be nice to be able to read the port data using a Stream

5043165356 avatar Nov 14 '13 14:11 5043165356

We'd like to be a stream eventually =)

reconbot avatar Nov 14 '13 18:11 reconbot