MYD-YA157C系列定制板GPS數據讀取
在linux下,大多使用串口接收gps模塊的原始數據,通過運行ls /dev命令,我們發現:
root@myir:~# ls /dev autofs fuse gpiochip9 loop-control mmcblk2 net ptyp4 ram13 ram9 stdout tty16 tty25 tty34 tty43 tty52 tty61 ttyp1 vcs vcsa3 vcsu6 block gpiochip0 hwrng loop0 mmcblk2boot0 null ptyp5 ram14 random tty tty17 tty26 tty35 tty44 tty53 tty62 ttyp2 vcs1 vcsa4 watchdog bus gpiochip1 i2c-0 loop1 mmcblk2boot1 ppp ptyp6 ram15 rfkill tty0 tty18 tty27 tty36 tty45 tty54 tty63 ttyp3 vcs2 vcsa5 watchdog0 cec0 gpiochip2 i2c-1 loop2 mmcblk2p1 ptmx ptyp7 ram2 rtc tty1 tty19 tty28 tty37 tty46 tty55 tty7 ttyp4 vcs3 vcsa6 zero char gpiochip3 iio:device0 loop3 mmcblk2p2 ptp0 qcqmi1 ram3 rtc0 tty10 tty2 tty29 tty38 tty47 tty56 tty8 ttyp5 vcs4 vcsu console gpiochip4 initctl loop4 mmcblk2p3 pts ram0 ram4 shm tty11 tty20 tty3 tty39 tty48 tty57 tty9 ttyp6 vcs5 vcsu1 cpu_dma_latency gpiochip5 input loop5 mmcblk2p4 ptyp0 ram1 ram5 snd tty12 tty21 tty30 tty4 tty49 tty58 ttySTM0 ttyp7 vcs6 vcsu2 disk gpiochip6 kmsg loop6 mmcblk2p5 ptyp1 ram10 ram6 spidev0.0 tty13 tty22 tty31 tty40 tty5 tty59 ttySTM2 ubi_ctrl vcsa vcsu3 fd gpiochip7 lircd loop7 mmcblk2rpmb ptyp2 ram11 ram7 stderr tty14 tty23 tty32 tty41 tty50 tty6 ttySTM3 uinput vcsa1 vcsu4 full gpiochip8 log mem mqueue ptyp3 ram12 ram8 stdin tty15 tty24 tty33 tty42 tty51 tty60 ttyp0 urandom vcsa2 vcsu5
在這個目錄中包含了所有Linux系統中使用的外部設備。但是這里並不是放的外部設備的驅動程序,這一點和其他操作系統不一樣。它實際上是一個訪問這些外部設備的端口。我們可以非常方便地去訪問這些外部設備,和訪問一個文件,一個目錄沒有任何區別。
盲猜ttySTM0-3中可能是我們GPS與主機通信的串口端口,我們使用microcom命令逐個測試一下。
Usage: microcom [-d DELAY] [-t TIMEOUT] [-s SPEED] [-X] TTY
參數如下:
-d 表示延時時間,一般我都不設置。
-t 表示超時時間,超多少時間就自動退出。單位為ms
-s 表示傳輸速度,波特率的意思,這個根據自己的情況而定。
-X 不加
最后指定你的串口設備。如 /dev/tty0
這個開發板使用的GPS芯片為BD-1612Z,通過查詢網上的參數得知:
波特率范圍:4800 bps ~115200 bps,默認9600bps,
8個數據位,無校驗,1個停止位
該GPS模塊默認使用9600bps波特率。使用microcom命令調試串口:
root@myir:~# microcom -s 9600 /dev/ttySTM3
終端成功打印出GPS信息,調試成功。