S60 Surveillance Camera and PyS60 instability

During my 4-week summer vacation I had some time to work on one of those projects that I’ve been meaning to do for ages. The task at hand seems simple: I have an old Nokia E70 device and I want to use it as a surveillance camera so that I can go to joker.iki.fi and see the pictures taken from our house when I’m travelling with my family.

I decided to implement first quick-and-dirty version of this in such way that the phone takes pictures every 10 seconds and sends them, one-by-one, using the wifi interface, to joker.iki.fi as a POST request. On the server side, there would be simple server component, which saves the image and tags it with the time it’s taken.

Since I made a holy promise not to touch Symbian C++ ever again, I implemented the component which takes the pictures and sends them using python for S60. I already had some good experiences of this from the SMS forwarder script, so I decided to take a deliberate risk on developing something for a Symbian device on my free time. On vacation time, I like to avoid any frustrating projects and doing something on Symbian is always frustrating, maybe excluding shooting the thing with a shotgun.

At first, everything seemed to work very nicely. Then I got *AGAIN* into the hell that is development on the S60 platform. Even using Python, you can feel the shaky yet rigid bubblegum patchwork that is Symbian underneath. Nothing works like you expect, error messages are about as informative as sudden kick to groin and documentation is outdated, crap or it doesn’t exist.

The script is under hundred lines and doing basic things, yet it took me close to 12 hours to get it working (well kinda). Here’s the most annoying things I found:

1. PyS60 Socket library madness. I can’t understand (or really care) why there are two socket libraries in PyS60. There’s the normal python “socket” module and then there’s something called “btsocket”. These look mostly the same and BT in the beginning refers to “Bluetooth”, but then you can use it like you would use sockets for anything else. The thing is, it seems like pys60 libs use the socket library, so if you give python libs instances of btsocket, you get unexpected behavior. Nothing in the documentation tells you this.

2. The “default access point” behavior on S60. This is related to the socket annoyance but is a nice extension to this. You see, when an application tries to use network in Symbian, the os pops up a dialog for the user to select which access point (can be 3G packet data or Wifi for example) you want to use. At times this dialog randomly refuses to show you the Wifi access option and best of all: If you do “send(data, server)” in a loop for example, 10 times over, the default behavior is to … yes you guessed it: Ask the question 10 times, each time for each loop! How cool and secure is that!

So I ended up doing my own access point selection dialog which prevents also the problem of constantly selecting the access point. Why oh why did I need to code this myself?

3. Fail eventually, silently, horribly -style behavior. This is really notorious thing and seems to happen always on this platform. My application is essentially like this:

initialize()
ap = select_access_point()
while(True):
image = camera.take_photo()
send_image(ap, image)

Everything worked nicely so I decided to leave the script running and went to golf course. When driving back, I checked the camera output from my trusty HTC Hero. Surprise, the image hadn’t updated for hours.

I spend a lot of time trying to find why it’s crashing (and it was crashing the OS, not the python runtime) and managed to isolate the problem.

Probably most annoying thing was this:

4. When the app crashed the first time I first checked through the code and found no problems. Then I checked my pyS60 version, which was quite old, and decided to upgrade to the latest 2.0.0. I spend hours trying to do this and found out that no, it seems that for some reason the installation is just not working. Grr.

While every annoyance is probably not related to Symbian but some can be attributed to the pyS60 project, this is yet-another negative development experience on top of Symbian. It really is a waste-of-time-kinda-platform. I do realize that I’m in S60 3rd edition still and newer versions exist, but still I wonder when there will be a brave leader of Symbian who has the balls to say: Look guys, this OS is no more. It was nice in 2000, but we actually need to develop something that works nowadays and Symbian only gets in the way.

Please let there be such hero really soon.

I’ll probably release the surveillance camera as soon as I get the code cleaned up and hopefully the bugs get fixed sooner than later by PyS60 team.

SMS Forwarding for S60, in Python

I got a new phone and had to take a new SIM card for that, and I didn’t want to migrate my old number to the new card, as the new number is mostly for work. Now I have two phones but I want to carry just one, and have the calls and SMS:es forwarded to the new phone.

