오류 수정
This commit is contained in:
parent
128ae98e91
commit
53c8085aa9
|
@ -48,10 +48,9 @@ func (c *fanControl) StartControl() {
|
||||||
log.Info("Fan control started")
|
log.Info("Fan control started")
|
||||||
|
|
||||||
ticker := time.Tick(c.sampleDuration)
|
ticker := time.Tick(c.sampleDuration)
|
||||||
fanSpeedList := make([]int, c.processorCount)
|
pastFanSpeedList := make([]int, c.processorCount)
|
||||||
|
|
||||||
for {
|
|
||||||
newFanSpeedList := make([]int, c.processorCount)
|
newFanSpeedList := make([]int, c.processorCount)
|
||||||
|
for {
|
||||||
checker:
|
checker:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -63,11 +62,11 @@ func (c *fanControl) StartControl() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!compareFanSpeed(fanSpeedList, newFanSpeedList)) {
|
if (!compareFanSpeed(pastFanSpeedList, newFanSpeedList)) {
|
||||||
copy(fanSpeedList, newFanSpeedList)
|
copy(pastFanSpeedList, newFanSpeedList)
|
||||||
args := make([]string, 0)
|
args := make([]string, 0)
|
||||||
args = append(args, "raw", "0x3a", "0x01", )
|
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, fmt.Sprintf("0x%x", item))
|
||||||
}
|
}
|
||||||
args = append(args,
|
args = append(args,
|
||||||
|
@ -89,6 +88,7 @@ func (c *fanControl) StartControl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func compareFanSpeed(old, new []int) bool {
|
func compareFanSpeed(old, new []int) bool {
|
||||||
|
new = new[:len(old)] // this line is the key
|
||||||
for i, v := range old {
|
for i, v := range old {
|
||||||
if v != new[i] { // here is no bounds checking for b[i]
|
if v != new[i] { // here is no bounds checking for b[i]
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue