May 122012
 

I started working on an iPad app just after Christmas and have today started the process of getting it into the Apple store. I’m not sure if Apple will approve it, since it breaks one of their cardinal rules. Applications may not include cross-compilers. My app is an Arduino simulator. The Arduino is a low-cost open source micro controller. The physical board is about 3×2 inches in size, has a 8 bit processor and 32 KB of usable program space. One of these costs about $60 here in NZ. It has a number of ports that can be connected to digital or analog devices.

This is what an Arduino looks like


The controller can be programmed using a cut down version of C++. I’ve set one of these up with a temperature and humidity sensor as well as an ethernet card. This setup updates a database with the current temperature, then I have an iPhone app that displays the current temperature.

My app includes some UI to draw an Arduino and a circuit board that can hold LEDs and wires to link the components and the Arduino model’s ports. I’ve written simple route tracking code that toggles the state of an LED when a wire is live. I’ve also written my own C compiler that takes a program just as you would write for the Arduino itself and I compile this to my own assembly language. I have a virtual machine that executes the assembly and sets the digital ports on the Arduino model to ‘on’ or ‘off’, then I track the wires and light up the LEds.

This is what the app looks like:


The question is, will Apple allow this app on the App Store? It has an embedded cross-compiler, but it’s all sandboxed, the C code that makes up the program can only blink the LEDs on the UI, though it would be interesting to allow the C code to call a web service.

BTW. Have already had suggestions that I port this to the Android platform. Probably won’t happen; writing a C compiler and VM in Java is a bit beyond me 😉

 Posted by at 4:00 pm
Apr 052011
 

I have an application that reads data from a JSON file and displays the locations for the records it’s reading in a map. Fairly standard fare and all works well. Well, it worked on an iPhone, but on an iPad the application would crash after loading a few hundred records. I thought there might be something wrong with the names of the locations that I was loading. These would be the titles for the annotations, so having established that a particular record was giving trouble I just disregarded it and moved on. Then I got a new data set and the problem went away. At least the problem with that record went away, but now a different record caused a problem, and again only on the iPad. I just buried my head in the sand. I’m not worried about the app running on an iPad so it’s not a major problem.

Except then I got a new iPhone, still an iPhone 4, so exactly the same model as the old one. And now the application crashes on the new iPhone just like it did on the iPad, but it doesn’t crash on the old iPhone. And now I am worried, because if it works on some iPhones and not on others that’s not a good thing. So I looked at the differences between the two iPhones. Aha! The new one runs iOS 4.3.1 and the old one runs 4.1. And the iPad runs 4.3.1 too, so that’s interesting.

But there has to be a root cause, because by ignoring some data records I could get the problem to stop happening. So this time I looked closer at the data and found the problem. The latitude and longitude are included in my data and these are a number of degrees. These range from -360 to +360 and have 5 or 6 decimal places. Except the bad records, which had been badly entered into the data file and had no decimal point, so they read as 3 million degrees or something.

Earlier versions of iOS would probably replace the bad values with zero, while 4.3 and later would crash. In fact the crash was very low down in the OS, it would make my app so it would not run again, I’d have to reboot the device.

I changed my app so it replaced these erroneous coordinates with zeroes and now my app runs perfectly. OK there are some annotations placed at the north pole, but that’s a data issue and nothing to do with my app. I just need to get the data cleaned up.

There are some lessons here: Never trust the data. Never ignore an error, and test for every type of hardware.

Mar 072011
 

This is probably an obvious one. but it’s possible to shorten your OpenID URL. Use your URL shortener of choice. Assuming you’re using TinyURL, type your OpenID, which might be something like http://myopenid.com/itsmereally and generate a TinyUrl for it (the TinyURL would look something like http://tinyurl.com/ABC123). When entering your OpenId in a web-site you can now type the shortened URL. OK in this example it doesn’t gain you much, but if you have your own domain and have tied your OpenID to that you would have an OpenID like http://openid.mydomain.com/itsmereally, which can benefit from shortening