Skip to content

Commit eff56a3

Browse files
committed
Display the NetworkPorts and SerialPorts in different places
Former-commit-id: dca0ff3c4ef35b504176d0e3594c186bcb4986df [formerly 43e7779a9b58b06b53e88ae0cebdf7ca687691e5] Former-commit-id: 83be1390634a2b28e7fd2f3244f8245e8c4fd1f9
1 parent 5f3ef3d commit eff56a3

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

Diff for: serial.go

+15-8
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ type serialhub struct {
8585
}
8686

8787
type SpPortList struct {
88-
SerialPorts []SpPortItem
88+
SerialPorts []SpPortItem
89+
NetworkPorts []SpPortItem
8990
}
9091

9192
type SpPortItem struct {
@@ -452,7 +453,13 @@ func spListDual(network bool) {
452453
// to append the open/close state, baud rates, etc to make
453454
// a super clean nice list to send back to browser
454455
n := len(list)
455-
spl := SpPortList{make([]SpPortItem, n, n)}
456+
spl := SpPortList{make([]SpPortItem, n, n), make([]SpPortItem, n, n)}
457+
458+
ports := spl.SerialPorts
459+
460+
if network {
461+
ports = spl.NetworkPorts
462+
}
456463

457464
ctr := 0
458465
for _, item := range list {
@@ -470,7 +477,7 @@ func spListDual(network bool) {
470477
AvailableBufferAlgorithms []string
471478
Ver float32
472479
*/
473-
spl.SerialPorts[ctr] = SpPortItem{
480+
ports[ctr] = SpPortItem{
474481
Name: item.Name,
475482
Friendly: item.FriendlyName,
476483
SerialNumber: item.SerialNumber,
@@ -486,15 +493,15 @@ func spListDual(network bool) {
486493
}
487494

488495
// figure out if port is open
489-
//spl.SerialPorts[ctr].IsOpen = false
496+
//ports[ctr].IsOpen = false
490497
myport, isFound := findPortByName(item.Name)
491498

492499
if isFound {
493500
// we found our port
494-
spl.SerialPorts[ctr].IsOpen = true
495-
spl.SerialPorts[ctr].Baud = myport.portConf.Baud
496-
spl.SerialPorts[ctr].BufferAlgorithm = myport.BufferType
497-
spl.SerialPorts[ctr].IsPrimary = myport.IsPrimary
501+
ports[ctr].IsOpen = true
502+
ports[ctr].Baud = myport.portConf.Baud
503+
ports[ctr].BufferAlgorithm = myport.BufferType
504+
ports[ctr].IsPrimary = myport.IsPrimary
498505
}
499506
//ls += "{ \"name\" : \"" + item.Name + "\", \"friendly\" : \"" + item.FriendlyName + "\" },\n"
500507
ctr++

0 commit comments

Comments
 (0)