Ejemplo n.º 1
0
        private void SerialPort_MessageReceived(object sender, SerialMessageData e)
        {
            Console.WriteLine("Message received.");

            Console.WriteLine($"{e.GetMessageString(Encoding.UTF8)}");
            nmeaProcessor.ProcessNmeaMessage(e.GetMessageString(Encoding.UTF8));
        }
Ejemplo n.º 2
0
        private void SerialPort_MessageReceived(object sender, SerialMessageData e)
        {
            string msg = (e.GetMessageString(Encoding.ASCII));

            Console.WriteLine($"Message arrived:{msg}");

            nmeaProcessor?.ProcessNmeaMessage(msg);
        }
Ejemplo n.º 3
0
        private void SerialPort_MessageReceived(object sender, SerialMessageData e)
        {
            string message = e.GetMessageString(Encoding.UTF8).Trim();

            string response = "";

            switch (message)
            {
            case FORWARD:
                this.Forward();
                response = "Going Forward\r\n";
                break;

            case BACK:
                this.Back();
                response = "Going Backward\r\n";
                break;

            case RIGHT:
                this.Right();
                response = "Turning right\r\n";
                break;

            case LEFT:
                this.Left();
                response = "Turning left\r\n";
                break;

            case STOP:
                this.Stop();
                response = "Stopping\r\n";
                break;

            default:
                response = $"Unrecognized '{message}'\r\n";
                Console.WriteLine($"Message not recognized: '{message}'");
                break;
            }

            if (!string.IsNullOrEmpty(response))
            {
                this.serialPort.Write(Encoding.UTF8.GetBytes(response));
            }
        }
 private void SerialPort_MessageReceived(object sender, SerialMessageData e)
 {
     Console.WriteLine($"Msg recvd: {e.GetMessageString(Encoding.ASCII)}\n");
 }