Sunday, February 26, 2012

What does an iPhone look like after being stepped on by a horse


This is my girlfriend's iPhone after being trampled on by a horse. I will be opening it up to see if I can repair it. The front side is perfectly fine but I won't know till I get the LCD powered on.

Coincidentally, I also have a water damaged iPhone 3GS that I got from a colleague. I'm going to be opening that one up too and seeing if I can repair it.

Thursday, February 16, 2012

Just a little frustration

Picard - Facepalm (Ready Room)
I'm doing code integration and verification and found something that upsets me just a bit more than it should.

I basically came across a function from a header file and it asked for a pointer to an array and another pointer where it would return the size of the array. It would then fill said array with data and return an error control back to the caller according to the comments.

Example function prototype:
int badFunction( int *outputPointer2Array, int *OutputSizeOfArray);

I got really suspicious of the function as it didn't ask for the size of the array to be passed. I was wondering, well what happens if someone came and provided an array that has a size that is different than the expected? Maybe it will just malloc it for me and return an array with its size... Nope. The sizeOfArray pointer had given me hope that I would be able to tell it how much memory I had allocated for the function but no, it is strictly used as an output.

So I dug deeper and found out a few serious concerns with the function.

#1. The function would fail if it received a NULL pointer. Not really a bad thing but it ties into the rest.
#2. The size of the array is never constant and can change depending on the hardware.
#3. It does not malloc memory for me and requires that I manage the memory for it.
#4. No error checking at all to make sure the function doesn't over flow the array.

Together, all of those problems leads to a potential situation where the memory will become corrupted if someone didn't realize the array size could be dynamic. Unfortunately, you cannot know ahead of time what the size of the array is without actually knowing the hardware. If a poor soul had no idea and put in an array that was too small... the function would have over flowed and corrupted the memory.

So I wasted some time sanitizing my inputs to the function so I malloc enough memory for our particular hardware every time we call it. As well, I also added a few checks to make sure the function did not overflow out of the array. If it did, then the driver would at least be able to report it back to the kernel that the memory is no longer valid.

A good, dead simple design for the function would have prevented this issue. From the looks of it, I'm assuming it was written by someone new to C and didn't understand how arrays and pointers worked.

Next time, we'll discuss why " if ( sizeof( *pointer2array) > 10)" is also not valid and makes me face palm.


Friday, December 23, 2011

Possible Downtime

For reasons I won't talk about right now, jaimeyu.com may go down for a few days. This is merely a warning as I'm hoping nothing goes wrong over the holidays. I am switching domain name providers and there is a small chance you may not be able to get to the site but I think this scenario won't happen. So Happy New Year!

Update: Had things go awry with my domain proxy so it looks like I'm locked for 60 days before I can move my domain again. Very annoying. I'm still planning the move nonetheless but it will be sometime in spring.

Last day at Tyco

Wow. Today was my last day at Tyco. It's A bitter sweet feeling leaving the company. Luckily, I've gotten good projects and pretty much had a good time. Leaving a lot of good co workers behind is probably the hardest part. I also feel bad beside I left my colleagues with a significant amount of work that i was responsible of. I was partitioning my time today for helping them out so they can have a head start. Especially one where the code size ib gave was much too big in comparison to another prototype I had built. I have no idea why the prototype I gave doesn't work. Most likely something broke as I scrambled to get it packed up for someone else to work on. Sadly, I was one of the last people to leave the office today. I wasn't counting on it being a half day so I actually spent the morning running a test and helping a colleague. Oups. Maybe it's a message I'm working too much. But now it's time to move on to a new job and a new city. I will be working at Thales and it sounds like I will get a chance to continue working with embedded software and other fields. I'm looking forward to working with them and expand my experience and skill sets. In other news, i now have a bunch of free time. I'm wounding what I'm going to do Monday morning with no work. I will definitely be packing my stuff in preparation of the move. But that shouldn't be to bad. I don't have a lot of stuff to begin with. Maybe I will get on that serial sniffer application I've been meaning to write. Would have been nice to have. More extensible version than the one I wrote at work. Plus it would be open source so I don't have to hide it like my other stuff because it was created at work. So I wish you all a happy holiday and a new year!

Wednesday, December 14, 2011

Source Code

Just a heads up on some code I'm working on. I'm working on some Arduino code for myself and my friend and I will be posting it here: http://code.google.com/p/arduinotutorials/ .

There isn't much but I will start using that for all my source code snippets from now on.

