Skip to content

Latest commit

 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go-Serial-Detector

This is a package that allows you to list active serial ports:

  • /dev/ttyS*;
  • /dev/ttyUSB*.

In linux systems information is obtained from udev, sysfs or procfs.

OS support

This package currently supports only linux systems.

Installation

go get github.com/hedhyw/Go-Serial-Detector/pkg/v1/serialdet

Usage

package main

import (
	"log"

	"github.com/hedhyw/Go-Serial-Detector/pkg/v1/serialdet"
)

func main() {
	list, err := serialdet.List()
	if err != nil {
		log.Fatal(err)
	}

	for _, p := range list {
		// p.Description():
		//   returns short information about serial port.
		// p.Path():
		//   returns path to device, for example: "/dev/ttyUSB1".
		log.Print(p.Description(), " ", p.Path())
	}
}

A runnable example is available in example/main.go.

About

A go library for determining active serial ports.

Topics

Resources

Stars

15 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages