added basic logging to i2c

main
Keegan 2 years ago
parent a24f0e055f
commit 68232c28d1

@ -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()

Loading…
Cancel
Save