mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-26 02:47:17 +00:00
Merge pull request #205 from giseburt/advanced
Fixing up flow control changes.
This commit is contained in:
commit
6c58e5bac4
2 changed files with 19 additions and 23 deletions
|
|
@ -67,22 +67,25 @@ function SerialPort (path, options, openImmediately) {
|
|||
|
||||
var self = this;
|
||||
|
||||
stream.Stream.call(this);
|
||||
|
||||
options.baudRate = options.baudRate || options.baudrate || _options.baudrate;
|
||||
// Removing check for valid BaudRates due to ticket: #140
|
||||
// if (BAUDRATES.indexOf(options.baudrate) == -1) {
|
||||
// throw new Error('Invalid "baudrate": ' + options.baudrate);
|
||||
// }
|
||||
|
||||
|
||||
stream.Stream.call(this);
|
||||
|
||||
|
||||
|
||||
if (DATABITS.indexOf(options.databits) == -1) {
|
||||
throw new Error('Invalid "databits": ' + options.databits);
|
||||
options.dataBits = options.dataBits || options.databits || _options.databits;
|
||||
if (DATABITS.indexOf(options.dataBits) == -1) {
|
||||
throw new Error('Invalid "databits": ' + options.dataBits);
|
||||
}
|
||||
if (STOPBITS.indexOf(options.stopbits) == -1) {
|
||||
|
||||
options.stopbits = options.stopBits || options.stopbits || _options.stopbits;
|
||||
if (STOPBITS.indexOf(options.stopBits) == -1) {
|
||||
throw new Error('Invalid "stopbits": ' + options.stopbits);
|
||||
}
|
||||
|
||||
options.parity = options.parity || _options.parity;
|
||||
if (PARITY.indexOf(options.parity) == -1) {
|
||||
throw new Error('Invalid "parity": ' + options.parity);
|
||||
}
|
||||
|
|
@ -113,7 +116,7 @@ function SerialPort (path, options, openImmediately) {
|
|||
switch (idx) {
|
||||
case 0: options.xon = true; break;
|
||||
case 1: options.xoff = true; break;
|
||||
case 2: options.xany = true; break;
|
||||
case 2: options.xany = true; break;
|
||||
case 3: options.rtscts = true; break;
|
||||
}
|
||||
}
|
||||
|
|
@ -121,10 +124,6 @@ function SerialPort (path, options, openImmediately) {
|
|||
}
|
||||
}
|
||||
|
||||
options.baudRate = options.baudRate || options.baudrate || _options.baudrate;
|
||||
options.parity = options.parity || _options.parity;
|
||||
options.dataBits = options.dataBits || options.databits || _options.databits;
|
||||
options.stopBits = options.stopBits || options.stopbits || _options.stopbits;
|
||||
options.bufferSize = options.bufferSize || options.buffersize || _options.buffersize;
|
||||
options.parser = options.parser || _options.parser;
|
||||
|
||||
|
|
|
|||
|
|
@ -163,31 +163,28 @@ void EIO_Open(uv_work_t* req) {
|
|||
options.c_cflag &= ~CSIZE;
|
||||
options.c_cflag |= dataBits;
|
||||
|
||||
options.c_cflag &= ~(CRTSCTS);
|
||||
|
||||
if (data->rtscts) {
|
||||
options.c_cflag &= ~CRTSCTS;
|
||||
options.c_cflag |= 1;
|
||||
options.c_cflag |= CRTSCTS;
|
||||
// evaluate specific flow control options
|
||||
}
|
||||
|
||||
options.c_iflag &= ~(IXON | IXOFF | IXANY);
|
||||
|
||||
if (data->xon) {
|
||||
options.c_iflag &= ~IXON;
|
||||
options.c_iflag |= 1;
|
||||
options.c_iflag |= IXON;
|
||||
}
|
||||
|
||||
if (data->xoff) {
|
||||
options.c_iflag &= ~IXOFF;
|
||||
options.c_iflag |= 1;
|
||||
options.c_iflag |= IXOFF;
|
||||
}
|
||||
|
||||
if (data->xany) {
|
||||
options.c_iflag &= ~IXANY;
|
||||
options.c_iflag |= 1;
|
||||
options.c_iflag |= IXANY;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
switch (data->parity)
|
||||
{
|
||||
case SERIALPORT_PARITY_NONE:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue