Last active
May 7, 2024 03:46
-
-
Save penguinpowernz/de9d758671a22f59fa3437bd82b77ae9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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