2015년 3월 19일 목요일

android에서 USB GPS Module 확인 방법

hardkernel에서 판매 중인 USB GPS Module입니다.

ODROID에 연결하면 아래와 같이 /dev/ttyACM0 노드가 생깁니다.

root@odroidxu3:/ # ls -l /dev/ttyACM0                                        
crw-rw-rw- gps      gps      166,   0 2015-03-19 16:46 ttyACM0

cat으로 노드를 읽어 보면 NMEA 값이 출력이 됩니다.

root@odroidxu3:/ # cat /dev/ttyACM0                                            
$GPRMC,,V,,,,,,,,,,N*53
$GPVTG,,,,,,,,,N*30
$GPGGA,,,,,,0,00,99.99,,,,,,*48
$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
$GPGSV,1,1,04,06,,,22,16,,,21,18,,,23,23,,,28*7C
$GPGLL,,,,,,V,N*64
$GPRMC,,V,,,,,,,,,,N*53
$GPVTG,,,,,,,,,N*30
$GPGGA,,,,,,0,00,99.99,,,,,,*48
$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
$GPGSV,1,1,04,06,,,22,16,,,21,18,,,22,22,,,22*76
$GPGLL,,,,,,V,N*64
$GPRMC,,V,,,,,,,,,,N*53
$GPVTG,,,,,,,,,N*30
$GPGGA,,,,,,0,00,99.99,,,,,,*48
$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
$GPGSV,1,1,04,06,,,22,16,,,21,18,,,22,22,,,21*75
$GPGLL,,,,,,V,N*64
$GPRMC,,V,,,,,,,,,,N*53
^C
130|root@odroidxu3:/ # 

google apps을 설치하고 GPS를 사용하는 app을 실행하면 adb logcat으로도 GPS 정보가 올라오는지 확인이 가능합니다.


D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPRMC,,V,,,,,,,,,,N*53
D/libmbm-gps( 3167): RMC
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPVTG,,,,,,,,,N*30
D/libmbm-gps( 3167): unknown sentence 'GPVTG
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPGGA,,,,,,0,00,99.99,,,,,,*48
D/libmbm-gps( 3167): GGA
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
D/libmbm-gps( 3167): GSA
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPGSV,1,1,00*79
D/libmbm-gps( 3167): GSV
D/libmbm-gps( 3167): NR sat: 'GSV'
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPGLL,,,,,,V,N*64
D/libmbm-gps( 3167): GLL
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPRMC,,V,,,,,,,,,,N*53
D/libmbm-gps( 3167): RMC
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPVTG,,,,,,,,,N*30
D/libmbm-gps( 3167): unknown sentence 'GPVTG
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPGGA,,,,,,0,00,99.99,,,,,,*48
D/libmbm-gps( 3167): GGA
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
D/libmbm-gps( 3167): GSA
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPGSV,1,1,01,18,,,28*7B
D/libmbm-gps( 3167): GSV
D/libmbm-gps( 3167): NR sat: 'GSV'
D/libmbm-gps( 3167): nmea_reader_parse: GSV message with total satellites 1
D/libmbm-gps( 3167): update sv status
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPGLL,,,,,,V,N*64
D/libmbm-gps( 3167): GLL
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPRMC,,V,,,,,,,,,,N*53
D/libmbm-gps( 3167): RMC
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPVTG,,,,,,,,,N*30
D/libmbm-gps( 3167): unknown sentence 'GPVTG
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPGGA,,,,,,0,00,99.99,,,,,,*48
D/libmbm-gps( 3167): GGA
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
D/libmbm-gps( 3167): GSA
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPGSV,1,1,01,17,,,21*7D
D/libmbm-gps( 3167): GSV
D/libmbm-gps( 3167): NR sat: 'GSV'
D/libmbm-gps( 3167): nmea_reader_parse: GSV message with total satellites 1
D/libmbm-gps( 3167): update sv status
D/libmbm-gps( 3167): Got an nmea string, parsing.
D/libmbm-gps( 3167): Received: $GPGLL,,,,,,V,N*64
D/libmbm-gps( 3167): GLL


소스 코드는 아래에서 확인이 가능합니다.


GPS 노드 이름이 다르거나 baud rate가 다르면 build.prop에 아래 부분을 수정 하시면 GPS library에서 두 정보를 읽어 처리 하도록 되어 있습니다.

ro.kernel.android.gps=/dev/ttyACM0
ro.kernel.android.gps.speed=9600