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…

WSS Logging, SQL Authentication and GRANT VIEW SERVER STATE TO [FARM ACCOUNT]

April 10, 2012

The project I’m currently working on had the requirement to install SharePoint 2010 using SQL Mixed Mode authentication. Two Technet articles got me up and running: Install SharePoint 2010 with SQL Authentication and Installing SharePoint 2010 Farm using SQL Authentication & its limitations. I also configured usage and health data collection. I noticed that the application log was showing Event 5586 (unknown SQL exceptions). Using ULS Viewer it was easy to find the following line:

“Unknown SQL Exception 297 occurred. Additional error information from SQL Server is included below.  The user does not have permission to perform this action.”

Above this I could see the connection string and the command that the SQL account was trying to execute. The SQL command was trying to execute a data management view.

Looks like when you configure a farm using mixed mode authentication the SQL account is not automatically given GRANT VIEW SERVER STATE.

SPView.DefaultViewForContentType

February 24, 2012

I’ve been working on an Event Receiver which has the requirement to use custom folder content types in SharePoint 2007. I needed to show one view at the root folder and a different view in a custom content type folder. As ever the SharePoint object model is less than clear.

This post by Mirjam was really useful in understanding what to do to programmatically set a view to only the root folder, the key line is setting the SPView.ContentTypeId to 0x012001, which is the content type id for RootOfList as part of the base content type hierachy shown here.

I still needed the view to automatically change to the one I had created when a user browsed into a folder based on the custom folder content type. The key to doing this was to set the following two lines:

SPView.ContentTypeId – this needs to be set to the content type id of the content type in your list

SPView.DefaultViewForContentType – this needs to set to true

Retry of query machine ‘xxx’ has failed with error: Logon Failure: The target account name is incorrect.

February 16, 2012

SharePoint search was broken on a load balanced cluster and I spent far too long today trying to figure out what was causing the following issue in the application event log:

Retry of query machine ‘xxx’ has failed with error: Logon Failure: The target account name is incorrect.

Occasionally this error in the system event log, at the same point in time as the error above:

The kerberos client received a KRB_AP_ERR_MODIFIED error from the server host/xxx.  The target name used was cifs/xxx. This indicates that the password used to encrypt the kerberos service ticket is different than that on the target server. Commonly, this is due to identically named  machine accounts in the target realm (xxx), and the client realm.   Please contact your system administrator.

Like most other SharePoint errors life begins with a Google / Bing search. There are quite a number of posts with a variety of solutions, I was almost at the point of thinking that search was truly broken and needed rebuilt from scratch.

The key for me was the line in the application event log: The target account name is incorrect. I was pretty sure there wasn’t an identically named machine. I checked the DNS entry for the query server which had been changed to point at the VIP for the cluster and not the IP address of the query server.

Sometimes taking what you see at face value is all that is needed – IP address changed and search sprang back to life.