Skip to content

Commit 317eaec

Browse files
committed
Fixed bug in changeBaudrate() that caused circular reference. There may still be a slight problem; this may be the source of strange behavior at the moment it tries to changeBaudrate near end of wireless protocol.
1 parent feb2c0c commit 317eaec

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

serial.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function changeBaudrate(port, baudrate) {
145145
if (port.isWired) {
146146
chrome.serial.update(port.connId, {'bitrate': baudrate}, function (updateResult) {
147147
if (updateResult) {
148-
updatePort(port, {baud: baudrate});
148+
port.baud = baudrate; //Update baud; does not use updatePort() because of circular reference //!!!
149149
resolve();
150150
} else {
151151
reject(Error(notice(neCanNotSetBaudrate, [port.path, baudrate])));
@@ -163,9 +163,8 @@ function changeBaudrate(port, baudrate) {
163163
let postStr = "POST /wx/setting?name=baud-rate&value=" + baudrate + " HTTP/1.1\r\n\r\n";
164164
chrome.sockets.tcp.connect(port.phSocket, port.ip, 80, function() {
165165
chrome.sockets.tcp.send(port.phSocket, str2ab(postStr), function () {
166-
updatePort(port, {baud: baudrate});
167166
propComm.response
168-
.then(function() {return resolve();})
167+
.then(function() {port.baud = baudrate; return resolve();}) //Update baud; does not use updatePort() because of circular reference //!!!
169168
.catch(function(e) {return reject(e);})
170169
});
171170
});

0 commit comments

Comments
 (0)