In other news, I'm moving to Ottawa for a job opportunity so I probably won't be updating the blog with new tutorials or code for a while. I was hoping to take the vacation to do some coding but it looks like it will be replaced with trying to move my life to a new city :)

Wednesday, November 02, 2011

The Brains
I just received my STM32F4Discovery evaluation board from ST Microelectronics. My colleague at work gave me the heads up that STm was shipping the free sample so I jumped on the opportunity. The deal is unfortunately over right now but you can still pick the baby up at Digikey for ~20$.

The particular reason I got this board was the built in accelerometers. I've been trying to save up and justify for some accelerometers + gyroscopes but they're either ridiculously expensive (I live in Canada, shipping and import duties are not cool, often cost more than what I want) or ridiculously difficult to solder. So a pre-built accelerometer was a no brainer for me. Anyways, the name of the game is cheap and so far, free is the best price.

I also ordered some free samples for some CAN bus transceivers and controllers. Hopefully, I will get them by next week but we'll see. I'm going to be putting it all together as a vehicle telematics system. I would have love to have gotten some gyroscopes for some better twist data but I will have to live with what I got.

Basically my car is going to be outfitted with a real time suspension geometry sensors, radars for both front, rear, and blind spots, maybe a chassis flex sensor if I can figure out how to hide the sensors, as well as a CAN bus interpreter for engine telemetry, GPS for location (if I can find my old GPS unit for a Palm Pilot). Everything will be fed into my laptop for now for display. I doubt the chip has enough power for a straight up Linux with OpenGL driving a large 5 inch screen so whenever I get the time, the board's screen will have to be completely home brew which is a waste of time for what I want. For now, I will run it on my laptop which lets me code 3D models which is way more useful than black on grey numbers. Is there a point to this? Probably not but my passion is in real time telematics and that's enough for me.

The hard part will be seeing what hardware I can install while its -15C during winter. Oh well. Hopefully it will go quick and the CAN bus will get done fast.

Side note: STm doesn't ship the product with a free GCC toolchain that works with their USB to JTAG interpreter. I'm having a ton of problems trying to get my Ubuntu running but I found one possible GCC toolchain here. I'm going to try it when I figure out what I'm going to do with my Virtual Machines thrashing my hard drive.

Monday, October 24, 2011

Zune Music Pass Mini Review

The Zune Music Player doubles as a nice screensaver. 

For the last two weeks, I've been enjoying the Microsoft Zune Music Pass on both my PC and Windows Phone 7... phone. It is an all-you-can-stream-&-download music service. They have a two week trial that you can try out before buying into it. I'm not going to be buying it just yet since I'm currently in the midst of acquiring parts for a large build up. Priorities. But I certainly would buy it if I had 10$ lying around every month or if Microsoft wants to throw me a free subscription cough cough.

Basically, I was enjoying unlimited music downloads and streams to both my PC and my phone. I actually ate my entire monthly mobile quota within a week because I was streaming tracks and when I found a song I liked, I immediately hit the download button. Boom, it was on my phone. Great for downloading but wasn't great for my monthly quota :( It is really well integrated with Zune on Windows Phone 7, a bit too integrated. My one suggestion, sign up using your phone to quickly register your phone to the service. Doing it online and then attaching it to your phone isn't as straight forward as one would hope.

Music selection? Pretty good. I found most of what I wanted but I wasn't searching that hard for obscure bands like the Metric's bonus tracks. Impressively, I found a few k-pop (rap?) groups on it, like 2NE1. To each their own but at least you can navigate their entire selection using the web based GUI. Hate downloading apps just to check for "selection."

Pros
Good music selection
Good quality music (bit rates, not tastes)
Very good integration with your devices, covers your PC, Windows Phone, and Silverlight capable browsers for online streaming. Maybe Xbox too?
Unlimited downloads and streaming
Nice DJ service to help find new music. Wish it would tie in with last.fm or pandora
Supposedly can buy 10 free songs a month DRM-free. Haven't tried this. Definitely a nice bonus if it does work.

Cons
It isn't free. 10$/month or 100$/year.
Songs comes with DRM so you will be unable to play said songs when you stop paying for the service (doesn't apply to songs you actually purchase.)
Will eat up your bandwidth quotas if you stream a lot. So if you're Canadian, 10$/month + overage fees are not that appetizing. It is very easy to download everything.
Doesn't have that song from that indie band that I never heard of or care about.