'GPS Interface func main() output 5 global hour,min,sec,day,month,year global longdeg global latdeg global latmin as float global longmin as float global strdat(80) as string global strtest(80) as string global strtemp(80) as string global speed as float global dir as float global latdir global longdir clear hsersetup baud,HBAUD57600 loop: getGPS() print "-----------------------------" print latdeg," ",{-6.4} latmin, " ",nodec latdir print longdeg," ",{-6.4} longmin, " ",nodec longdir print print "dir ",{4.1} dir print "speed ", {3.1} speed print DECMASK = %10000011 print day,"/",month,"/",year," ",hour,":",min,":",sec DECMASK = %11111111 print "-----------------------------" goto loop endfunc func getGPS() dim dat,stat clear strdat,strtest hsersetup start,clear loop: toggle 5 hserin loop,dat if dat = 13 then goto loop if dat = 10 then STRgetword(strdat,1,',',strtest) stat = STRinstr(strtest,"$GPRMC") if stat <> 1000 then hsersetup stop procGPRMC() exit 0 goto loop endif clear strdat,strtest goto loop endif strdat = * + dat goto loop endfunc '------------------------------------------ func procGPRMC() 'Get Time GPSfield(2) hour=GPSfieldval(0,2) min=GPSfieldval(2,2) sec=GPSfieldval(4,2) 'Get Date GPSfield(10) day=GPSfieldval(0,2) month=GPSfieldval(2,2) year=GPSfieldval(4,2) 'Get Speed GPSfield(8) speed = GPSfloatval(0) * 1.15207 'Get Dir GPSfield(9) dir = GPSfloatval(0) 'get lat GPSfield(4) latdeg = GPSfieldval(0,2) latmin = GPSfloatval(2) GPSfield(5) latdir = #strtest 'Get Long GPSfield(6) longdeg = GPSfieldval(0,3) longmin = GPSfloatval(3) GPSfield(7) longdir = #strtest endfunc '------------------------------------------------------ 'GPS Support Routines '------------------------------------------------------ func GPSfield(fld) STRgetword(strdat,fld,',',strtest) endfunc '------------------------------------------------------- function GPSfieldval(pos,len) dim tval strtemp = strtest(pos,len) : tval = STRval(strtemp) exit tval endfunc '------------------------------------------------------- function GPSfloatval(pos,mode) as float dim decpos dim tlen,x,mult dim lval as float dim rval as float 'clear rval,lval if OPP8 <> 2 then strtemp = strtest(pos,255) else strtemp = strtest(pos,mode) endif 'Locate decimal point decpos = STRinstr(strtemp,".") lval = STRval(strtemp,".") if decpos <> 1000 then rval = STRval(decpos+1) tlen = STRlen(decpos+1) for x = 0 to tlen - 1 rval = rval / 10.0 next lval = lval + rval exit lval else exit lval endif endfunc include \lib\DiosString.lib include \lib\DiosDispFloat.lib