added testing file and began write implementation

This commit is contained in:
Russell Stanley 2022-01-07 14:42:15 +10:30 committed by Saxon Nelson-Milton
parent 0c6d9d0132
commit 7da2097cf9
3 changed files with 64 additions and 4 deletions

View File

@ -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
}

18
cmd/rv/probe_test.go Normal file
View File

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

33
revid/audio_OSX.go Normal file
View File

@ -0,0 +1,33 @@
/*
NAME
audio_OSX.go
AUTHORS
Russell Stanley <russell@ausocean.org>
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")
}