Some debug.
This commit is contained in:
@ -10,7 +10,7 @@ func (g *gps) CheckStatus() error {
|
||||
// Provides more information about signal and possible problems using NMEA reports
|
||||
|
||||
// Collect reports
|
||||
reports, err := g.collectNmeaReports(gpgsv | gpgsa) // Now minimum
|
||||
reports, err := g.collectNmeaReports(nmeaFlagsAll) // Now minimum
|
||||
if err != nil {
|
||||
return fmt.Errorf("collect nmea reports: %w", err)
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ func New(logger *log.Logger, port at.Port) Gps {
|
||||
}
|
||||
|
||||
func (g *gps) Init() error {
|
||||
if g.port.IsConnected() {
|
||||
if !g.port.IsConnected() {
|
||||
return fmt.Errorf("at port is not connected")
|
||||
}
|
||||
return nil
|
||||
|
@ -33,17 +33,17 @@ const (
|
||||
)
|
||||
|
||||
// Go... otherwise will throw warning
|
||||
var _ = gga | rmc | gpgsv | gpgsa | vtg | xfi | glgsa | gns | gagsv | bdpqgsa | bdpqgsv
|
||||
var nmeaFlagsAll = gga | rmc | gpgsv | gpgsa | vtg | xfi | glgsa | gns | gagsv | bdpqgsa | bdpqgsv
|
||||
|
||||
func (g *gps) rawCollect(flags nmeaFlags) (string, error) {
|
||||
// Need to omplement low level write/read here because collect must be atomic operation
|
||||
// If other command is executed(write/read) it will read a part of nmea report and cause an error
|
||||
g.switchGpsMode(true)
|
||||
g.port.Mutex().Lock()
|
||||
s := g.port.SerialPort()
|
||||
defer func() {
|
||||
s.ResetInputBuffer()
|
||||
s.ResetOutputBuffer()
|
||||
g.port.Mutex().Unlock()
|
||||
g.switchGpsMode(false)
|
||||
}()
|
||||
|
||||
// Send AT+CGPSINFOCFG=255, flags
|
||||
@ -57,7 +57,7 @@ func (g *gps) rawCollect(flags nmeaFlags) (string, error) {
|
||||
time.Sleep(collectTimeout)
|
||||
|
||||
// Send AT+CGPSINFOCFG=0, flags
|
||||
if _, err := s.Write([]byte("AT+CGPSINFOCFG=255," + string(flags) + "\r\n")); err != nil {
|
||||
if _, err := s.Write([]byte("AT+CGPSINFOCFG=0," + string(flags) + "\r\n")); err != nil {
|
||||
return "", fmt.Errorf("serial port write 2: %w", err)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user