1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
PROJECT = "Air720_GPS" VERSION = "2.0.0" PRODUCT_KEY = "v32xEAKsGTIEQxtqgwCldp5aPlcnPs3K"
require "log" LOG_LEVEL = log.LOGLEVEL_TRACE
require "sys"
require "net"
net.startQueryAll(60000, 60000)
gps_lib = "gps"
if gps_lib == "gps" then require"gps" require"agps" local function printGps() if gps.isOpen() then local tLocation = gps.getLocation() local speed = gps.getSpeed() log.info("testGps.printGps", gps.isOpen(),gps.isFix(), tLocation.lngType,tLocation.lng,tLocation.latType,tLocation.lat, gps.getAltitude(), speed, gps.getCourse(), gps.getViewedSateCnt(), gps.getUsedSateCnt()) end end gps.setUart(2, 9600,8,uart.PAR_NONE,uart.STOP_1) gps.open(gps.DEFAULT,{tag="TEST1"}) sys.timerLoopStart(printGps,2000) else require "gpsv2" sys.taskInit(function(...) gpsv2.open(2, 9600, 2, 5) while true do log.info("testGps isFix:", gpsv2.isFix()) log.info("testGps lng,lat:", gpsv2.getIntLocation()) log.info("testGps message:", gpsv2.getAltitude(), gpsv2.getSpeed(), gpsv2.getAzimuth(), gpsv2.getUsedSateCnt(), gpsv2.getViewedSateCnt()) sys.wait(1000) end end) end
sys.init(0, 0) sys.run()
|