void Initialize() { Console.WriteLine("Initialize hardware..."); display = new Ssd1309(Device.CreateI2cBus()); Console.WriteLine("Display created"); graphics = new GraphicsLibrary(display); graphics.CurrentFont = new Font8x8(); Console.WriteLine("Graphics library created"); //COM4 - Pins D00 & D01 on the Meadow F7 port = Device.CreateSerialMessagePort( Device.SerialPortNames.Com4, suffixDelimiter: Encoding.ASCII.GetBytes("\r\n"), preserveDelimiter: true, 9600); Console.WriteLine("Serial port created"); port.MessageReceived += (object sender, SerialMessageData e) => { nmea.ProcessNmeaMessage(e.GetMessageString(Encoding.ASCII)); }; nmea = new NmeaSentenceProcessor(); var ggaParser = new GgaDecoder(); ggaParser.PositionReceived += GgaParser_OnPositionReceived; nmea.RegisterDecoder(ggaParser); // open serial port.Open(); }
protected void InitDecoders() { Console.WriteLine("Create NMEA"); nmeaProcessor = new NmeaSentenceProcessor(); Console.WriteLine("Add decoders"); // MTK var mtkDecoder = new MtkDecoder(); Console.WriteLine("Created MTK"); nmeaProcessor.RegisterDecoder(mtkDecoder); mtkDecoder.MessageReceived += (object sender, string message) => { Console.WriteLine($"MTK Message:{message}"); }; // GGA var ggaDecoder = new GgaDecoder(); Console.WriteLine("Created GGA"); nmeaProcessor.RegisterDecoder(ggaDecoder); ggaDecoder.PositionReceived += (object sender, GnssPositionInfo location) => { this.GgaReceived(this, location); }; // GLL var gllDecoder = new GllDecoder(); nmeaProcessor.RegisterDecoder(gllDecoder); gllDecoder.GeographicLatitudeLongitudeReceived += (object sender, GnssPositionInfo location) => { this.GllReceived(this, location); }; // GSA var gsaDecoder = new GsaDecoder(); nmeaProcessor.RegisterDecoder(gsaDecoder); gsaDecoder.ActiveSatellitesReceived += (object sender, ActiveSatellites activeSatellites) => { this.GsaReceived(this, activeSatellites); }; // RMC (recommended minimum) var rmcDecoder = new RmcDecoder(); nmeaProcessor.RegisterDecoder(rmcDecoder); rmcDecoder.PositionCourseAndTimeReceived += (object sender, GnssPositionInfo positionCourseAndTime) => { this.RmcReceived(this, positionCourseAndTime); }; // VTG (course made good) var vtgDecoder = new VtgDecoder(); nmeaProcessor.RegisterDecoder(vtgDecoder); vtgDecoder.CourseAndVelocityReceived += (object sender, CourseOverGround courseAndVelocity) => { this.VtgReceived(this, courseAndVelocity); }; // GSV (satellites in view) var gsvDecoder = new GsvDecoder(); nmeaProcessor.RegisterDecoder(gsvDecoder); gsvDecoder.SatellitesInViewReceived += (object sender, SatellitesInView satellites) => { this.GsvReceived(this, satellites); }; }
protected void InitDecoders() { Console.WriteLine("Create NMEA"); nmeaProcessor = new NmeaSentenceProcessor(); // verbose output nmeaProcessor.DebugMode = true; Console.WriteLine("Add decoders"); // GGA var ggaDecoder = new GgaDecoder(); Console.WriteLine("Created GGA"); nmeaProcessor.RegisterDecoder(ggaDecoder); ggaDecoder.PositionReceived += (object sender, GnssPositionInfo location) => { Console.WriteLine("*********************************************"); Console.WriteLine(location); Console.WriteLine("*********************************************"); }; // GLL var gllDecoder = new GllDecoder(); nmeaProcessor.RegisterDecoder(gllDecoder); gllDecoder.GeographicLatitudeLongitudeReceived += (object sender, GnssPositionInfo location) => { Console.WriteLine("*********************************************"); Console.WriteLine(location); Console.WriteLine("*********************************************"); }; // GSA var gsaDecoder = new GsaDecoder(); nmeaProcessor.RegisterDecoder(gsaDecoder); gsaDecoder.ActiveSatellitesReceived += (object sender, ActiveSatellites activeSatellites) => { Console.WriteLine("*********************************************"); Console.WriteLine(activeSatellites); Console.WriteLine("*********************************************"); }; // RMC (recommended minimum) var rmcDecoder = new RmcDecoder(); nmeaProcessor.RegisterDecoder(rmcDecoder); rmcDecoder.PositionCourseAndTimeReceived += (object sender, GnssPositionInfo positionCourseAndTime) => { Console.WriteLine("*********************************************"); Console.WriteLine(positionCourseAndTime); Console.WriteLine("*********************************************"); }; // VTG (course made good) var vtgDecoder = new VtgDecoder(); nmeaProcessor.RegisterDecoder(vtgDecoder); vtgDecoder.CourseAndVelocityReceived += (object sender, CourseOverGround courseAndVelocity) => { Console.WriteLine("*********************************************"); Console.WriteLine($"{courseAndVelocity}"); Console.WriteLine("*********************************************"); }; // GSV (satellites in view) var gsvDecoder = new GsvDecoder(); nmeaProcessor.RegisterDecoder(gsvDecoder); gsvDecoder.SatellitesInViewReceived += (object sender, SatellitesInView satellites) => { Console.WriteLine("*********************************************"); Console.WriteLine($"{satellites}"); Console.WriteLine("*********************************************"); }; }