Skip to content

Fix duplication issues #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,18 @@ const homeTemplateHtml = `<!DOCTYPE html>

var socket;
var msg = $("#msg");
var log = $("#log");
var log = document.getElementById('log');
var messages = [];

function appendLog(msg) {
var d = log[0]
var doScroll = d.scrollTop == d.scrollHeight - d.clientHeight;
msg.appendTo(log)
messages.push(msg);
if (messages.length > 100) {
messages.shift();
}
var doScroll = log.scrollTop == log.scrollHeight - log.clientHeight;
log.innerHTML = messages.join("<br>");
if (doScroll) {
d.scrollTop = d.scrollHeight - d.clientHeight;
log.scrollTop = log.scrollHeight - log.clientHeight;
}
}

Expand All @@ -334,7 +338,7 @@ const homeTemplateHtml = `<!DOCTYPE html>
appendLog($("<div><b>Connection closed.</b></div>"))
});
socket.on("message", function(evt) {
appendLog($("<div/>").text(evt))
appendLog(evt);
});
} else {
appendLog($("<div><b>Your browser does not support WebSockets.</b></div>"))
Expand Down
38 changes: 20 additions & 18 deletions serial.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,24 +472,26 @@ func spListDual(network bool) {
// happen on windows in a fallback scenario where an
// open port can't be identified because it is locked,
// so just solve that by manually inserting
for port := range sh.ports {

isFound := false
for _, item := range list {
if strings.ToLower(port.portConf.Name) == strings.ToLower(item.Name) {
isFound = true
}
}

if !isFound {
// artificially push to front of port list
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))
var ossp OsSerialPort
ossp.Name = port.portConf.Name
ossp.FriendlyName = port.portConf.Name
list = append([]OsSerialPort{ossp}, list...)
}
}
// if network {
// for port := range sh.ports {

// isFound := false
// for _, item := range list {
// if strings.ToLower(port.portConf.Name) == strings.ToLower(item.Name) {
// isFound = true
// }
// }

// if !isFound {
// // artificially push to front of port list
// 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))
// var ossp OsSerialPort
// ossp.Name = port.portConf.Name
// ossp.FriendlyName = port.portConf.Name
// list = append([]OsSerialPort{ossp}, list...)
// }
// }
// }

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