Access GPS data from .Net Winform application

Does anyone have any experience programmatically returning lat / long from a GPS attached to a mobile PC? The team I'm working with now is considering hardware options - as a programmer who will eventually have to live with what was chosen. I was wondering if anyone has any experience writing .Net programs that interact with GPS? Any recommendations on hardware and / or programming would be appreciated.

As I imagine it, my application will need to ask GPS for the current lat / long, perhaps every 10-20 seconds.

+3
source share
3 answers

I wrote such an application before.

As Henk said, you are listening on a COM port. Create a component that reads a COM stream, for example, 1024 buffers. which will be enough to contain at least 1 complete NMEA sentence. From there, read the entry until you find the beginning of the sentence and analyze it. If for some reason you do not have a full sentence, read in another buffer, add and continue / try again.

+1
source

If you want to be dependent on Windows 7, there is a Location API that handles NMEA decoding for you.

+1
source

Gps Windows CE PC Windows, GPS . .net, .Net- API.

public class GpsHardware
{
    private const string gpsLibraryName = "gpsapi.dll";
    private const string coreLibraryName = "coredll.dll";

    [DllImport(GpsHardware.coreLibraryName, SetLastError = false)]
    [return: MarshalAs(UnmanagedType.Bool)]
    private static extern bool EventModify(IntPtr hEvent, uint function);

    [DllImport(GpsHardware.gpsLibraryName, SetLastError = true, CharSet = CharSet.Unicode)]
    private static extern IntPtr GPSOpenDevice(IntPtr hNewLocationData, IntPtr hDeviceStateChange, string szDeviceName, uint dwFlags);

    [DllImport(GpsHardware.gpsLibraryName, SetLastError = true)]
    private static extern uint GPSCloseDevice(IntPtr hGPSDevice);

    [DllImport(GpsHardware.gpsLibraryName, SetLastError = true)]
    private static extern uint GPSGetPosition(IntPtr hGPSDevice, IntPtr pGPSPosition, uint dwMaximumAge, uint dwFlags);

    [DllImport(GpsHardware.gpsLibraryName, SetLastError = true)]
    private static extern uint GPSGetDeviceState(IntPtr pGPSDevice);

    ...
}

, :)

+1
source

Source: https://habr.com/ru/post/1723167/


All Articles