Skip to content

Commit 6b18a55

Browse files
committed
Merge pull request #43 from facchinm/serialList_native
Serial list native
2 parents a338c00 + 3a0295e commit 6b18a55

17 files changed

+6474
-353
lines changed

compile_webidebridge.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ bootstrapPlatforms()
5252
env CC_FOR_TARGET=o64-clang CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 ./make.bash --no-clean
5353
env CC_FOR_TARGET=gcc CGO_ENABLED=1 GOOS=linux GOARCH=amd64 ./make.bash --no-clean
5454
env CC_FOR_TARGET=gcc CGO_ENABLED=1 GOOS=linux GOARCH=386 ./make.bash --no-clean
55-
env CGO_ENABLED=0 GOOS=linux GOARCH=arm ./make.bash --no-clean
55+
#env CGO_ENABLED=0 GOOS=linux GOARCH=arm ./make.bash --no-clean
5656
env CC_FOR_TARGET=i686-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows GOARCH=386 ./make.bash --no-clean
5757
}
5858

@@ -90,7 +90,7 @@ extractVersionFromMain
9090
compilePlatform darwin amd64 o64-clang 1
9191
#compilePlatformLinux linux 386 gcc
9292
compilePlatform linux amd64 gcc 1
93-
compilePlatform linux arm 0
93+
#compilePlatform linux arm 0
9494
compilePlatform windows 386 i686-w64-mingw32-gcc 1
9595

9696

seriallist.go

+14-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
package main
44

55
import (
6+
"fmt"
67
log "github.com/Sirupsen/logrus"
7-
"github.com/facchinm/go-serial"
8+
"github.com/facchinm/go-serial-native"
89
"regexp"
910
)
1011

@@ -16,6 +17,7 @@ type OsSerialPort struct {
1617
Product string
1718
IdProduct string
1819
IdVendor string
20+
ISerial string
1921
NetworkPort bool
2022
}
2123

@@ -29,11 +31,19 @@ func GetList(network bool) ([]OsSerialPort, error) {
2931
} else {
3032

3133
// will timeout in 2 seconds
32-
ports, err := serial.GetPortsList()
33-
3434
arrPorts := []OsSerialPort{}
35+
ports, err := serial.ListPorts()
36+
if err != nil {
37+
return arrPorts, err
38+
}
39+
3540
for _, element := range ports {
36-
arrPorts = append(arrPorts, OsSerialPort{Name: element})
41+
vid, pid, _ := element.USBVIDPID()
42+
vidString := fmt.Sprintf("0x%04X", vid)
43+
pidString := fmt.Sprintf("0x%04X", pid)
44+
if vid != 0 && pid != 0 {
45+
arrPorts = append(arrPorts, OsSerialPort{Name: element.Name(), IdVendor: vidString, IdProduct: pidString, ISerial: element.USBSerialNumber()})
46+
}
3747
}
3848

3949
// see if we should filter the list
@@ -54,7 +64,6 @@ func GetList(network bool) ([]OsSerialPort, error) {
5464
arrPorts = newarrPorts
5565
}
5666

57-
arrPorts = associateVidPidWithPort(arrPorts)
5867
return arrPorts, err
5968
//log.Printf("Done doing GetList(). arrPorts:%v\n", arrPorts)
6069
}

seriallist_darwin.go

-66
This file was deleted.

seriallist_linux.go

-36
This file was deleted.

seriallist_windows.go

-227
This file was deleted.

0 commit comments

Comments
 (0)