From 68232c28d19c80093d35e6dc7130156e9205f15d Mon Sep 17 00:00:00 2001 From: Keegan Date: Tue, 12 Jul 2022 18:40:30 +0000 Subject: [PATCH] added basic logging to i2c --- internal/pkg/I2C/bus.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/pkg/I2C/bus.go b/internal/pkg/I2C/bus.go index 1dc37c9..43dc958 100644 --- a/internal/pkg/I2C/bus.go +++ b/internal/pkg/I2C/bus.go @@ -4,12 +4,14 @@ package I2C import ( _ "fmt" - "log" + _ "log" "os/exec" + "os/user" "bytes" "strings" "sync" "strconv" + "FRMS/internal/pkg/logging" ) type I2CBus struct { @@ -32,9 +34,11 @@ func (b *I2CBus) Scan() map[int]bool { bus := strconv.Itoa(b.int) cmd := exec.Command("i2cdetect", "-y", "-r", bus) var out bytes.Buffer + var errs bytes.Buffer + cmd.Stderr = &errs cmd.Stdout = &out if err := cmd.Run(); err != nil { - log.Fatal(err) + logging.Debug(logging.DError, "I2C ERROR: %v", errs.String()) } outString := out.String() @@ -81,7 +85,7 @@ func (b *I2CBus) GetStatus(addr int) bool { var out bytes.Buffer cmd.Stdout = &out if err := cmd.Run(); err != nil { - log.Fatal(err) + logging.Debug(logging.DError,"I2C ERROR: %v", err) } outString := out.String()