Documentation ¶
Overview ¶
Package enumerator is a golang cross-platform library for USB serial port discovery.
WARNING: this library is still beta-testing code! please consider the library and the API as *unstable*. Beware that, even if at this point it's unlike to happen, the API may be subject to change until this notice is removed from the documentation.
This library has been tested on Linux, Windows and Mac and uses specific OS services to enumerate USB PID/VID, in particular on MacOSX the use of cgo is required in order to access the IOKit Framework. This means that the library cannot be easily cross compiled for GOOS=darwing targets.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PortDetails ¶
PortDetails contains detailed information about USB serial port. Use GetDetailedPortsList function to retrieve it.
func GetDetailedPortsList ¶
func GetDetailedPortsList() ([]*PortDetails, error)
GetDetailedPortsList retrieve ports details like USB VID/PID. Please note that this function may not be available on all OS: in that case a FunctionNotImplemented error is returned.
Example ¶
package main import ( "fmt" "go.bug.st/serial.v1/enumerator" "log" ) func main() { 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) } } }
Output:
type PortEnumerationError ¶
type PortEnumerationError struct {
// contains filtered or unexported fields
}
PortEnumerationError is the error type for serial ports enumeration
func (PortEnumerationError) Error ¶
func (e PortEnumerationError) Error() string
Error returns the complete error code with details on the cause of the error