Monday, May 2, 2016

How do you create a Arduino Project in Visual Studio 2015 Community?

Arduino has a number of hardware products (microcontrollers. SoC, etc) that can be used for various end uses including the Internet Of Things (IoT).

Visual Studio can be used to create Arduino projects wherein the application created using the Visual Studio can be used to control like in robotics, garage openers, light dimmers, etc. to mention a few.

The more recent Visual Studio editions that are free and well suited for Arduino projects are the two Community Editions, Visual Studio 2013 Community and Visual Studio 2015 Community.

The first thing you need is to install Visual Studio (either 2013 or 2015). If you want to know details for 'how' follow these two posts.

This post considers the Visual Studio 2015 Community(VS2015C).
A default install of VS2015C does not have the 'hooks' to create a Arduino Project. You will not find it in the 'New Project' templates.

You need to install the Arduino Extension for Visual Studio 2015. You can get an idea how to do it by following this Swaytorial:

Once you install this you can create an Arduino Project from File | New Arduino Project.


Click and you have created a project. It is that easy.


You just need to give a name to the project and the template is ready.
I have a few projects created with the VS2013C on my blog which you may want to review.

Analog Serial Readout

What is a Common Table Expression (CTE) in SQL Server?

Microsoft documentation defines Common Table Expression thus,

"A common table expression (CTE) can be thought of as a temporary result set that is defined within the execution scope of a single SELECT, INSERT, UPDATE, DELETE, or CREATE VIEW statement. A CTE is similar to a derived table in that it is not stored as an object and lasts only for the duration of the query. Unlike a derived table, a CTE can be self-referencing and can be referenced multiple times in the same query.

It is unlike a temporary table (persisted) during a connection or a view persisted in the database. CTE is only in memory.

We will consider CTE's many use case scenarios in later posts and the objective of this post is to give a simple example using the Northwind database.

A CTE should have the following:
  • CTE with a CTE Expression name
  • An Optional Column list
  • A query defining the CTE

After a CTE is defined it can be referenced like a table or view and you can do all of the following statements:

  • Select
  • Insert
  • Update
  • Delete
It can also be used in defining a view by providing the columns.

Now let me define CTE using the Employees table in Northwind. The example is just to show the syntax as the result can be obtained from a single query without using CTE.

USE Northwind
---define the common table expression
WITH NEmp_CTE (FirstName,LastName,CITY)  /*Name: Nemp_CTE, Column List:FirstName, LastName,City*/
---define the CTE query
(SELECT FirstName,LastName,City
from Employees
where City in ('Tacoma','London')
---Use it in a Select Query
SELECT LastName,FirstName,CITY
From NEmp_CTE
where LastName <>'Buchanan'

The response to this query is:

Note: The response such as the above does not really need a Common Table Expression but the point was to show the construction of the Syntax used for CTE. In fact, it is to make complex queries more readable.

Friday, April 29, 2016

How do you create a Virtual Switch in Windows 10?

You need a virtual switch to connect to the Network via the Network Card. You follow the indicated procedure to create one.

Before you create a virtual switch you need to enable Hyper-V built into Windows 10. Follow this post to enable Hyper-V on Windows 10.

After enabling Hyper-V follow this procedure to create the virtual switch.

Thursday, April 28, 2016

What is STUN and why do I need a STUN Server?

Skype is quite well known. You can call up someone using your web browser to speak to him if he is also on the Internet or even his cell phone if he has a Skype UserId / Password or Skype account. This is made possible by VOIP (voice over Internet) using the VoIP protocol.

Now what is STUN?

STUN is Session Traversal of User Datagram Protocol (UDP) through Network Address Translators(NAT).

If you are using the IP Phone from behind the firewall (where NAT becomes important) then STUN allows you setup Phone calls to aVoIP Provider hosted outside your local network (typical example is a home network consisting of computers connected to a router).

While your voice calls go through the router to the STUN Server, the STUN server can connect to your local machine behind the firewall.

Read more here. The above image was from this link.

How do you resize multiple images simultaneously?

Sometimes you are faced with resizing a bunch of images:

  • Reduce the size of images to a level accepted by your application (perhaps the server does not accept anything more than a given size) or you can only upload a certain file size
  • You want to save space (smartphones can capture HD images with very big files sizes).  

Application like Photoshop can do this, but you can use Photo Gallery on your Windows 10 machine to do the same.

Photo Gallery is a desktop app that you can download from the Windows Store.


In my Desktop I have a folder with 64 jpg items with item sizes ranging from 2780 KB to 5072 KB with a total folder size of 234 MB


I bring up and choose all images in this folder in Photo Gallery as shown.


I click EDIT and Resize as shown.


The Photo Gallery Resize dialog is displayed where you can choose the size from the drop-down list.


I choose size 640 and browse and save it to my presently empty folder named Larger_resized.

I then click Resize and save button. In couple of seconds it is done.
The total file size is now 10.3 MB


The individual JPGs were from 177Kb to 201KB

The Photo Gallery did an excellent job!

Wednesday, April 27, 2016

Does ping use IPv4 or IPv6?

In Windows 10 machine when I ping a web site such as, I get the response as shown:

Pinging [2600:1406:1f:386::2768] with 32 bytes of data:
Reply from 2600:1406:1f:386::2768: time=72ms
Reply from 2600:1406:1f:386::2768: time=64ms
Reply from 2600:1406:1f:386::2768: time=64ms
Reply from 2600:1406:1f:386::2768: time=65ms

Ping statistics for 2600:1406:1f:386::2768:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 64ms, Maximum = 72ms, Average = 66ms

The default appears to be IPv6

However, if I need to ping the IPv4 then I can ping as shown.
C:\Users\Jayaram>ping -4
Pinging [] with 32 bytes of data:
Reply from bytes=32 time=84ms TTL=55
Reply from bytes=32 time=89ms TTL=55
Reply from bytes=32 time=64ms TTL=55
Reply from bytes=32 time=80ms TTL=55

Ping statistics for
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 64ms, Maximum = 89ms, Average = 79ms

Monday, April 25, 2016

How do you install Hyper-V on Windows 10?

Actually Hyper-V is installed on Windows 10 and you need to activate it.

Before you configure a virtual machine, you must enable the Hyper-V role. You can do it in the Control Panel as shown below; using a Windows Powershell Commandlet; or DISM. Only the Control Panel method is described.

Step 1:
You do so by following this: Control Panel > Programs > Programs and Features

Step 2:
Click on Turn Windows Features on or off to turn on.
Windows Features window gets displayed.


Step 3:
Place check mark for all items of Hyper-V as shown.


Step 4: Click OK and reboot the computer
You are done.