From 5b1c814a0e690ea09fb481b88624efcd3ae5e31b Mon Sep 17 00:00:00 2001 From: richardsonjack Date: Fri, 20 Apr 2018 11:43:29 +0930 Subject: [PATCH] Make pin undefined error more verbose --- RevidCLI.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/RevidCLI.go b/RevidCLI.go index 3677c57f..ca50f0e7 100644 --- a/RevidCLI.go +++ b/RevidCLI.go @@ -213,9 +213,11 @@ func main() { } func netsenderInit() { + //initialize netsender and assign function to check X pins netsender.InitRevidNetsender() netsender.ExternalReader = revidReportActions + //try get initial config if err := netsender.GetConfig(); err != nil { //default to a config????? config.Logger.Log("Error", err.Error()) @@ -224,6 +226,8 @@ func netsenderInit() { } } +//periodicNetsenderReport is called by the main function every monPeriod seconds. It makes sure a config has been recieved, and then +//reports back CPU stats and updates vars func periodicNetsenderReport(){ if !configReceived { if err := netsender.GetConfig(); err != nil { @@ -253,9 +257,11 @@ func periodicNetsenderReport(){ } } + func updateRevid() { revidInst.Stop() time.Sleep( time.Duration(revidStopTime) * time.Second ) + //look through var map and update revid where needed for key, value := range vars { switch key { case "FramesPerClip": @@ -357,6 +363,7 @@ func revidReportActions(pin int) (int, error) { // return int(val), nil // } + //function to measure temp of cpu case pin == cpuTemp: var out []byte var err error @@ -368,7 +375,7 @@ func revidReportActions(pin int) (int, error) { return -1, errors.New("CPU Temp Read Err: " + err.Error()) } return int(val), nil - + //function to measure usage of cpu case pin == cpuUsage: stat, err := linuxproc.ReadStat("/proc/stat") if err != nil { @@ -398,7 +405,7 @@ func revidReportActions(pin int) (int, error) { // return int(processManager.PriorityLevel), nil default: - return -1, errors.New("External pin not defined") + return -1, errors.New("External pin" + pin + " not defined") } }