package communication import ( "go.bug.st/serial" "go.bug.st/serial/enumerator" ) const ( ST_VID = `0483` ) func getStSerials() ([]string, error) { retval := make([]string, 0) ports, err := enumerator.GetDetailedPortsList() if err != nil { return retval, err } for _, port := range ports { if port.IsUSB { if port.VID == ST_VID { retval = append(retval, port.Name) } } } return retval, nil } func openSerial(device string) (serial.Port, error) { var port serial.Port mode := &serial.Mode{ BaudRate: 115200, } port, err := serial.Open(device, mode) if err != nil { return port, err } return port, nil }