mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-26 02:47:17 +00:00
Check callback before calling it in no-error case.
It appears to be an optional parameter because we check it before calling it in every other case. Also simplify the error handling in a few callbacks.
This commit is contained in:
parent
172aa8da43
commit
79e7fbfce6
1 changed files with 11 additions and 27 deletions
|
|
@ -614,16 +614,10 @@ function SerialPortFactory(_spfOptions) {
|
|||
}
|
||||
|
||||
factory.SerialPortBinding.flush(fd, function (err, result) {
|
||||
if (err) {
|
||||
if (callback) {
|
||||
callback(err, result);
|
||||
} else {
|
||||
self.emit('error', err);
|
||||
}
|
||||
} else {
|
||||
if (callback) {
|
||||
callback(err, result);
|
||||
}
|
||||
if (callback) {
|
||||
callback(err, result);
|
||||
} else if (err) {
|
||||
self.emit('error', err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -663,14 +657,10 @@ function SerialPortFactory(_spfOptions) {
|
|||
}
|
||||
|
||||
factory.SerialPortBinding.set(fd, options, function (err, result) {
|
||||
if (err) {
|
||||
if (callback) {
|
||||
callback(err, result);
|
||||
} else {
|
||||
self.emit('error', err);
|
||||
}
|
||||
} else {
|
||||
if (callback) {
|
||||
callback(err, result);
|
||||
} else if (err) {
|
||||
self.emit('error', err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -690,16 +680,10 @@ function SerialPortFactory(_spfOptions) {
|
|||
}
|
||||
|
||||
factory.SerialPortBinding.drain(fd, function (err, result) {
|
||||
if (err) {
|
||||
if (callback) {
|
||||
callback(err, result);
|
||||
} else {
|
||||
self.emit('error', err);
|
||||
}
|
||||
} else {
|
||||
if (callback) {
|
||||
callback(err, result);
|
||||
}
|
||||
if (callback) {
|
||||
callback(err, result);
|
||||
} else if (err) {
|
||||
self.emit('error', err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue