Merge pull request #58 from jpoirier/development

shift direction fix
pull/67/head
cyoung 2015-09-24 00:53:08 -04:00
commit 84fb44f6b2
1 zmienionych plików z 8 dodań i 6 usunięć

Wyświetl plik

@ -9,14 +9,16 @@ import (
"time" "time"
"bufio" "bufio"
"github.com/kidoman/embd" "github.com/kidoman/embd"
_ "github.com/kidoman/embd/host/all" _ "github.com/kidoman/embd/host/all"
"github.com/kidoman/embd/sensor/bmp180" "github.com/kidoman/embd/sensor/bmp180"
"github.com/tarm/serial" "github.com/tarm/serial"
"../mpu6050"
"os" "os"
"os/exec" "os/exec"
"../mpu6050"
) )
type SituationData struct { type SituationData struct {
@ -86,7 +88,7 @@ func makeUBXCFG(class, id byte, msglen uint16, msg []byte) []byte {
ret[2] = class ret[2] = class
ret[3] = id ret[3] = id
ret[4] = byte(msglen & 0xFF) ret[4] = byte(msglen & 0xFF)
ret[5] = byte((msglen & 0xFF00) << 8) ret[5] = byte((msglen >> 8) & 0xFF)
ret = append(ret, msg...) ret = append(ret, msg...)
chk := chksumUBX(ret[2:]) chk := chksumUBX(ret[2:])
ret = append(ret, chk[0]) ret = append(ret, chk[0])
@ -147,9 +149,9 @@ func initGPSSerial() bool {
// Baud rate. // Baud rate.
bdrt := uint32(115200) bdrt := uint32(115200)
cfg[8] = byte((bdrt & 0xFF000000) << 24) cfg[8] = byte((bdrt >> 24) & 0xFF)
cfg[9] = byte((bdrt & 0xFF0000) << 16) cfg[9] = byte((bdrt >> 16) & 0xFF)
cfg[10] = byte((bdrt & 0xFF00) << 8) cfg[10] = byte((bdrt >> 8) & 0xFF)
cfg[11] = byte(bdrt & 0xFF) cfg[11] = byte(bdrt & 0xFF)
// inProtoMask. NMEA and UBX. // inProtoMask. NMEA and UBX.
@ -370,7 +372,7 @@ func processNMEALine(l string) bool {
gpsTimeStr := fmt.Sprintf("%s %d:%d:%d", x[8], hr, min, sec) gpsTimeStr := fmt.Sprintf("%s %d:%d:%d", x[8], hr, min, sec)
gpsTime, err := time.Parse("020106 15:04:05", gpsTimeStr) gpsTime, err := time.Parse("020106 15:04:05", gpsTimeStr)
if err == nil { if err == nil {
if time.Since(gpsTime) > 10 * time.Minute { if time.Since(gpsTime) > 10*time.Minute {
log.Printf("setting system time to: %s\n", gpsTime) log.Printf("setting system time to: %s\n", gpsTime)
setStr := gpsTime.Format("20060102 15:04:05") setStr := gpsTime.Format("20060102 15:04:05")
if err := exec.Command("date", "-s", setStr).Run(); err != nil { if err := exec.Command("date", "-s", setStr).Run(); err != nil {