Thank you very much David for your reply.
But after I used some commands, I didn' have the same replies from the GPS. You can see my answers below.
Thanks in advanced.
toggle quoted message
Show quoted text
On Sun, Jan 31, 2021 at 06:23 PM, David Ranch wrote:
As a test, try this.? The first step initializes and ACTIVATES your serial port.? This example assumes the you're you've logged into the Linux computer with an account which is in the "dialout" group, it's on /dev/ttyS0, and the GPS runs at a serial speed of 4800:
As I can see in the device manual, the baudrate is 115200, should I change it to 4800 or change this 4800 values to 115200?
? ?stty -F /dev/ttyS0 ispeed 4800 ospeed 4800 -ignpar cs8 -cstopb -echo
With the serial port initialized, now you should see if you get output:
?? cat /dev/ttyS0
With me nothing happens. ? I use this python code to start the GPS reciever:
#!/usr/bin/python
?
import serial
import time
?
# Enable Serial Communication
port = serial.Serial("/dev/ttyS0", baudrate=115200, timeout=1)
# Transmitting AT Commands to the Modem
# '\r\n' indicates the Enter key
?
port.write('AT'+'\r\n')? ? ? ? ? ??
time.sleep(.1)
?
port.write('AT+CGNSPWR=1'+'\r\n')? ? ? ? ? ? ?# to power the GPS
time.sleep(.1)
?
port.write('AT+CGNSIPR=115200'+'\r\n') # Set the baud rate of GPS
time.sleep(.1)
?
I start to see the following: -- ??6v&?fF&??c&V??vF?v???F?F??6v?6??c?&V?v??c??V&k $GPGSA,A,3,22,16,03,04,,,,,,,,,9.3,4.8,7.9*3A
$GPRMC,180315.000,A,3720.6142,N,12159.9974,W,0.80,,310121,,,D*6B
$GPGGA,180316.000,3720.6142,N,12159.9977,W,2,04,4.8,37.0,M,-25.7,M,,0000*58
$GPGSA,A,3,22,16,03,04,,,,,,,,,9.3,4.8,7.9*3A
$GPRMC,180316.000,A,3720.6142,N,12159.9977,W,0.98,,310121,,,D*62
$GPGGA,180317.000,3720.6143,N,12159.9977,W,2,04,4.8,36.9,M,-25.7,M,,0000*50
$GPGSA,A,3,22,16,03,04,,,,,,,,,9.3,4.8,7.9*3A
$GPRMC,180317.000,A,3720.6143,N,12159.9977,W,0.39,,310121,,,D*69
$GPGGA,180318.000,3720.6142,N,12159.9976,W,2,04,4.8,37.0,M,-25.7,M,1.8,0000*70 --
If that doesn't work, maybe your GPS needs to be manually initialized before it starts sending NMEA sentences?? Look at the manual to see that once you get the right AT commands in it, can you SAVE those settings as default so it will auto-start.? If not, you'll need to send commands to it.? For example, here is one way to send commands:
GPSPORT=/dev/ttyS0 GPSSPEED=4800
(stty -F $GPSPORT ispeed $GPSSPEED ospeed $GPSSPEED -ignpar cs8 -cstopb -echo; echo -e "AT+\r"; ) <$GPSPORT >$GPSPORT
P.S. - I have the GPSD installed but it doesn't work and I don't know why.
There could be a few reasons here:
?? 1. If the GPS doesn't auto-start, you'll have to initialize it first and then run gpsd.? See the gpsd man page and /etc/gpsd/device-hook to see how to do this the gpsd way
?? 2. GPSD wont' do anything until a client connects to it.
You can test gpsd by doing the following:
?? In terminal #1, run:
????? /usr/sbin/gpsd -N -D 5 /dev/ttyS0 ????? -- ????? gpsd:INFO: launching (Version 3.17) ????? gpsd:IO: opening IPv4 socket ????? gpsd:IO: opening IPv6 socket ????? gpsd:ERROR: can't bind to IPv6 port gpsd, Cannot assign requested address ????? gpsd:INFO: listening on port gpsd ????? gpsd:PROG: NTP: shmat(4,0,0) succeeded, segment 2 ????? gpsd:PROG: NTP: shmat(5,0,0) succeeded, segment 3 ????? gpsd:PROG: NTP: shmat(6,0,0) succeeded, segment 4 ????? gpsd:PROG: NTP: shmat(7,0,0) succeeded, segment 5 ????? gpsd:PROG: NTP: shmat(8,0,0) succeeded, segment 6 ????? gpsd:PROG: NTP: shmat(9,0,0) succeeded, segment 7 ????? gpsd:PROG: successfully connected to the DBUS system bus ????? gpsd:PROG: shmget(0x47505344, 8928, 0666) for SHM export succeeded ????? gpsd:PROG: shmat() for SHM export succeeded, segment 10 ????? gpsd:INFO: stashing device /dev/ttyS0 at slot 0 ????? gpsd:INFO: running with effective group ID 1000 ????? gpsd:INFO: running with effective user ID 1000 ????? gpsd:INFO: startup at 2021-01-31T18:17:57.000Z (1612117077) ????? --
The response to this command was slightly different:
gpsd:INFO: launching (Version 3.17)
gpsd:IO: opening IPv4 socket
gpsd:ERROR: can't bind to IPv4 port gpsd, Address already in use
gpsd:ERROR: maybe gpsd is already running!
gpsd:IO: opening IPv6 socket
gpsd:ERROR: can't bind to IPv6 port gpsd, Address already in use
gpsd:ERROR: maybe gpsd is already running!
gpsd:INFO: command sockets creation failed, netlib errors -1, -1
?
?? In terminal #2, run: ????? cgps ????? -- ????? .01a ","activated":"2021-01-31T18:21:34.306Z","flags":1,"native":1,"bps":4800,"parity":"N","stopbits":1,"cycle":1.00}]} ????? {"class":"WATCH","enable":true,"json":true,"nmea":false,"raw":0,"scaled":false,"timing":false,"split24":false,"pps":false} ????? {"class":"TPV","device":"/dev/ttyUSB0","mode":1,"time":"2025-11-30T18:21:33.730Z","ept":0.005} ????? {"class":"TPV","device":"/dev/ttyUSB0","mode":1,"time":"2025-11-30T18:21:34.730Z","ept":0.005} ????? {"class":"SKY","device":"/dev/ttyUSB0","time":"2025-11-30T18:21:35.730Z","xdop":0.89,"ydop":1.40,"vdop":4.20,"hdop":0.00,"gdop":5.26,"pdop":4.60} ????? {"class":"TPV","device":"/dev/ttyUSB0","mode":1,"time":"2025-11-30T18:21:35.730Z","ept":0.005} ????? {"class":"TPV","device":"/dev/ttyUSB0","mode":1,"time":"2025-11-30T18:21:36.730Z","ept":0.005} ????? {"class":"TPV","device":"/dev/ttyUSB0","mode":1,"time":"2025-11-30T18:21:37.730Z","ept":0.005} ????? {"class":"SKY","device":"/dev/ttyUSB0","time":"2025-11-30T18:21:38.730Z","xdop":0.89,"ydop":1.40,"vdop":4.20,"hdop":0.00,"gdop":5.26,"pdop":4.60} ????? {"class":"TPV","device":"/dev/ttyUSB0","mode":1,"time":"2025-11-30T18:21:38.730Z","ept":0.005} ????? {"class":"TPV","device":"/dev/ttyUSB0","mode":1,"time":"2025-11-30T18:21:39.730Z","ept":0.005} ????? {"class":"TPV","device":"/dev/ttyUSB0","mode":1,"time":"2025-11-30T18:21:40.730Z","ept":0.005} ???? --
--David KI6ZHD
Here you used ttyUSB0, it's like you wrote? ³¢³Ü¨ª²õ
|