Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPS assist load in development #148

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 48 additions & 2 deletions main/ry835ai.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"log"
"io"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -97,6 +98,42 @@ func makeUBXCFG(class, id byte, msglen uint16, msg []byte) []byte {
return ret
}

func sendGPSAssist() {
f, err := os.Open("/root/current_14d.alp")
if err != nil {
log.Printf("Cannot send assist data due to file missing!\n")
return
}
done := make([]byte, 1)

done[0] = 0xff;
serialPort.Write(makeUBXCFG(0x0b,0x50, 1, done))
time.Sleep(100 * time.Millisecond)

defer f.Close()
data := make([]byte, 512)
for {
data = data[:cap(data)]
n, err := f.Read(data)
if err != nil {
if err == io.EOF {
break
}
log.Printf("Something is dicked up!\n")
return
}
data = data[:n]
log.Printf("Sending %d bytes\n",n)
serialPort.Write(makeUBXCFG(0x0b, 0x50, uint16(n), data ))
time.Sleep(100 * time.Millisecond)
}
done[0] = 0xff;
serialPort.Write(makeUBXCFG(0x0b,0x50, 1, done))



}

func initGPSSerial() bool {
var device string
if _, err := os.Stat("/dev/ttyACM0"); err == nil {
Expand All @@ -121,8 +158,8 @@ func initGPSSerial() bool {
return false
}

// Set 10Hz update.
p.Write(makeUBXCFG(0x06, 0x08, 6, []byte{0x64, 0x00, 0x00, 0x01, 0x00, 0x01}))
// Set 1Hz update.
p.Write(makeUBXCFG(0x06, 0x08, 6, []byte{0xe8, 0x03, 0x00, 0x01, 0x00, 0x01}))

// Set navigation settings.
nav := make([]byte, 36)
Expand Down Expand Up @@ -171,6 +208,15 @@ func initGPSSerial() bool {

p.Write(makeUBXCFG(0x06, 0x00, 20, cfg))

// Set 1Hz update.
p.Write(makeUBXCFG(0x06, 0x08, 6, []byte{0xe8, 0x03, 0x00, 0x01, 0x00, 0x01}))


sendGPSAssist()

// Set 10Hz update.
p.Write(makeUBXCFG(0x06, 0x08, 6, []byte{0x64, 0x00, 0x00, 0x01, 0x00, 0x01}))

p.Close()

return true
Expand Down