From 7da2097cf9c66303d325899cf4359fa576b0e985 Mon Sep 17 00:00:00 2001 From: Russell Stanley Date: Fri, 7 Jan 2022 14:42:15 +1030 Subject: [PATCH] added testing file and began write implementation --- cmd/rv/main.go | 17 +++++++++++++---- cmd/rv/probe_test.go | 18 ++++++++++++++++++ revid/audio_OSX.go | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 cmd/rv/probe_test.go create mode 100644 revid/audio_OSX.go diff --git a/cmd/rv/main.go b/cmd/rv/main.go index 031381b2..9590f53f 100644 --- a/cmd/rv/main.go +++ b/cmd/rv/main.go @@ -61,6 +61,7 @@ import ( "strconv" "time" + "gocv.io/x/gocv" "gopkg.in/natefinch/lumberjack.v2" "bitbucket.org/ausocean/av/container/mts" @@ -104,7 +105,7 @@ const ( profilePath = "rv.prof" pkg = "rv: " runPreDelay = 20 * time.Second - turbidity + turbidityDelay = 60 * time.Second ) // Software define pin values. @@ -125,17 +126,25 @@ type turbidityProbe struct { // TODO(Russell): complete this implementation of Write. func (tp *turbidityProbe) Write(p []byte) (int, error) { - ticker := time.NewTicker(500 * time.Millisecond) + ticker := time.NewTicker(turbidityDelay) + const ( + rows = 2464 + cols = 3280 + ) go func() { for { select { case <-ticker.C: - - // Implementation here + mat, err := gocv.NewMatFromBytes(rows, cols, gocv.MatTypeCV8U, p) // IMDecode may also work + if err != nil { + //TODO + } + mat.GetUCharAt(0, 0) } } }() + return len(p), nil } diff --git a/cmd/rv/probe_test.go b/cmd/rv/probe_test.go new file mode 100644 index 00000000..4468af0a --- /dev/null +++ b/cmd/rv/probe_test.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "testing" +) + +func TestMain(m *testing.M) { + + ts := new(turbidityProbe) + + frame := make([]byte, 10) + + size, err := ts.Write(frame) + + fmt.Println(size) + fmt.Println(err) +} diff --git a/revid/audio_OSX.go b/revid/audio_OSX.go new file mode 100644 index 00000000..b31e3e47 --- /dev/null +++ b/revid/audio_OSX.go @@ -0,0 +1,33 @@ +/* +NAME + audio_OSX.go + +AUTHORS + Russell Stanley + +LICENSE + revid is Copyright (C) 2021 the Australian Ocean Lab (AusOcean) + + It is free software: you can redistribute it and/or modify them + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + It is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + in gpl.txt. If not, see http://www.gnu.org/licenses. +*/ + +package revid + +import ( + "errors" +) + +func (r *Revid) setupAudio() error { + return errors.New("audio not implemented on OSX") +}