mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-26 02:47:17 +00:00
Merge branch 'fix-dtr-rts' into controlsignals
This commit is contained in:
commit
96070935e9
2 changed files with 28 additions and 18 deletions
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////
|
||||
// Use the cool library //
|
||||
// git://github.com/voodootikigod/node-serialport.git //
|
||||
// to reset an arduino . //
|
||||
// to reset an arduino. //
|
||||
////////////////////////////////////////////////////////
|
||||
var com = require("serialport");
|
||||
|
||||
|
|
@ -12,6 +12,8 @@ var serialPort = new com.SerialPort("/dev/tty.usbmodem1411", {
|
|||
|
||||
serialPort.on('open',function() {
|
||||
console.log('Port open');
|
||||
// note you get a dtr for free on port open so lets wait 5 seconds
|
||||
// to make sure ours is seperate from that one
|
||||
setTimeout(asserting, 5000);
|
||||
});
|
||||
|
||||
|
|
@ -19,23 +21,23 @@ serialPort.on('data', function(data) {
|
|||
console.log(data);
|
||||
});
|
||||
|
||||
|
||||
function asserting() {
|
||||
console.log('asserting');
|
||||
serialPort.set({rts:true, dtr:true}, function(err, something) {
|
||||
console.log('asserted');
|
||||
setTimeout(clear, 250);
|
||||
});
|
||||
//NOTE: you actually de-assert rts and dtr to toggle!
|
||||
serialPort.set({rts:false, dtr:false}, function(err, something) {
|
||||
console.log('asserted');
|
||||
setTimeout(clear, 5000);
|
||||
});
|
||||
}
|
||||
|
||||
function clear() {
|
||||
console.log('clearing');
|
||||
serialPort.set({rts:false, dtr:false}, function(err, something) {
|
||||
console.log('clear');
|
||||
setTimeout(done, 50);
|
||||
});
|
||||
console.log('clearing');
|
||||
serialPort.set({rts:true, dtr:true}, function(err, something) {
|
||||
console.log('clear');
|
||||
setTimeout(done, 5000);
|
||||
});
|
||||
}
|
||||
|
||||
function done() {
|
||||
console.log("done resetting");
|
||||
console.log("done resetting");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,9 +60,9 @@ function SerialPortFactory() {
|
|||
xon: false,
|
||||
xoff: false,
|
||||
xany: false,
|
||||
rts: false,
|
||||
rts: true,
|
||||
cts: false,
|
||||
dtr: false,
|
||||
dtr: true,
|
||||
dts: false,
|
||||
databits: 8,
|
||||
stopbits: 1,
|
||||
|
|
@ -593,10 +593,18 @@ function SerialPortFactory() {
|
|||
options = (typeof option !== 'function') && options || {};
|
||||
|
||||
// flush defaults, then update with provided details
|
||||
options.rts = options.rts || options.rts || _options.rts;
|
||||
options.cts = options.cts || options.cts || _options.cts;
|
||||
options.dtr = options.dtr || options.dtr || _options.dtr;
|
||||
options.dts = options.dts || options.dts || _options.dts;
|
||||
if(!options.hasOwnProperty('rts')){
|
||||
options.rts = _options.rts;
|
||||
}
|
||||
if(!options.hasOwnProperty('dtr')){
|
||||
options.dtr = _options.dtr;
|
||||
}
|
||||
if(!options.hasOwnProperty('cts')){
|
||||
options.cts = _options.cts;
|
||||
}
|
||||
if(!options.hasOwnProperty('dts')){
|
||||
options.dts = _options.dts;
|
||||
}
|
||||
|
||||
if (!fd) {
|
||||
var err = new Error('Serialport not open.');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue