Since Windows Mobile provided the gpsid interface, the communication problem between Windows Mobile and GPS devices is greatly omitted, serial Port and thread, Which is troublesome!
It seems that after wm5.0, we have provided the gpsid driver interface, which greatly simplifies our work, however, a small bug was found in the interface provided by Microsoft during simulator debugging! In the gpsid library provided by Microsoft, a file gpsposition. CS has a bug.
Code /// <Summary> /// Parses out the degrees, minutes, seconds from the double format returned /// The nmea gps device /// </Summary> /// <Param name = "Val"> degrees, minutes, seconds as a double </param> /// <Returns> degreesminutesseconds structure </returns> Private Degreesminutesseconds parsedegreesminutesseconds ( Double Val ){ If (Val <0) val =-val; // Ddmm. Mmmmm format in Windows mobile5.0 and DD. dddddddd format in wm6.0 Int Marjor = system. environment. osversion. version. Major; Int Minor = system. environment. osversion. version. Minor; If (Marjor = 5 & minor = 0) // Windows Mobile 5.0 { Double Degrees = (Val/100.0 ); Double Minutes = (math. Abs (degrees)-math. Abs (( Double )( Int ) (Degrees) * 100; Double Seconds = (math. Abs (VAL)-math. Abs (( Double )( Int ) Val) * 60.0; Return New Degreesminutesseconds (( Int ) Degrees ,(Int ) Minutes, seconds );} Else { // Windows Mobile 6.0 Int Degrees = ( Int ) (VAL ); Double Dminutes = (Val-degrees) * 60.0; Int Minutes = ( Int ) Dminutes; Double Seconds = (dminutes-minutes) * 60.0; Return New Degreesminutesseconds (degrees, minutes, seconds );}}
After debugging and testing, we found that this function has problems in wm5.0 and wm6.0. The data formats read from GPS in the 5.0 S and 6.0 s are different, for details, see the comments in the Code section above!
This function must be rewritten. First, you must determine whether the device uses Windows Mobile 5.0 or Windows Mobile 6.0. environment. osversion. the main version of version and the version number can be used to obtain the previous version of the current device. I searched for msdn and didn't see official instructions on how to identify Windows Mobile 5.0 and wm6.0 through the version number, some online users are certain to say
"I believe wm5 is 5.01 and wm6 is." (for details, see 《Detect what version of Windows Mobile Device is runningHttp://social.msdn.microsoft.com/Forums/zh-HK/netfxcompact/thread/8079e32f-b058-4ae7-b334-73eb3f51967e), after testing, wm6 is indeed identified by the minor version number, see the above Code.