Moved USB enumerations subroutines in their own package
This commit is contained in:
29
enumerator/example_getdetailedportlist_test.go
Normal file
29
enumerator/example_getdetailedportlist_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Copyright 2014-2017 Cristian Maglie. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
//
|
||||
|
||||
package enumerator_test
|
||||
|
||||
import "fmt"
|
||||
import "log"
|
||||
import "go.bug.st/serial.v1/enumerator"
|
||||
|
||||
func ExampleGetDetailedPortsList() {
|
||||
ports, err := enumerator.GetDetailedPortsList()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if len(ports) == 0 {
|
||||
fmt.Println("No serial ports found!")
|
||||
return
|
||||
}
|
||||
for _, port := range ports {
|
||||
fmt.Printf("Found port: %s\n", port.Name)
|
||||
if port.IsUSB {
|
||||
fmt.Printf(" USB ID %s:%s\n", port.VID, port.PID)
|
||||
fmt.Printf(" USB serial %s\n", port.SerialNumber)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user