Example #1
0
        public NMEASerialPort(SerialPortSettings portSettings)
            : base()
        {
            #region serialPort initialization

            if (portSettings == null)
            {
                throw new ArgumentNullException("portSettings");
            }

            PortSettings = portSettings;

            serialPort = new SerialPort(
                PortSettings.PortName,
                (int)PortSettings.PortBaudRate,
                PortSettings.PortParity,
                (int)PortSettings.PortDataBits,
                PortSettings.PortStopBits);

            serialPort.Handshake    = portSettings.PortHandshake;
            serialPort.Encoding     = Encoding.ASCII;
            serialPort.WriteTimeout = 1000;
            serialPort.ReadTimeout  = 1000;

            serialPort.ErrorReceived += new SerialErrorReceivedEventHandler(serialPort_ErrorReceived);
            serialPort.DataReceived  += new SerialDataReceivedEventHandler(serialPort_DataReceived);

            #endregion
        }
Example #2
0
        public RedNodePort(string portName)
        {
            portSettings = new SerialPortSettings(portName, BaudRate.baudRate9600, Parity.None, DataBits.dataBits8, StopBits.One, Handshake.None);
            //portSettings = new SerialPortSettings(portName, BaudRate.baudRate115200, Parity.None, DataBits.dataBits8, StopBits.One, Handshake.None);

            #region timers

            timer        = new PrecisionTimer();
            timer.Mode   = Mode.Periodic;
            timer.Period = 2000;
            timer.Tick  += new EventHandler(timer_Tick);

            #endregion

            #region Handlers

            port = new NMEASerialPort(portSettings);
            port.NewNMEAMessage += new EventHandler <NewNMEAMessageEventArgs>(port_NewNMEAMessage);
            port.PortError      += new EventHandler <SerialErrorReceivedEventArgs>(port_PortError);

            #endregion

            #region NMEA

            NMEAInit();

            #endregion

            #region other

            RedBASE_1 = new RedBASEState();
            RedBASE_2 = new RedBASEState();
            RedBASE_3 = new RedBASEState();
            RedBASE_4 = new RedBASEState();

            #endregion
        }
Example #3
0
        public GNSSReceiverWrapper(SerialPortSettings portSettings)
        {
            #region port initialization

            port = new NMEASerialPort(portSettings);

            port.PortError      += new EventHandler <System.IO.Ports.SerialErrorReceivedEventArgs>(port_PortError);
            port.NewNMEAMessage += new EventHandler <NewNMEAMessageEventArgs>(port_NewMessage);

            #endregion

            #region parsers initialization

            cmdProcessor = new Dictionary <SentenceIdentifiers, ProcessCommandDelegate>()
            {
                { UCNLNMEA.SentenceIdentifiers.GGA, new ProcessCommandDelegate(ProcessGGA) },
                { UCNLNMEA.SentenceIdentifiers.GSV, new ProcessCommandDelegate(ProcessGSV) },
                { UCNLNMEA.SentenceIdentifiers.GLL, new ProcessCommandDelegate(ProcessGLL) },
                { UCNLNMEA.SentenceIdentifiers.RMC, new ProcessCommandDelegate(ProcessRMC) },
                { UCNLNMEA.SentenceIdentifiers.VTG, new ProcessCommandDelegate(ProcessVTG) }
            };

            #endregion
        }