summaryrefslogtreecommitdiff
path: root/src/camera.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/camera.go')
-rw-r--r--src/camera.go63
1 files changed, 1 insertions, 62 deletions
diff --git a/src/camera.go b/src/camera.go
index 519cc65..fe1140e 100644
--- a/src/camera.go
+++ b/src/camera.go
@@ -2,14 +2,6 @@
package main
-import (
- "log"
- "os/exec"
- "os"
- "path/filepath"
- "bufio"
-)
-
type Camera struct {
statemachine Machine
}
@@ -44,63 +36,10 @@ func NewCamera() Camera {
func runCameraHooks(last string, next string, m *Machine) {
if last == "idle" && next == "single_picture" {
- go singlePicture(m)
+ ipc.WriteLineTo("picamera", "single_picture\n")
}
}
-func singlePicture(m *Machine) {
-
- // create command
- var cmd *exec.Cmd
- if !config.Flag.Debug {
- cmd = exec.Command("/usr/bin/python3", "/usr/lib/python3.9/site-packages/birdscan/")
- } else { // debug mode
- pwd,err := os.Getwd()
- if err != nil {
- log.Fatal(err)
- }
- repoDir := filepath.Dir(pwd)
- log.Printf("Repository path is assumed to be = '%s'", repoDir)
- pythonPackage := repoDir + "/python/birdscan"
- cmd = exec.Command("/usr/bin/python3", pythonPackage, "--debug")
- }
-
- // connect stdout of python process
- stdout,err := cmd.StdoutPipe()
- if err != nil {
- log.Print(err)
- }
- defer stdout.Close()
-
- // run command
- err = cmd.Start()
- if err != nil {
- log.Print(err)
- }
-
- scanner := bufio.NewScanner(stdout)
- for scanner.Scan() {
- text := scanner.Text()
- log.Printf("Python returned '%s'", text)
- if text == "ok" {
- break
- }
- }
-
- err = cmd.Wait() // wait until command execution and io is complete
- if err != nil {
- log.Print(err)
- }
-
- // process result
- m.SendEvent("single_picture_taken")
-}
-
func (cam *Camera) run() {
cam.statemachine.Run()
}
-
-// read until '\n'
-func readLine(buff *[]byte, ) {
-
-}