Serial communication between MBED and GUI(visual studio C#)

11 Feb 2015

Hallo,

Is it possible to transfer data from an GUI in visual studio to the mbed(LPC 1768) or is it impossible if you only use USB communication?

  1. include "mbed.h"

Serial pc(USBTX,USBRX);tx, rx

string size_cmd ="";

int main()

{

while(1)

{

if (pc.readable()) {

size_cmd=pc.getc();

pc.printf("data received");

/* Do some operations

  • /

} } }

Thx Titi

11 Feb 2015

Assuming C# for GUI, see https://msdn.microsoft.com/en-us/library/system.io.ports.serialport(v=vs.110).aspx Use the serialport class. Make sure you open COMx: where x is the mbed port and that the baudrate is correct (same as mbed).

using System;
using System.Collections.Generic;
using System.Text;
using System.IO.Ports;
namespace Hello_CS_Serial_World
{
    class Program
    {
        static void Main(string[] args)
        {
        SerialPort _serialPort;
        // Create a new SerialPort object with desired settings.
        _serialPort = new SerialPort();
        //Defaults to ("COM1", 9600, Parity.None, 8, StopBits.One)    
        _serialPort.Open();
        _serialPort.WriteLine("Hello CS Serial World");
        _serialPort.Close();
        }
    }
}