Skip to content

Commit a9dad82

Browse files
committed
fix gain index
1 parent ba76e01 commit a9dad82

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cmd/lms_tcp.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var tunerValues []int
3030

3131
func init() {
3232
for i := 0; i < 32; i++ {
33-
tunerValues = append(tunerValues, i*4)
33+
tunerValues = append(tunerValues, i*6)
3434
}
3535
}
3636

@@ -112,18 +112,18 @@ func main() {
112112
case rtltcp.SetBiasTee:
113113
case rtltcp.SetGain:
114114
gain := binary.BigEndian.Uint32(cmd.Param[:])
115-
gainU := uint(gain / 10)
115+
gainU := uint(gain / 4)
116116
fmt.Printf("Setting gain to %d\n", gainU)
117117
dev.SetGainDB(*channel, true, gainU)
118118
case rtltcp.SetGainMode:
119119
case rtltcp.SetTunerGainByIndex:
120120
gainIdx := binary.BigEndian.Uint32(cmd.Param[:])
121-
if uint32(len(tunerValues)) < gainIdx {
121+
if uint32(len(tunerValues)) > gainIdx {
122122
gain := tunerValues[gainIdx]
123123
fmt.Printf("Setting gain to %d (idx %d)\n", gain, gainIdx)
124124
dev.SetGainDB(*channel, true, uint(gain))
125125
} else {
126-
fmt.Printf("Received gain index: %d but that's invalid. maximum is %d\n", len(tunerValues))
126+
fmt.Printf("Received gain index: %d but that's invalid. maximum is %d\n", gainIdx, len(tunerValues))
127127
}
128128
case rtltcp.SetFrequency:
129129
frequency := binary.BigEndian.Uint32(cmd.Param[:])

0 commit comments

Comments
 (0)