Skip to content

Commit

Permalink
Make Go Lint happier by adding some explicit type conversions and ign…
Browse files Browse the repository at this point in the history
…oring unused error returns
  • Loading branch information
Stephen Merrony committed May 16, 2018
1 parent 0416524 commit c23d9fc
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions platforms/dji/tello/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,9 @@ func (d *Driver) SendDateTime() (err error) {

now := time.Now()
binary.Write(buf, binary.LittleEndian, byte(0x00))
binary.Write(buf, binary.LittleEndian, now.Hour())
binary.Write(buf, binary.LittleEndian, now.Minute())
binary.Write(buf, binary.LittleEndian, now.Second())
binary.Write(buf, binary.LittleEndian, int16(now.Hour()))
binary.Write(buf, binary.LittleEndian, int16(now.Minute()))
binary.Write(buf, binary.LittleEndian, int16(now.Second()))
binary.Write(buf, binary.LittleEndian, int16(now.UnixNano()/int64(time.Millisecond)&0xff))
binary.Write(buf, binary.LittleEndian, int16(now.UnixNano()/int64(time.Millisecond)>>8))

Expand Down Expand Up @@ -653,15 +653,13 @@ func (d *Driver) handleResponse() error {
case wifiMessage:
buf := bytes.NewReader(buf[9:12])
wd := &WifiData{}

err = binary.Read(buf, binary.LittleEndian, &wd.Disturb)
err = binary.Read(buf, binary.LittleEndian, &wd.Strength)
_ = binary.Read(buf, binary.LittleEndian, &wd.Disturb)
_ = binary.Read(buf, binary.LittleEndian, &wd.Strength)
d.Publish(d.Event(WifiDataEvent), wd)
case lightMessage:
buf := bytes.NewReader(buf[9:10])
var ld int16

err = binary.Read(buf, binary.LittleEndian, &ld)
_ = binary.Read(buf, binary.LittleEndian, &ld)
d.Publish(d.Event(LightStrengthEvent), ld)
case timeCommand:
d.Publish(d.Event(TimeEvent), buf[7:8])
Expand Down Expand Up @@ -732,13 +730,13 @@ func (d *Driver) createPacket(cmd int16, pktType byte, len int16) (buf *bytes.Bu
return buf, nil
}

func validatePitch(val int) int {
if val > 100 {
return 100
}
if val < 0 {
return 0
}
// func validatePitch(val int) int {
// if val > 100 {
// return 100
// }
// if val < 0 {
// return 0
// }

return val
}
// return val
// }

0 comments on commit c23d9fc

Please sign in to comment.