Easy? Not really. Diverting calls is easy, but for some reason, there just aren’t any SMS forwarding applications that would satisfy my requirements:

  • Free, as in speech and as in beer
  • Would only do one thing, that is, forward SMS:s to another cell phone number, as soon as they arrive
  • Would be easily customizable
  • Would work on S60 3rd edition without the certification pain

Well, now there is a solution that satisfies all these requirements. All this with < 30 lines of Python code.

Check out sms_forwarder.py.

Distributed knowledge

I’ve been thinking lately of a problem that constantly seems to hit a lot of IT projects (and probably other projects) in the face. Basically, how to make the basic assumptions and done decisions most efficiently known throughout the team.

For example, if the lead developer or architect decides that a component called “engine” needs to do only thing A and B, nothing else, and he thinks that if anyone, ever, wants it to make C, they always need to understand the original rational for limiting the functionality to A and B, before making the decision to add C.

Problems like this can become tedious in larger organizations because many people only typically know that the “engine” exists, but nothing else. Without knowing the context and basic assumptions made when the original decision to keep the functionality to the bare minimum, that is, only to have A and B in the engine, many people waste a lot of time and effort to design stuff without complete information.

Clearly, traditional approach, meaning documentation and learning, is quite slow and inefficient. Worse yet, collective documentation and collective learning are even slower. People constantly are misaligned with their documentation and with the stuff they have learned.

Nevertheless, I think I have found out at least few items that can make this better and I hopefully can pursue them in the near future. Please let me know if you are interested in this topic, I’m surely going to need help.

Raising the abstraction level

Start with logic gates created from transistors.

Continue towards boolean algebra operations.

Too difficult? Try representing integer and float values and basic arithmetic operations.

Now code that in assembler.

Hard to follow the flow of the program? Move to a sequential programming language.

Hard to write correct code? Maybe some functions and scoped, automatic variables?

Hm, still quite difficult since you can access all the stuff in the program and create unexpected dependencies?

Should we try to do a object oriented program to protect access to object or component internals?

What, now you need to actually still reserve memory (and most importantly, free it when there’s no use for that particular data)?

How about running the code in container and have the code managed by a virtual machine?

Ok, but now you still have that nasty code you need to compile and change.

How about making a generic code framework on top of the virtual machine engine that you can dynamically command using a higher level language that you specify from standard building blocks?

Ok, now you still need to worry about the underlying hardware resources like having enough memory and disk space. How about virtualizing that?

Sigh. Now we have everything virtualized and you can add hardware resources to your virtual system that’s running virtual machine-managed script code. How on earth do you know what piece of virtual code depends on other piece of virtual code? You need to capture that as a standard metadata that you can again use to know what’s really going on.
How on earth do you now make sense to all this metadata? Let’s standardize what are the pieces that make up the virtual system and expose that logic over a standard layer and call it service orientation.

Hm. Seems like a lot of services… We surely don’t want to make those services be called from sequential or object-oriented programs, we need to make higher level “processes” that can be dynamically configured and run in another container so that you can actually relate those to the processes that organizations are made of.

… and this is pretty much where we are now. Automating processes which call services organized into strictly governed building blocks and use standards-compliant interfaces. All running on virtual machines on virtual hardware.

Good enough for you?

No, think not. Next we make the data itself virtual and standardized so that you are not restricted to doing calls to it from any particular (virtual of physical) location but you can just call it by name and the underlying framework locates the data, the process that needs the data and services which actually operate on that data.

Next step would be to virtualize the data generation logic so that it finds it’s right standard and virtual call handle so that the creator of the data doesn’t need to anymore know the data.

At this point we can probably hand it all over to semi-intelligent virtual software layer which can do all the stuff we tell it to do starting from the data generation to the actual usage.

Next, only logical step is to write and artificial intelligence layer using quantum computing on top of the stack to know what we want to actually do with our systems before we even know that.

At this point, you don’t need to calculate how much money you will have on your bank account the next week after all the bills because every possible scenario is already calculated.

