1
0
Fork 0

오류 수정

This commit is contained in:
Sangbum Kim 2017-09-11 01:18:37 +09:00
parent 128ae98e91
commit 53c8085aa9
1 changed files with 6 additions and 6 deletions

View File

@ -48,10 +48,9 @@ func (c *fanControl) StartControl() {
log.Info("Fan control started")
ticker := time.Tick(c.sampleDuration)
fanSpeedList := make([]int, c.processorCount)
for {
pastFanSpeedList := make([]int, c.processorCount)
newFanSpeedList := make([]int, c.processorCount)
for {
checker:
for {
select {
@ -63,11 +62,11 @@ func (c *fanControl) StartControl() {
return
}
}
if (!compareFanSpeed(fanSpeedList, newFanSpeedList)) {
copy(fanSpeedList, newFanSpeedList)
if (!compareFanSpeed(pastFanSpeedList, newFanSpeedList)) {
copy(pastFanSpeedList, newFanSpeedList)
args := make([]string, 0)
args = append(args, "raw", "0x3a", "0x01", )
for _, item := range fanSpeedList {
for _, item := range newFanSpeedList {
args = append(args, fmt.Sprintf("0x%x", item))
}
args = append(args,
@ -89,6 +88,7 @@ func (c *fanControl) StartControl() {
}
func compareFanSpeed(old, new []int) bool {
new = new[:len(old)] // this line is the key
for i, v := range old {
if v != new[i] { // here is no bounds checking for b[i]
return false