private static string UID = "XYZ"; // Change XYZ to the UID of your GPS Bricklet

    #endregion Fields

    #region Methods

    // Callback function for coordinates callback
    static void CoordinatesCB(BrickletGPS sender, long latitude, char ns, long longitude,
	                          char ew, int pdop, int hdop, int vdop, int epe)
    {
        Console.WriteLine("Latitude: " + latitude/1000000.0 + "° " + ns);
        Console.WriteLine("Longitude: " + longitude/1000000.0 + "° " + ew);
        Console.WriteLine("");
    }
Beispiel #2
0
    private static string UID  = "ABC";    // Change to your UID

    // Callback function for coordinates callback
    static void CoordinatesCB(BrickletGPS sender,
                              long latitude, char ns, long longitude, char ew,
                              int pdop, int hdop, int vdop, int epe)
    {
        System.Console.WriteLine("Latitude: " + latitude / 1000000.0 + "° " + ns);
        System.Console.WriteLine("Longitude: " + longitude / 1000000.0 + "° " + ew);
    }
    static void Main()
    {
        IPConnection ipcon = new IPConnection(); // Create IP connection
        BrickletGPS gps = new BrickletGPS(UID, ipcon); // Create device object

        ipcon.Connect(HOST, PORT); // Connect to brickd
        // Don't use device before ipcon is connected

        // Register coordinates callback to function CoordinatesCB
        gps.Coordinates += CoordinatesCB;

        // Set period for coordinates callback to 1s (1000ms)
        // Note: The coordinates callback is only called every second
        //       if the coordinates has changed since the last call!
        gps.SetCoordinatesCallbackPeriod(1000);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
    static void Main()
    {
        IPConnection ipcon = new IPConnection();          // Create IP connection
        BrickletGPS  gps   = new BrickletGPS(UID, ipcon); // Create device object

        ipcon.Connect(HOST, PORT);                        // Connect to brickd
        // Don't use device before ipcon is connected

        // Register coordinates callback to function CoordinatesCB
        gps.CoordinatesCallback += CoordinatesCB;

        // Set period for coordinates callback to 1s (1000ms)
        // Note: The coordinates callback is only called every second
        //       if the coordinates has changed since the last call!
        gps.SetCoordinatesCallbackPeriod(1000);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
    private static string UID = "XYZ"; // Change XYZ to the UID of your GPS Bricklet

    #endregion Fields

    #region Methods

    static void Main()
    {
        IPConnection ipcon = new IPConnection(); // Create IP connection
        BrickletGPS gps = new BrickletGPS(UID, ipcon); // Create device object

        ipcon.Connect(HOST, PORT); // Connect to brickd
        // Don't use device before ipcon is connected

        // Get current coordinates
        long latitude; char ns; long longitude; char ew; int pdop, hdop, vdop, epe;
        gps.GetCoordinates(out latitude, out ns, out longitude, out ew, out pdop,
                           out hdop, out vdop, out epe);

        Console.WriteLine("Latitude: " + latitude/1000000.0 + "° " + ns);
        Console.WriteLine("Longitude: " + longitude/1000000.0 + "° " + ew);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
    private static string UID  = "XYZ";    // Change XYZ to the UID of your GPS Bricklet

    static void Main()
    {
        IPConnection ipcon = new IPConnection();          // Create IP connection
        BrickletGPS  gps   = new BrickletGPS(UID, ipcon); // Create device object

        ipcon.Connect(HOST, PORT);                        // Connect to brickd
        // Don't use device before ipcon is connected

        // Get current coordinates
        long latitude, longitude; char ns, ew; int pdop, hdop, vdop, epe;

        gps.GetCoordinates(out latitude, out ns, out longitude, out ew, out pdop,
                           out hdop, out vdop, out epe);

        Console.WriteLine("Latitude: " + latitude / 1000000.0 + " °");
        Console.WriteLine("N/S: " + ns);
        Console.WriteLine("Longitude: " + longitude / 1000000.0 + " °");
        Console.WriteLine("E/W: " + ew);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }