gpsd-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

powering on gps device


From: Nachiket Gokhale
Subject: powering on gps device
Date: Tue, 22 Jun 2021 15:34:52 +0530

Hello all,

I'd like to know how I can send the right commands to my gps device to power it up.

Apologies if my question is simple or obvious. I'm very new to communicating with serial (or gps) devices. I'm trying to install gpsd on a Raspberry Pi. As per the instructions at

https://gpsd.io/installation.html

I should first check if I can get data from my GPS using

stty -F /dev/ttyS0 ispeed 4800 && cat </dev/ttyS0

This does not yield anything. So, I should fix this first. I think this is because the device is not powering up. However, I can send the right AT commands to power up the device attached to the serial port using the Python script given at the end of this message. I open two terminals, run the Python script in one of them and type

cat /dev/ttyS0 

in the other terminal. The cat then gives me GPGGA sentences. 

However, 

gpsmon /dev/ttyS0 gives

gpsmon:ERROR: SER: /dev/ttyS0 already opened by another process

Which makes me think that what I did is not good enough for gpsd, because doing gpsd -N -D3  /dev/ttyS0 gives:

gpsd:INFO: launching (Version 3.17)
gpsd:INFO: listening on port gpsd
gpsd:INFO: stashing device /dev/ttyS0 at slot 0
gpsd:INFO: running with effective group ID 20
gpsd:INFO: running with effective user ID 115
gpsd:INFO: startup at 2021-06-22T09:56:52.000Z (1624355812)
gpsd:CLIENT: => client(0): {"class":"VERSION","release":"3.17","rev":"3.17","proto_major":3,"proto_minor":12}\x0d\x0a
gpsd:CLIENT: <= client(0): ?WATCH={"enable":true,"json":true}\x0a
gpsd:INFO: SER: opening GPS data source type 2 at '/dev/ttyS0'
gpsd:ERROR: SER: device open of /dev/ttyS0 failed: Device or resource busy - retrying read-only
gpsd:ERROR: SER: read-only device open of /dev/ttyS0 failed: Device or resource busy
gpsd:ERROR: /dev/ttyS0: device activation failed.
gpsd:ERROR: /dev/ttyS0: activation failed, freeing device
gpsd:CLIENT: => client(0): {"class":"DEVICES","devices":[]}\x0d\x0a{"class":"WATCH","enable":true,"json":true,"nmea":false,"raw":0,"scaled":false,"timing":false,"split24":false,"pps":false}\x0d\x0a
gpsd:INFO: detaching 127.0.0.1 (sub 0, fd 6) in detach_client

So how can I wake up the device and make it available to gpsd?

Nachiket

The Python script follows:

from time import sleep
import serial

ser = serial.Serial(
    port='/dev/ttyS0', #Replace ttyS0 with ttyAM0 for Pi1,Pi2,Pi0
    baudrate = 115200,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.EIGHTBITS,
    timeout=1
)

# print (ser.name) # check which serial port was actually used

print ("Turn ON GPS Power (AT+CGPSPWR=1)")
ser.write(bytes("AT+CGPSPWR=1\n", 'utf-8')) #turn on the GPS module
rx = ser.readline()
print (rx.decode('utf-8'))

# sleep(30) # Wait till the module gets a fix. This typically takes between 20-60s.
sleepsecs = 15
print ("Waiting for {}s to get a GPS fix...".format(sleepsecs))
while sleepsecs:
    mins, secs = divmod(sleepsecs, 60)
    timer = '{:02d}:{:02d}'.format(mins, secs)
    print(timer, end="\r")
    sleep(1)
    sleepsecs -= 1
#
while True:
    print('Staying alive')
    sleep(5)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]