Skip to content

Commit

Permalink
Fix camera module override
Browse files Browse the repository at this point in the history
  • Loading branch information
CameronRP committed Aug 31, 2023
1 parent 0547b48 commit c543ac5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
14 changes: 0 additions & 14 deletions cmd/thermal-recorder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
package main

import (
"log"
"os"
"strings"

goconfig "github.com/TheCacophonyProject/go-config"
"github.com/TheCacophonyProject/thermal-recorder/motion"
"github.com/TheCacophonyProject/thermal-recorder/recorder"
Expand All @@ -47,16 +43,6 @@ func (c *Config) LoadMotionConfig(cameraModel string) error {
return err
}

// Module override, just a temp fix for now.
overrideFile := "/etc/cacophony/lepton-module"
content, err := os.ReadFile(overrideFile)
if err == nil {
cameraModel = strings.TrimSpace(string(content))
log.Println("Camera model override: " + cameraModel)
} else if !os.IsNotExist(err) {
return err
}

motionConfig, err := motion.NewConfig(configRW, cameraModel)
if err != nil {
return err
Expand Down
13 changes: 13 additions & 0 deletions headers/headerinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package headers
import (
"bufio"
"bytes"
"log"
"os"
"strings"

"gopkg.in/yaml.v1"
Expand Down Expand Up @@ -105,6 +107,17 @@ func ReadHeaderInfo(reader *bufio.Reader) (*HeaderInfo, error) {
serial: toInt(h[Serial]),
firmware: toStr(h[Firmware]),
}

// Module override, just a temp fix for now.
overrideFile := "/etc/cacophony/lepton-module"
content, err := os.ReadFile(overrideFile)
if err == nil {
cameraModel := strings.TrimSpace(string(content))
header.model = cameraModel
log.Println("Camera model override: " + cameraModel)
} else if !os.IsNotExist(err) {
return nil, err
}
return header, nil
}

Expand Down

0 comments on commit c543ac5

Please sign in to comment.