Sep 25, 2012

Angry user...

Sorry, I could not resist the pun :)

Well, some time ago (to be more precise 1 1/2 years ago) I've bought a (Chinese) Android Tablet so I could experiment, play games and may be try to develop some program (of course I've failed miserable to write any application for it :(. You can see a picture of the device bellow (it ended up to be much more resistant than what I expected! You can see its cracked 
screen due to 2 ~ 3 not so smooth landings - thanks to my young daughter):

Anyway, I use it regularly for reading ebooks, email reading and playing basic games. Talking about games I used to play "Angry Birds" (all free editions) on this device with no problems at all; but at some point in time something has changed and since then I am not able to play it anymore. The symptoms are always the same: I launch the game, its "splash screen" shows up followed by some screens and finally the "loading" screen shows up but then the application just dies without any trace! 


I had just accepted the fact that I'd not be able to play this game again on this device but last weekend I was recovering from a small surgery and I decided to investigate it a little bit more.


First thing I did was to install a log viewer (I'm using aLogCat) to check if I could find anything on Android logs. Indeed it was pretty easy to find the information I was looking for:


E/HttpRequestHelper( 4956): Exception from HttpClient.execute.
E/HttpRequestHelper( 4956): java.net.UnknownHostException: rovio.events.medio.com
E/HttpRequestHelper( 4956): at java.net.InetAddress.lookupHostByName(InetAddress.java:513)
E/HttpRequestHelper( 4956): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:278)
E/HttpRequestHelper( 4956): at java.net.InetAddress.getAllByName(InetAddress.java:242)
E/HttpRequestHelper( 4956): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
E/HttpRequestHelper( 4956): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
E/HttpRequestHelper( 4956): at


Huum... ok, so the application tried to resolve the host "rovio.events.medio.com" and it failed bringing the whole app down! WTF? (I tried to access this host from my desktop and the result is the same (
Interesting enough, medio.com as well events.medio.com does exist) so I assume the problem is directly related to the subdomain "rovio" on events.medio.com.

Searching on net for this error did not bring any useful answer. Also I've tried to clear Angry Birds application data, 
re-install it and even a device factory reset (due to other issues) to no avail :(. 

Have you seem this error? Any ideas how to fix it? I doubt I am the first one to stumble on it!

Sep 15, 2012

Shopping abroad


If you by stuff while travelling abroad (more specifically to European and some Asiatic countries) you may be paying more than you need to! This is because in such countries there are some taxes that tourists do not need to pay but they are included in the product price anyway.

Bellow I show the basic steps to make sure you'll get a tax refund:


  1. Find a participant store
  2. Buy and pay (of course) your stuff
  3. Tell the clerk that you want to get a tax-refund (at this point he/she will fill a form with information regarding your purchases / you)
  4. At the airport do the procedure to get your refund.
I'll not explain all these steps in details here; instead I'll focus on how to proceed at the airport (step 4) because that was the most confusing part for me. For more information, including the complete list of countries you can check here.

Also, keep in mind that the following description is based on my own experience (mostly travelling to Germany) and it may be different in other countries (although I believe that they are either pretty similar if not the same in all countries).


So, when you get ready to return:


  1. At the check-in post inform the clerk that you have a tax-refund to claim. She/he should follow the usual procedure but instead of dispatching your bags immediately it will be handed back to you (with the baggage identification stickers on it).
  2. Now you need to go tho the customs where a custom official will check your purchases, receipts and stamp the form filled at the store. At this moment your bags will be dispatched.
  3. With your form stamped go to the "tax-free" post (usually within the board area, i.e, after the security checks) and present the just stamped form and your passport.
  4. Get some of your hard earned money  back.

Regarding refund methods I have used two different ones: i) cash, ii) credit in a credit card; sometimes the tax-refund clerk asks you which method do you want, sometimes he/she will pick one for you :)

One mistake I've made at least twice was to forget that in some flight connections you don't take your bags back at the intermediate airport. For instance in one of my travels I was returning from Germany to Brasil but my flight had a connection in France, i.e, I'd fly from Germany -> France -> Brasil. Since the instructions are to follow this procedure when you are leaving EU I planed to  do this in France, but wait, I did not got my bags back in France, so no refund for me this time. In this case I should have done the process in Germany.


BTW: Last time I got back 13 euros which represents more or less 10% of my expenses (this value may vary for each country of course).


Hope this help others....

Sep 4, 2012

C#/.Net Generic constraints

Hi

Despite having no doubt about the usefulness of type constraints in C# generics (this is a key feature to help avoiding bugs when writing generic code in C#) I always had  the impression that it should be able to express more constraints than what the C# language / compiler exposes.

Well, some
 time ago this blog entry called my attention on my RSS reader and motivated me to go and scan the .Net specification (more specifically § II.10.1.7 in the CLI Metadata Definition and Semantics document which can be downloaded from here) and to my surprise I found out that in addition to the valid C# generic constraints CLI also support constraining a generic argument to delegates, arrays and even enums! That is nice.

Next question is: does the C# compiler abides by these rules when consuming assemblies?


To answer this question I wrote a small class library (
in C#) that exposes some generic types and manually (ildasm/ilasm) added each of these constraints. After that I created one application (C#) that uses this library and confirmed that C# compiler does respect these constraints (at least in VS 2010 which uses CSC 4.0.30319.1). Bellow you can see the result of trying to use these generic types with incompatible types:
Generic parameter 'E' was constrained to enums
Generic parameter 'E' was constrained to enums

Generic parameter 'A' was constrained to arrays. 
You can download the sample application from here.

The bottom line:  Generic constrains in .Net  are more useful than what you may be lead to believe ;)

As always, don't be shy! Let me know what you think.

Hope you find this useful.

Aug 31, 2012

My adventures with Arduino continues...

Hi

In this post I listed some components/shields/breakout boards that I want to try with Arduino. Well, last weak one of the missing components in order to test my ethernet breakout board (one very similar to the one in this post) arrived.


Like I child with a new toy I took the evening to try it out. After some time I finally got it connected (unfortunately there's not much information about the ethernet breakout board I've got in the net) but to my frustration I could not get it to work. :(


Basically I connected my Arduino Mega to the breakout as follows:

ENC28J60    Arduino
-------------------------
CLKOUT       NC
WOL            NC
SO               50
SI                51
SCK             52
CS               53
RESET          RESET
VCC             3v3
Gnd             Gnd

When I power up the Arduino board I can see that a red led also lights up on the ethernet breaakout board but its statuses leds does not blink / flash.

After a lot of time checking it my guess is that either the breakout board is defective or that it requires a crossover cable (I've tried various cables connecting it both my router and my computer directly) (
ENC28J60  datasheet claims that it supports "One 10Base-T Port with Automatic Polarity Detection and Correction" but this doesn't looks to be the same as auto MDI/MDIX to me).

Well next steps:
  • Ask for help on Arduino forums (already did)
  • Try to get a crossover cable to check.
  • Try to exchange it with a new one
  • Hope that someone have already faced this issue
As soon as I get any update to this I'll post comments here.

BTW, if you have any idea how to test / get this working, drop me a comment.

In time: I just received a "bluetooth" breakout board :) but this will need to wait to get tested.

Happy programming.

Aug 15, 2012

Windows 8 / Visual Studio 2012

Hi

Getting back to the subject I am more comfortable with, MS just released Windows 8 / VS 2012 (for MSDN and Technet subscribers). Off course I am downloading both right now but this is the first time, since Windows 95 launch, that I am not going to install the new MS OS as soon as it gets released. 


To be honest I am not even considering installing it (on my main dev machine) in the next 6 ~ 12 months! Contrast that to what I've been doing in the past 
(I've used Vista / Windows 7 RC!) and you can see how "excited" I am about it (maybe I install it on a virtual machine so I can experiment with it). Anyway, sooner or later I'll end up formatting my dev machine and the question is: am I going to give Windows 8 a try? Or shall I take a more drastic approach and install Ubuntu? This bring me to the second MS release.. VS 2012.

One of the main reasons I'm procrastinating migrating to a Linux OS is that I really enjoy developing using .Net (yeah, I do know Mono; the problem is: the bulk of .Net development is still concentrated on MS platform. Also, 
IMHO, *nix lacks a good .Net IDE).

Of course my friends (at least the ones in the software development field) knows that that is not completely  true: I also enjoy MS technology in general (COM+ pops up as one example).


What do you think? Should I dive into Windows 8?


BTW: Visual Studio download finished! This one for sure I'll get installed in the next few days ;)

Happy codding!

Aug 8, 2012

Connecting Nokia 5110 LCD breakout to Arduino

Hi

As I said in my last post, I have been playing with some hardware parts for Arduino.


In the "still to go" list I had:

  • Ethernet breakout
  • External EEPROM
  • RTC (DS 1307)
  • Nokia 5110 LCD
My plan was to tackle at least 2 of them during last weekend but I had a problem: all of this parts requires external components that I didn't have at hand. So I went to a local component shop but unfortunately I could not find most of the parts. 

The only part I had the required "missing" components was the Nokia LCD so I googled for "Nokia 5110 LCD  on Arduino" and voilá! The third entry in the results links to one great source of information about Arduino (and electronics in general). Now I was ready to start; I pulled my Arduino board, breadboard, the LCD (and required components) and put myself to connect them together.


My first disappointment came when I uploaded the sample application and nothing happened :(
Oopss.. maybe I have messed up with the connections... , let's see, pin x goes to y, pin z goes to w... no, everything looks connected correctly. After some head scratching I finally decided to do what I should have done from the beginning: Make sure the pin on my LCD breakout board matched the one in the Laydada  guide and of course they didn't! Compare the two pictures below (the red one is  mine and the blue one is the one used by ladyada):
As you can see they have different pinouts! Next step was to carefully reconnect the LCD and power on my Arduino (crossing my fingers hoping nothing bad had happened to neither my Arduino nor the LCD); this time everything but the backlight worked as expected; for some reason I could not explain the backlight refused to light up.  I checked and re-checked the connections many times but could not spot the problem. 

But at some point, during my investigation I could swear having seen the  backlight turning on and off; after some more testing I found out: by mistake I connected the backlight pin to the Arduino ground and that did the trick. But wait, both the LCD breakout schematic (not shown here) and the board itself does states that I should connect 3.3v on that pin... I have no idea what's happening here, but it is working. 

Next stop: external EEPROM.


Happy programming.

Aug 2, 2012

Now we are talking :)

Hi

Just a quick update on my Arduino experiments.


Some of my new "toys" just arrived....

I managed to get the following working so far:


  • Ultrasonic sensor (HC-SR04)
  • LCD 16 x 2
  • SD card
  • Temperature sensor (18B20)

Still to go:

  • Ethernet breakout
  • External EEPROM
  • RTC (DS 1307)
  • Nokia 5110 LCD

I am having lots of fun ;)

Lets get back to play with the ethernet breakout. 


See you.