Maybe then I will have time to develop that game I have always wanted to develop. Oh wait. It was already developed by our ultra-virtualized, standards-compliant quantum AI overlord. Nothing left to do anymore. Doh!

Economic meltdown

I have to say that the last thing I am interested in is the global economy. I find the theoretical side boring and the practical side very distant. When it comes to investing to stocks and soforth, I am not really doing it. Partly this is because I’m paying the mortgage more agressively back whenever I have loose money and partly this is because I just don’t have the energy to invest and then aggregate a solid base of knowledge aroung the investment to actually maintain the investment.

This can be pretty stupid and surely it is against the principles of market economy. I already know that I’m the worst consumer there is (I don’t really consume that much because I don’t need that much) and I don’t invest my capita efficiently, which probably in few years will be counted as an act of terrorism.

Still currently I have been listening to the world’s finance news more closely. Typically I ignore the “OMG the nasdaq has fallen/risen this much and that much” type of news since I think that most investors and analysts are a bunch of control freak monkeys whose blood pressure is directly linked with market tickers. And I found the “Jump You Fuckers” comment hilarious. Anyway, it is looking like this one can get pretty nasty and since I work as an IT consultant, my work is quite sensitive to economic hiccups.

While it would be quite bad to get fired (I don’t think it’s very likely currently, although working for a US-based company can be problematic currently…) but also that would be my first time ever. Well, in the case that I would get sacked, I think I would use at least some of the time paid by the union to actually do some serious introspection and career moves. Personally I would be very interested in starting to work with only open source products. I am currently quite sick with the problems associated with commercial software. I would like to code, but with the way the current consulting engagements have gone, It’s been powerpoint only. This makes my coder heart cry in pain every time I need to “restructure” or “fix” or “generate” another slideshow to explain some topic. Granted, some of the things I work with are conceptually quite hard and since it’s the customer who pays the bills and has to live with the solution, it’s only fair that I explain what I do. Anyway, this probably deserves another posting.

But the point was, economic meltdown may actually be a good thing for me. I get to go back to the basics if shit hits the fan in a big way. Of course this would mean that there’s a way to feed the family and stuff but I don’t really think that shit’s going to be hitting the fan so hard that food production stops. And if it will, then I can become a part time farmer. That would be kind of cool too.

Greetings from Brussels

Hello all, just wanted to say hello from the capital of EU. I’m currently doing a 5 day course here and then spend the weekend here with my wife and daughter.

There’s very limited connectivity and I don’t have too much time to blog from here, but I have done some writeups offline on my mobile. I plan to post those here, perhaps even today. Good that the Android phones are just about to be released, so that I can start to really maintain my blog. Seems like all the keyboard time I currently have go to something else than creative work…

Anyway, this city seems nice enough. It’s very much possible to bicycle here and it’s very easy to get around. The traffic is pretty ok and food and beer is good. Prices seem to be pretty standard across EU nowadays so no big surprises here.
Belgian people are quite much like the french, but bit more friendly and helpful and at least here they tend to know a few words of english.

This course almost feels like a vacation. Title is “Embedded Linux” and it’s organized by Linux Belgium. Nice people and interesting agenda. I basically wanted to know how nowadays people do embedded systems using linux. When I last did lowlevel stuff in Linux it was back in the 2.2 kernel days. It’s totally a different system nowadays and you have all these cool tools like Busybox. It’s very cool stuff that’s happening and now that everyone is creating devices on top of Linux it’s very nice indeed.

Release 2008.02 of Mobilogger

I have just released my new open source project. I call this baby Mobilogger.

It started when I participated in Google’s Android Developer Challenge. I didn’t qualify for the second round (out of 1,788 entries), but it was fun and educating experience. First time in years actually writing software for embedded/mobile device was actually fun.

Mobilogger is a mobile blogging application. You install it to your Android-based device (whenever those hit the market), configure your blog into the app and you can start posting.

I tend to only write software on my free time that’s useful to me. With Mobilogger I hope to be finally able to post blog entries here more often when in pointless meeting or when sitting in the bus. This is the design goal of Mobilogger; whether it’s video, pictures or text, posting entries should be as easy and quick as writing SMSes.

