Skip to content

DDD North 2014

October 21, 2014

Big thanks to everyone who came to the “The Internet of Things ,Thought about it? Now try it.” talk at DDD North 2014, both Robert and I hope you all found it worthwhile.

Robert has written a nice summary of the links from the slide stack to help get you started with Windows On Devices.

The LCD demo code is available on github. The solution contains the demos I didn’t get to do, as always too much content too little timešŸ˜¦

During the talk someone asked whether or not the Intel Galileo has a real time clock (RTC). The Intel Galileo does have an on-board RTC which can be connected to a coin cell battery (e.g. CR2032) via the header pins shown below:

Intel Galileo RTC battery

The Intel Quark Datasheet, section 21.10 discusses the RTC. At this point it isn’t particularly clear as to whether this is/would be accessible via the version of Windows installed on the Intel Galileo. A more straightforward solution would be to use an external RTC such as a DS1307.

Displaying Intel Galileo IP address on a 16×2 LCD

September 26, 2014

I’ve had problems with Galileo Watcher showing Galileo boards on Windows 8.1. It works fine on Windows 7 and as far as I am aware Windows Firewall is configured correctly. I was also a little inspired by this question on stackoverflow, I’ve copied the title of the question for this blog post. The nub of the question is this…

“What’s the best way do get and show the Galileo IP address on the display instead of “Hello!” message?”

I’ve used the 16×2 LCD with netduino projects and decided to have a go. The only answer to theĀ  question suggested using the Windows APIs to get the IP address in string form and then use lcd.print to print the string to the LCD. I thought I would add a bit more value and also print the computer name to the LCD.

I decided to split the problem into three steps:

  • Write a C++ console app to get the IP address (and other network adapter properties)
  • Get the LCD sample app (http://ms-iot.github.io/content/16x2LCD.htm) working
  • Merge the two projects and display the Galileo IP address on a 16×2 LCD

Step 1 – Writing a console app to get the IP address:
The GetAdaptersInfo page on MSDN gives a good example of a suitable console application. The application worked fine on my laptop. The Galileo runs a modified version of Windows with aĀ subset of Win32 so I copied the console application to the Galileo and ran it successfully:

GetIPAddress

I now had code capable of retrieving the IP address and Computer Name.

Step 2 – Get the LCD sample app working:
I followed the instructions on setting up the 16 x 2 LCD from the sample applications on github. Unfortunately the project would not build. As a quick fix I modified the include files in the local package:

      • Add #ifndef directive to Print.h:
      • Remove the inheritance from the Print class in Stream.h

Step 3 – Merge the two projects
This was pretty straightforward, the only change I made between the console app and the Galileo project was changing from GetComputerName to GetComputerNameA to print the computer name to the LCD. The code snippet below runs in setup:

	lcd.begin(16, 2); // columns and rows, LCD unit (it calls clear at the end of begin)
	lcd.setCursor(0, 0);

	DWORD len = 16;
	char cName[16];

	GetComputerNameA(cName, &len);

	lcd.print(cName);
	
	PIP_ADAPTER_INFO	pAdapterInfo = NULL;
	PIP_ADAPTER_INFO	pAdapter = NULL;
	ULONG				ulOutBufLen = sizeof(IP_ADAPTER_INFO);
	DWORD				dwRetVal = 0;

	pAdapterInfo = (IP_ADAPTER_INFO *)MALLOC(sizeof(IP_ADAPTER_INFO));
	if (pAdapterInfo == NULL) {
		printf("Error allocating memory needed to call GetAdaptersinfo\n");
	}

	if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) {
		FREE(pAdapterInfo);
		pAdapterInfo = (IP_ADAPTER_INFO *)MALLOC(ulOutBufLen);
		if (pAdapterInfo == NULL) {
			printf("Error allocating memory needed to call GetAdaptersinfo\n");
		}
	}

	if ((dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen)) == NO_ERROR) {
		pAdapter = pAdapterInfo;
		lcd.setCursor(0, 1);
		lcd.print(pAdapter->IpAddressList.IpAddress.String);
	}

	if (pAdapterInfo)
		FREE(pAdapterInfo);

Computer name and IP address on a 16×2 LCD display…
16x2lcd

I’ll tidy up the source code and update the blog post shortly…

SQLite: SQL error or missing database – foreign key violation

January 16, 2014
tags:

When using SQLite “SQL error or missing database” is a very generic error that doesn’t help identify the root cause. The error usually occurs when inserting data where the SQL and/or data is incorrect. The root cause in this case was a foreign key definition that referred to a table that did not exist. I had created a foreign key relationship between two tables e.g A and B as shown below:

CREATE TABLE [A] (
[Id] UNIQUEIDENTIFIER NOT NULL PRIMARY KEY,
[Name] TEXT NOT NULL
)

CREATE TABLE [B] (
[Id] UNIQUEIDENTIFIER NOT NULL PRIMARY KEY,
[FkId] UNIQUEIDENTIFIER NOT NULL,
[Data1] REAL NULL,
[Data2] REAL NULL,
FOREIGN KEY(FkId) REFERENCES C(Id)
)

The foreign key for table B was referencing a table that didn’t exist, called C. When I tried to insert data into table B I received the generic error “SQL error or missing database”. When written as above it is easy to spot the error. Unfortunately in reality the difference between the correct table name and the incorrect table name was quite subtle and it took me some time to spot my mistake.

(Note – SQLite allows you to legitimately create a table with an invalid foreign key relationship: “The parent key definitions of foreign key constraints are not checked when a table is created. There is nothing stopping the user from creating a foreign key definition that refers to a parent table that does not exist, or to parent key columns that do not exist or are not collectively bound by a PRIMARY KEY or UNIQUE constraint.”)

The Joy of Wires: an introduction to Netduino, .NET Micro Framework and the Internet of Things (DDDDundee)

November 26, 2013
tags:

Thanks to everyone who came to my session at DDDDundee this year, hopefully you got enough to get started with Netduino.

Link to presentation is here… The Joy Of Wires (DDD Dundee).

Since presenting at DDDNorth I’ve noticed a couple of general books that have been published dealing with the Internet of Things – The Silent Intelligence and Designing the Internet of Things. Sadly Designing the Internet of Things doesn’t mention either Netduino or Gadgeteer, whether as an oversight or a deliberate snub is hard to tell. However both are well worth reading.

The Joy of Wires: an introduction to Netduino, .NET Micro Framework and the Internet of Things (DDDNorth)

October 14, 2013

Thanks to everyone who came to my session at DDDNorth this year. I was quite ambitious in the breadth of what I hoped to cover and as always too much material too little time.

Link to presentation is here… The Joy Of Wires.

The “Exec” task needs a command to execute

July 20, 2012

I was trying to build a Visual Studio project and instead of a successful build I received the following error:

The “Exec” task needs a command to execute.

I was stumped until I remembered that I’d recently removed the post build action. I’d left a new line which msbuild was trying to execute (obviously unsuccessfully). Once the new line was gone the build ran successfully.

Could not load type ‘Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy’ from assembly ‘Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’

June 14, 2012

I created a console application to automate the creation of SharePoint 2010 Search Managed Properties for a project I’m working on. I started the application from Visual Studio and received the following error:

TypeLoadException was unhandled

Could not load type ‘Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy’ from assembly ‘Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’

As usual I’d forgotten to change the platform target from x86 to x64…