(Please answer all 3)

const serialPort = require('serialport');
const readLine = require('@serialPort/parser-readLine');
serialPort.list(function(err,ports){
ports.forEach(function(port){
console.log(port.comName);
})
})
var port = new serialPort('com5',{
autoOpen: true,
baudRate: 9600,
dataBits: 8,
partiy: 'none',
stopBits: 1
})
const parser = port.pipe(new readLine());
parser.on('data',console.log)
port.write('fakemessage',function(err){
if(err){
console.trace(err);
}
console.log('message written..')
});
port.open(function(err){
if(err){
console.log(err);
}
});
port.drain();
port.close(function(err){
if(err){
console.log(err)
}
});
Readline looks for \n by default, are you sure that's what your device is
sending?
On Mon, Oct 1, 2018, 7:55 PM jdshin123 notifications@github.com wrote:
Summary of Problem
(Please answer all 3)
What are you trying to do?
write and read to/from a comport.
What happens?
Does not seem to be able to open a port. When i write to comport,
the message stays in the buffer but
never gets sent. When i connect to comport via terminal im able to see
the message that has not been sent. I also tried closing the port i.e
port.close() but i get an error saying port is not open.What should have happened?
The message should have been able to go through and receive message
Code to Reproduce the Issue
[image: 2018-10-01 16_42_04-com5 - tera term vt]
https://user-images.githubusercontent.com/7707488/46321671-91b49800-c599-11e8-92a1-76a27797666c.pngconst serialPort = require('serialport');
const readLine = require('@serialPort/parser-readLine');serialPort.list(function(err,ports){
ports.forEach(function(port){
console.log(port.comName);
})
})var port = new serialPort('com5',{
autoOpen: true,
baudRate: 9600,
dataBits: 8,
partiy: 'none',
stopBits: 1
})const parser = port.pipe(new readLine());
parser.on('data',console.log)
port.write('fakemessage',function(err){
if(err){
console.trace(err);
}
console.log('message written..')
});port.open(function(err){
if(err){
console.log(err);
}
});
port.drain();port.close(function(err){
if(err){
console.log(err)
}
});
Versions, Operating System and Hardware
- SerialPort@? 7.0.2
- Node.js v? 9.40
- Windows? Linux? Mac? windows 10 (home)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/node-serialport/node-serialport/issues/1687, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AABlbp9XFbNgy4PNbLcSBk4sm5RqqwVGks5ugqthgaJpZM4XDFry
.
@jdshin123 Can you confirm that 'COM5' is listed when you run Serialport.list()?
Also, unless you pass the autoOpen: false option to the Serialport construction, then the following code is redundant and will probably throw an error:
var port = new serialPort('com5',{
autoOpen: true,
baudRate: 9600,
dataBits: 8,
partiy: 'none',
stopBits: 1
})
port.open(function(err){
if(err){
console.log(err);
}
});
@reconbot @HipsterBrown welp.. i'm such a dolt.. you were right! it was a "\n" that was missing.. When i opened the terminal , i had to press enter for the message to display.. Thank you guys!
Most helpful comment
@reconbot @HipsterBrown welp.. i'm such a dolt.. you were right! it was a "\n" that was missing.. When i opened the terminal , i had to press enter for the message to display.. Thank you guys!