Skip to content

Commit

Permalink
serial drain implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
hilschernetpi committed Jul 5, 2019
1 parent 2e2b409 commit 6d171d9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions node-red-contrib-npix-rs485/25-serial-rs485.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,14 @@ module.exports = function(RED) {
if (err) {
var errmsg = err.toString().replace("Serialport","Serialport "+node.port.serial.path);
node.error(errmsg,msg);
mutex.unlock();
} else {
// !!!!!Modification!!!! Wait till all data has been transmitted
node.port.drain(function(err) {
// set RS485 TX enable to low
gpio.write(11, false, function(err){
// unlock mutex
mutex.unlock();
// unlock mutex
mutex.unlock();
});
});
}
Expand Down Expand Up @@ -268,6 +269,7 @@ module.exports = function(RED) {
queue: [],
on: function(a,b) { this._emitter.on(a,b); },
close: function(cb) { this.serial.close(cb); },
drain: function(cb) { this.serial.drain(cb); },
encodePayload: function (payload) {
if (!Buffer.isBuffer(payload)) {
if (typeof payload === "object") {
Expand Down

0 comments on commit 6d171d9

Please sign in to comment.