Anyway, in case you are looking for a cool mobile application for blogging when the Android devices come out or just want to contribute to the project, go to google code and join the team!

It’s been a while when I got to contribute to the cause, so this feels good. The current version of the app was a lot of work but it has been well worth it. I actually tried to write the same application on Symbian too during last year but got frustrated with the buggy tools and generally very annoying platform.

Now we just need to wait for the actual Android phones to hit the market.

About to really end the silence

About a month ago, I mentioned that there is a lot of things that I have been up to and this keeps me from updating this blog. It’s still true, but let me give you some more information about the situation.

First, the new baby is a lot of work. Lot of positive too, but the time I’m able to spend with the kid is not really as much as I’d hope to be able to. So whenever I have free time, blogging is not one of the top most important things.

Second, I’m just about to publish my new open source project. For the first time in years I have actually spend a lot of time on one single project to actually get it done. I’m a master of unfinished coding projects, especially when I lose interest after solving the core problems I intend to solve with with the code.

This time around, it’s a bit different. I’ve been actually able to invest significant amount of time to this project and it’s very nearly completed. I just need to clean some of the ugliest bits of the codebase and then it’ll be available. Within a week or two it should be done and out.

The baby is totally cool. It’s so rewarding to see her learn new things every day. Surely, it’s been a big change in life too, but for the most part it’s been towards positive. Less beer, more family time, if you need a summary … =)

Ok, no more from me this time, keep checking the blog for updates. My friends should be able to access some baby photos through facebook too.

Feeling lazy and anxious

All of this vacationing has made me really lazy. I really haven’t been accomplishing anything for many weeks now and this causes me to feel a bit anxious. It’s a funny thing really. I relax the best when I have something to do. Just sitting on my ass doesn’t seem like an option.

Yet still I have problems getting stuff started. I have one Symbian OS coding project which progresses really slowly. Also, I keep getting some light pressure from my wife to finally start the home multimedia center thing going on. Currently the only way to record anything from TV is this old VCR and since Finland is going to be all digital really soon, this is something that would be nice to do. I don’t want to buy a DVB recorder since my own MythTV box seems more appealing.

Then there’s the next Nordic Underground Digital movie production which I feel is not faring all that well currently since the vacation time keeps us from finalising the filming.

Then there’s the travel journal thing that I’ve been promising to do for some time now.

Then there’s a ton of small repairs to the house and all sorts of improvements. I totally need to get stuff done since most of this stuff will get more and more difficult to do when work starts in August. I think I will have a hard time adjusting to the office life after this much vacation.

Just some of my insights to Symbian development

This post I think I need to start with a disclaimer: The following that is said is in no way related to my employer or any other company for that matter. It’s just an interesting thing that happened to me during my free time and is in no way related to any person I have business affiliance with.

Just the other day I was discussing with one guy who has been involved with Symbian S60 platform development. I didn’t actually know that he had been involved with this stuff until this discussion took place. Basically, I complained to him about Symbian S60 as a development platform. The platform is just very hard to learn even if you know C++ and getting from initial concept to a working and installable product is very time-consuming and frustrating.
I have written quite a lot of software in many languages and platforms during the 20 years I have been coding. This includes also some very low-level things with C and assembler. I took to Symbian development a few years back and was first very excited about the platform. Now that I finally have S60 devices and have some time to actually do more complex development, the difficulty and pain of developing working software has really surprised me.

Then just as a proof to the points I made, I found a link to this article from Slashdot. I would not like to call it a piece-of-shit OS as the article does, but I think it’s in serious need of redesign. I do realize it’s just not very easy nor cheap to make an easy, fast and customizable mobile smartphone OS, but the things that the article mentions just don’t seem to be today (or future) anymore.

I also would like to see some statistics on how much resources the worst problems of Symbian, like the VERY frustrating “leaving” exception handling and the descriptor paradigm does really save. If just these few things could be fixed and I could actually write my apps using a language closer to C++, I would not complain anymore.

Well, that and starting to add support for Linux on the development tools side.
I just needed to write this as the coincidence of stumbling to that article was quite eerie.