Skip to content

Commit 15f3fcb

Browse files
committed
Merge pull request #2 from arduino/fix_duplication
Fix duplication issues
2 parents e53934c + dbd146d commit 15f3fcb

File tree

2 files changed

+30
-24
lines changed

2 files changed

+30
-24
lines changed

main.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,18 @@ const homeTemplateHtml = `<!DOCTYPE html>
301301
302302
var socket;
303303
var msg = $("#msg");
304-
var log = $("#log");
304+
var log = document.getElementById('log');
305+
var messages = [];
305306
306307
function appendLog(msg) {
307-
var d = log[0]
308-
var doScroll = d.scrollTop == d.scrollHeight - d.clientHeight;
309-
msg.appendTo(log)
308+
messages.push(msg);
309+
if (messages.length > 100) {
310+
messages.shift();
311+
}
312+
var doScroll = log.scrollTop == log.scrollHeight - log.clientHeight;
313+
log.innerHTML = messages.join("<br>");
310314
if (doScroll) {
311-
d.scrollTop = d.scrollHeight - d.clientHeight;
315+
log.scrollTop = log.scrollHeight - log.clientHeight;
312316
}
313317
}
314318
@@ -334,7 +338,7 @@ const homeTemplateHtml = `<!DOCTYPE html>
334338
appendLog($("<div><b>Connection closed.</b></div>"))
335339
});
336340
socket.on("message", function(evt) {
337-
appendLog($("<div/>").text(evt))
341+
appendLog(evt);
338342
});
339343
} else {
340344
appendLog($("<div><b>Your browser does not support WebSockets.</b></div>"))

serial.go

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -472,24 +472,26 @@ func spListDual(network bool) {
472472
// happen on windows in a fallback scenario where an
473473
// open port can't be identified because it is locked,
474474
// so just solve that by manually inserting
475-
for port := range sh.ports {
476-
477-
isFound := false
478-
for _, item := range list {
479-
if strings.ToLower(port.portConf.Name) == strings.ToLower(item.Name) {
480-
isFound = true
481-
}
482-
}
483-
484-
if !isFound {
485-
// artificially push to front of port list
486-
log.Println(fmt.Sprintf("Did not find an open port in the serial port list. We are going to artificially push it onto the list. port:%v", port.portConf.Name))
487-
var ossp OsSerialPort
488-
ossp.Name = port.portConf.Name
489-
ossp.FriendlyName = port.portConf.Name
490-
list = append([]OsSerialPort{ossp}, list...)
491-
}
492-
}
475+
// if network {
476+
// for port := range sh.ports {
477+
478+
// isFound := false
479+
// for _, item := range list {
480+
// if strings.ToLower(port.portConf.Name) == strings.ToLower(item.Name) {
481+
// isFound = true
482+
// }
483+
// }
484+
485+
// if !isFound {
486+
// // artificially push to front of port list
487+
// log.Println(fmt.Sprintf("Did not find an open port in the serial port list. We are going to artificially push it onto the list. port:%v", port.portConf.Name))
488+
// var ossp OsSerialPort
489+
// ossp.Name = port.portConf.Name
490+
// ossp.FriendlyName = port.portConf.Name
491+
// list = append([]OsSerialPort{ossp}, list...)
492+
// }
493+
// }
494+
// }
493495

494496
// we have a full clean list of ports now. iterate thru them
495497
// to append the open/close state, baud rates, etc to make

0 commit comments

Comments
 (0)