diff --git a/serialport.js b/serialport.js index c2b6fd2..9400cd0 100644 --- a/serialport.js +++ b/serialport.js @@ -139,13 +139,13 @@ function SerialPortFactory() { if (typeof fc === 'boolean') { options.rtscts = true; } else { - fc.forEach(function (flowControl) { + var clean = fc.every(function (flowControl) { var fcup = flowControl.toUpperCase(); var idx = FLOWCONTROLS.indexOf(fcup); if (idx < 0) { var err = new Error('Invalid "flowControl": ' + fcup + ". Valid options: " + FLOWCONTROLS.join(", ")); callback(err); - return; + return false; } else { // "XON", "XOFF", "XANY", "DTRDTS", "RTSCTS" @@ -155,8 +155,12 @@ function SerialPortFactory() { case 2: options.xany = true; break; case 3: options.rtscts = true; break; } + return true; } }); + if(!clean){ + return; + } } }