Skip to content

Instantly share code, notes, and snippets.

@penguinpowernz
Last active May 7, 2024 03:46
Show Gist options
  • Save penguinpowernz/de9d758671a22f59fa3437bd82b77ae9 to your computer and use it in GitHub Desktop.
Save penguinpowernz/de9d758671a22f59fa3437bd82b77ae9 to your computer and use it in GitHub Desktop.
package main
import (
"log"
"github.com/tarm/serial"
)
func main() {
c := &serial.Config{Name: "/dev/tty0", Baud: 115200}
s, err := serial.OpenPort(c)
if err != nil {
log.Fatal(err)
}
r := bufio.NewReader(s)
for {
data, err := r.ReadString('\n')
if err != nil {
panic(err)
}
log.Println(data)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment