Visual C Serial Portanimationsupport

Posted on

Notice

Some of the downloads that are mentioned in this article are currently available on My.VisualStudio.com. Make sure to log in by using a Visual Studio Subscription account so that you can access the download links.

Use this method for reading characters from the serial port. If it is necessary to switch between reading text and reading binary data from the stream, select a protocol that carefully defines the boundary between text and binary data, such as manually reading bytes and decoding the data. Windows Users: The native DLL has been compiled with Visual Studio 2015, so you needto install Visual C Redistributable for Visual Studio 2015! Don't forget to install it, else it will not work. Supports listing, reading and writing to serial ports; Configure port (baudrate, parity, stop bits, data bits). I have my code that reads and writes to a serial port written in MFC. The programs works well but is a bit slow as there are many operations occuring (Read and writing). I have a timer that carries on the operations on the serial port. The timer is given below: LoopTimer = SetTimer(1,50,0); The serial port transmission information is as follows.

Serial

If you are asked for credentials, use your existing Visual Studio subscription account or create a free account by selecting 'Create a new Microsoft account.'

Summary

This article lists the download links for the latest versions of Microsoft Visual C++.

Visual Studio 2015, 2017 and 2019

Download the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019. The following updates are the latest supported Visual C++ redistributable packages for Visual Studio 2015, 2017 and 2019. Included is a baseline version of the Universal C Runtime see MSDN for details.

Note Visual C++ 2015, 2017 and 2019 all share the same redistributable files.

For example, installing the Visual C++ 2019 redistributable will affect programs built with Visual C++ 2015 and 2017 also. However, installing the Visual C++ 2015 redistributable will not replace the newer versions of the files installed by the Visual C++ 2017 and 2019 redistributables.

This is different from all previous Visual C++ versions, as they each had their own distinct runtime files, not shared with other versions.

Visual Studio 2013 (VC++ 12.0)

  • Download the Microsoft Visual C++ Redistributable Packages for Visual Studio 2013. This is the latest supported Visual C++ redistributable package for Visual Studio 2013.

  • Download Multibyte MFC Library for Visual Studio 2013. This add-on for Visual Studio 2013 contains the multibyte character set (MBCS) version of the Microsoft Foundation Class (MFC) Library.

  • Download Visual C++ 2013 Runtime for Sideloaded Windows 8.1 apps.

For more information, see C++ Runtime for Sideloaded Windows 8.1 apps on the VC++ Team Blog.

Visual Studio 2012 (VC++ 11.0)

Download the Microsoft Visual C++ Redistributable Packages for Visual Studio 2012 Update 4. This is the latest supported Visual C++ redistributable package for Visual Studio 2012.

Visual Studio 2010 (VC++ 10.0) SP1

  • Download the Visual Studio 2010 Service Pack 1 (Installer). This is the latest supported Visual C++ service pack for Visual Studio 2010.

    Note: This web installer requires an internet connection. This installer downloads and installs Visual Studio 2010 Service Pack 1. It works for all editions of Visual Studio 2010 (Express, Professional, Premium, Ultimate, and Test Professional).

  • Download the Microsoft Visual C++ 2010 Service Pack 1 Redistributable Package MFC Security Update. This is the latest supported Visual C++ redistributable package update for Visual Studio 2010.

Visual Studio 2008 (VC++ 9.0) SP1

  • Visual Studio 2008 reached end of support on April 10, 2018. To aid the discovery of the latest downloads, the links are retained currently, but may be removed in the future.

  • Download the Visual Studio 2008 Service Pack 1 (Installer). This is the latest Visual C++ service pack for Visual Studio 2008. This service pack improved responsiveness, stability, and performance.
    Note This download installs Visual Studio 2008 Service Pack 1 and Microsoft .NET Framework 3.5 SP1.

  • Download the Microsoft Visual C++ 2008 Service Pack 1 Redistributable Package MFC Security Update. This is the latest Visual C++ redistributable package update for Visual Studio 2008.

Visual C++ Redistributable Packages

Visual C++ Redistributable Packages install runtime components of Visual C++ Libraries on a computer that does not have Visual C++ installed. The libraries are required to run applications that are developed by using the corresponding version of Visual C++.

For Visual Studio 2008

These packages install runtime components of C Runtime (CRT), Standard C++, ATL, MFC, OpenMP and MSDIA libraries. They are installed into the native assembly cache, also known as the WinSxS folder. They are installed on versions of Windows operating systems that support side-by-side assemblies, for libraries that support side-by-side deployment models (CRT, STL, ATL, MFC, OpenMP).

Microsoft Foundation Class Library Security Update

A security issue was identified. This issue causes a Microsoft Foundation Class Library application vulnerability in your Windows-based system that uses the Visual C++ Redist. The Microsoft Foundation Class Library Security Update packages in this article have the most current redistributable files for Visual Studio.

Visual

I just go my Arduino a couple of weeks ago and even though I haven’t had much chance to play with it one of the first things I wanted to do was send data to it from my computer. Am starting very simple, in this tutorial I will show you how to turn Arduino’s pin 13 light with C++

Why Visual C++

Before trying or even thinking about Microsoft’s .Net framework I was looking for open source solutions or native code, I came across great frameworks like openframeworks but the truth of the matter is that I could find a project that was as well documented and testes as Visual C++ was.

Another major set back was that the most popular solutions seemed to work with Linux only. Visual studio is also free and its IDE was specifically designed for the .Net framework so there is no better choice for me.

Step 1: Download and Install Visual Studio C++

Like I said, the IDE and the framework are free, so have at it.

Download the .Net Framework.

Download Visual Studio C++ 2010 Express Edition (free edition).

Step 2: Start a New C++ Console Project

Go to File->New->Project and choose console program as shown below. Name the project how ever you like.

Your Visual C++ Project Files

The only file you have to mess with is the file named the same way as your project but with the .cpp extension. I named my project “ArduinoComm”, so my file is “ArduinoComm.cpp”. Double click on that file to open it.

Empty C++ Arduino Project

Visual C Serial Portanimationsupport

How The Program Is Going to Work

Our program is going to work this way, it will ask the user to enter the serial port he wants to use and store the answer in a variable called portName. Then we will ask the person if they want to turn the light on or off, if they type on, the number 1 will be sent to the Arduino, 0 will be sent for off.

The program will contain a loop to ask the user if he wishes to continue or end the program.

We also need to set a baud rate, this is kinda like the frequency at which we will set the Arduino board to communicate. Add the following lines of code to your main function.

If you have used regular C++ only think of Console::WriteLine as cout and Console::ReadLine() as getline(cin,variable).

The SerialPort Class

The .Net framework has a class for you to play with your computer’s serial ports, this class is called SerialPort and it can be found under the namespace 'System::IO::Ports'. We will also use other methods under the System namespace so let’s use this one as well.

Instantiating the Port Class

The serial port object needs a port name and baud rate in its constructors, so add the following lines to your code. Our serial port object will be 'arduino'.

Port

Opening The Port

Port

Just like with text files the first thing you have do is open ports. Open is a method of the serial port class of which arduino is an object of.

The Loop

We will use a do while loop to run the loop the first time our program is run. Our answer string variable will store the answer for our two questions, 'Want to continue?' and 'on or off?'

Inside The Loop

Sending a string to your Arduino board is done by using the method WriteLine of your arduino object. Add the following code to your loop, I think it is self explanatory but leave me a comment if you got any questions.

The Full C++ Script

Serial Port Programming In C

Here is the full script for those who are too lazy to follow or just don’t give a damn about what I say. Please note that I added some exception handling to test for errors in typing and what not.

The Arduino Script

If you haven’t used Arduino’s serial class this is how it works. In your set up function you need to begin communication with your serial and set the baud rate the same value as we did in our C++ script (9600).

The next thing we do is check if the serial port is available, if it is we read the incoming data.

Not much can be said about the code above. We are using pin number 13 and setting it to HIGH if 1 was sent if 0 was sent we set it to LOW. We don’t do anything otherwise.

Test Your Program

Once your have uploaded the arduino script to your arduinio board head back to Visual Studio and press F5, the program should compile and you should see a console screen like the following.

Arduino Visual C++ Program

How To Get Your Port Name

The port name your Arduino is using starts with 'com' and is followed by a number, you can get it by going to your Arduino compiler. Under Tools > Serial Port.

My port name is COM4, and that is exactly what I have to type in the console so that the program continues to run.

This will not always be your port name however, it depends on which USB port your Arduino is connected in.

C# Serial Port Tutorial

Running Your Program Outside Of Visual Studio

C# Serial Port

You don’t have to be in Visual Studio to run your C++ program. If you look in your project files OUTSIDE of Visual Studio, in your debug folder you will find a file with the type 'Application' and the same name as your project. This is your program’s executable file. You can take this file anywhere and double click it run the program.

Arduino Executable (.exe)