Skip to content

Commit

Permalink
Merge pull request #105 from sgacond/fix-open-callback
Browse files Browse the repository at this point in the history
Moved .open() down to avoid callback before transactionId’s are set.
  • Loading branch information
yaacov authored May 13, 2017
2 parents c4c585b + 96c30ea commit 10261f2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,6 @@ ModbusRTU.prototype.open = function(callback) {
if (callback)
callback(error);
} else {
/* On serial port open OK call next function */
if (callback)
callback(error);

/* init ports transaction id and counter */
modbus._port._transactionIdRead = 1;
Expand Down Expand Up @@ -321,6 +318,10 @@ ModbusRTU.prototype.open = function(callback) {
break;
}
});

/* On serial port open OK call next function */
if (callback)
callback(error);
}
});
};
Expand Down

0 comments on commit 10261f2

Please sign in to comment.