Initial commit

This commit is contained in:
nemunaire 2021-02-03 23:26:03 +01:00
commit 5064f5685a
4 changed files with 59 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
linky2influx
vendor/

8
go.mod Normal file
View File

@ -0,0 +1,8 @@
module github.com/nemunaire/linky2influx
go 1.15
require (
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
)

4
go.sum Normal file
View File

@ -0,0 +1,4 @@
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07 h1:UyzmZLoiDWMRywV4DUYb9Fbt8uiOSooupjTq10vpvnU=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

45
main.go Normal file
View File

@ -0,0 +1,45 @@
package main
import (
"flag"
"log"
"os"
"os/signal"
"syscall"
"time"
"github.com/tarm/serial"
)
func readSerial(s *serial.Port, interval *time.Duration) {
}
func main() {
var interval = flag.Duration("interval", 5*time.Second, "Minimum time between releve")
flag.Parse()
if len(flag.Args()) < 1 {
log.Println("missing required argument: serial device (eg. /dev/ttyUSB0)")
return
}
config := &serial.Config{
Name: flag.Args()[0],
Baud: 9600,
Size: 7,
Parity: serial.ParityNone,
StopBits: 1,
}
s, err := serial.OpenPort(config)
if err != nil {
log.Fatal(err)
}
go readSerial(s, interval)
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, os.Interrupt, syscall.SIGTERM)
<-interrupt
}