2017年6月7日 星期三

[RPi] 解決 GlobalStat BU-353-S4 亂碼問題

在 FAQ 裡寫得很清楚:

37Q) I am seeing strange characters being outputed on GPSInfo & the red LED isn't on. How can I fix this?

37A) Please follow these steps:

1. Download and install this software: http://www.usglobalsat.com/store/downloads/SiRFDemo387.zip

2. Run the Sirf Demo software.

3. Connect your device, choose the correct COM port, and select the 4800 baud rate.

4. Go to Action > Open Data Source.

5. Next, go to Action > Synchronize Protocol & baud rate.

6. Then, go to Action > Switch to NMEA Protocol.

7. In the pop-up window, select the 4800 baud rate under the Baud Rate and click Send.

8. Close the Sirf Demo software.

測試程式
import serial

ser = serial.Serial("/dev/ttyUSB0", 4800, timeout=0.5)

while True:
    try:
        str = ser.readline()
        print str
    except Exception as e:
        print(e)
        pass


如果在執行 cgps -s 以後, 再執行測試程式以後可能會變成亂碼, 一個方法就是透過上面的 GPSInfo 修改, 另一個方法就是透過指令列修改
sudo pkill gpsd
sudo stty 4800 > /dev/ttyUSB0
sudo gpsd -b /dev/ttyUSB0
cat /dev/ttyUSB0     # CTRL+c to stop


順帶一提, 這邊有不錯的範例程式
https://www.raspberrypi.org/forums/viewtopic.php?t=172893&p=1105715

reference:
* https://askubuntu.com/questions/30569/how-to-use-gps-receiver-bu-353

沒有留言: