예제 #1
0
        public MainForm()
        {
            InitializeComponent();

            m_Gps = new NmeaGps();
            m_Gps.PositionReceived += new NmeaGps.PositionReceivedDelegate(m_Gps_PositionReceived);

            m_Logger         = new DataLogger("GpsLog.txt", m_Gps);
            m_Logger.Logging = true;
        }
예제 #2
0
        public DataLogger(string filename, NmeaGps gps)
        {
            m_Filename = filename;
            m_Gps      = gps;

            // Write Header line
            WriteLine(string.Format("# GPS Logger started at {0}", DateTime.Now.ToString()));
            WriteLine("");
            WriteLine("Timestamp, Lat, Long, Speed, Bearing");

            // Listen for Frame Received
            m_Gps.PositionReceived += new NmeaGps.PositionReceivedDelegate(m_Gps_PositionReceived);
        }
예제 #3
0
파일: Program.cs 프로젝트: Keyhad/raylia
        public static void Main()
        {
#if SD_ENABLED
            // If your Netduino can't execute the next line of code, make sure you got at least firmware 4.1.1 beta 1
            // See also: http://forums.netduino.com/index.php?/topic/1592-netduino-firmware-v411-beta-1/
            StorageDevice.MountSD("SD", SPI_Devices.SPI1, Pins.GPIO_PIN_D10);

            // Determines the filename
            string filename = "";
            int    index    = 0;
            do
            {
                filename = @"\SD\LOGGER" + Tools.ZeroFill(index, 2) + ".CSV";
                ++index;
            }while (File.Exists(filename));

            // Starts writing to the file
            FileStream   stream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write);
            StreamWriter writer = new StreamWriter(stream);

            // Writes file headers
            writer.WriteLine("ticks,datetime,fix,latitude,longitude,altitude,satellites,kmh");
#endif

            // The GPS unit is connected to COM2
            NmeaGps gps = new NmeaGps("COM2");

            // Lets power on the GPS unit (active: LOW)
            OutputPort gps_enable = new OutputPort(Pins.GPIO_PIN_D4, false);

            // LEDs are connected to pins 5 and 6
            OutputPort led1 = new OutputPort(Pins.GPIO_PIN_D5, false);
            OutputPort led2 = new OutputPort(Pins.GPIO_PIN_D6, false);

            // Starts the GPS unit
            gps.Start();

            // Keeps on looping
            while (true)
            {
                // LED1 status ON
                led1.Write(true);

                // Builds the output
                string output = "";
                output += DateTime.Now.Ticks.ToString() + ", ";
                output += gps.GPSTime.ToString() + ", ";
                if (!gps.Fix)
                {
                    output += "0, 0, 0, 0, 0, 0";
                }
                else
                {
                    output += "1, ";
                    output += gps.Latitude.ToString() + ", ";
                    output += gps.Longitude.ToString() + ", ";
                    output += gps.Altitude.ToString() + ", ";
                    output += gps.Satellites.ToString() + ", ";
                    output += gps.Kmh.ToString();
                }

                // Prints the output to the debugger
                Debug.Print(output);
#if SD_ENABLED
                // Writes the output to the SD buffer
                writer.WriteLine(output);
#endif

                // LED1 status OFF, LED1 status ON
                led1.Write(false);
                led2.Write(true);

#if SD_ENABLED
                // Flushes the buffers to the SD card
                writer.Flush();
                stream.Flush();
#endif

                // LED2 status OFF
                led2.Write(false);

                // Sleeps for a second
                Thread.Sleep(1000);
            }
        }