Make pin undefined error more verbose

This commit is contained in:
richardsonjack 2018-04-20 11:43:29 +09:30
parent 1437b54450
commit 5b1c814a0e
1 changed files with 9 additions and 2 deletions

View File

@ -213,9 +213,11 @@ func main() {
} }
func netsenderInit() { func netsenderInit() {
//initialize netsender and assign function to check X pins
netsender.InitRevidNetsender() netsender.InitRevidNetsender()
netsender.ExternalReader = revidReportActions netsender.ExternalReader = revidReportActions
//try get initial config
if err := netsender.GetConfig(); err != nil { if err := netsender.GetConfig(); err != nil {
//default to a config????? //default to a config?????
config.Logger.Log("Error", err.Error()) 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(){ func periodicNetsenderReport(){
if !configReceived { if !configReceived {
if err := netsender.GetConfig(); err != nil { if err := netsender.GetConfig(); err != nil {
@ -253,9 +257,11 @@ func periodicNetsenderReport(){
} }
} }
func updateRevid() { func updateRevid() {
revidInst.Stop() revidInst.Stop()
time.Sleep( time.Duration(revidStopTime) * time.Second ) time.Sleep( time.Duration(revidStopTime) * time.Second )
//look through var map and update revid where needed
for key, value := range vars { for key, value := range vars {
switch key { switch key {
case "FramesPerClip": case "FramesPerClip":
@ -357,6 +363,7 @@ func revidReportActions(pin int) (int, error) {
// return int(val), nil // return int(val), nil
// } // }
//function to measure temp of cpu
case pin == cpuTemp: case pin == cpuTemp:
var out []byte var out []byte
var err error var err error
@ -368,7 +375,7 @@ func revidReportActions(pin int) (int, error) {
return -1, errors.New("CPU Temp Read Err: " + err.Error()) return -1, errors.New("CPU Temp Read Err: " + err.Error())
} }
return int(val), nil return int(val), nil
//function to measure usage of cpu
case pin == cpuUsage: case pin == cpuUsage:
stat, err := linuxproc.ReadStat("/proc/stat") stat, err := linuxproc.ReadStat("/proc/stat")
if err != nil { if err != nil {
@ -398,7 +405,7 @@ func revidReportActions(pin int) (int, error) {
// return int(processManager.PriorityLevel), nil // return int(processManager.PriorityLevel), nil
default: default:
return -1, errors.New("External pin not defined") return -1, errors.New("External pin" + pin + " not defined")
} }
} }