Communicating with Arduino board with Visual Express C++

I've developed an application for the Arduino (Uno). It's a rather simple application which generates some timed digital outputs (after being triggered) based on timing parameters (delay and pulse width) stored in an array. Now, I would like to be able to communicate with the Arduino board via the serial port from a Microsoft Visual Express C++ program running on a host laptop computer.

The host program would generate the timing values as a fixed number of bytes, and write them to the Arduino board. The host would than wait for a single byte return message indicating that timing parameters should be recalculated and resent. This would repeat until the host program is terminated.

Do I need interface code to communicate between my C++ code and the serial port (which is installed on my laptop as COM6), or can the serial port be treated a generic port? Can anyone give me some guidance on this? Thanks.

If you are not fluent in using C++ to develop WIndows applications, might I suggest that you scrap the C++ application and use C#, instead. Writing to and reading from the serial port in C# is trivial. I have a sample that I could send you that connects to the Arduino and exchanges information using one thread, and shows that information in the UI thread. Once you set up the structure of the application (dual threads with delegates), extending it is easy.

Thanks PaulS for responding. I have just basic expertise in C++. However, I'd like to see your C# sample. If C# is a better approach for this kind of stuff, I'm willing to switch to it.

Send me a PM with an e-mail address, and I'll send you the code.

I realize this falls in the category of a dumb question, but how do you send a PM?
Thanks

I realize this falls in the category of a dumb question, but how do you send a PM?

Not a dump question at all. Click on the name of the person you want the send a PM to. On the left side of the page that comes up, near the bottom is a link that says something like "Send this person a private message".

Of course, that isn't working right now. Something done over the weekend hosed the PM system.

Send an e-mail to Paul at shirron.net.

@PaulS

I am also interrested in sending via serial port in C#. ( I guess I need a C# IDE ). It look like you do not recommend C++. I don't mind learning C#. I would like also a sample using ports in C#.

I would like also a sample using ports in C#.

I need to know where to send it.

Here's an example of accessing a serial port in C#. As you can see, it's pretty trivial. Once the port is opened, there are various methods to read/write and so on.

            SerialPort _serialPort = new SerialPort("COM8", 9600, Parity.None, 8);
            _serialPort.Handshake = Handshake.None;

            try
            {
                _serialPort.Open();
            }
            catch (Exception e)
            {
                Console.WriteLine("Open failed: " + e);
                return;
            }

Thank PeterH.

@PaulS.

I will e-mail my e-mail.