Tuesday, November 13, 2007

CNBC Trading Matters Challenge

Tuesday, April 24, 2007

Nokia N95 and PC Suite USB Conection Problem

I friend of mine just got a Nokia N95 (really nice phone). He had installed in on a laptop and got everything working, but then when he tried to install in on a desktop it just wouldn't connect to PC Suite via USB.

The drivers all seemed to be recognized by windows XP, but PC Suite just sat there asking for him to connect the phone. He had uninstalled, reinstalled, rebooted, powered off, updated software etc and nothing was working.

After a little bit of searching I came across the a discussion on a European nokia board (which I can't seem to find now, sorry). In the middle of someones post they had said check that USB is selected in Connection Manager (I think that was what it was called). I did that, and noticed that of the options (Bluetooth, Infrared, Serial, USB) serial and usb were selected.

Wondering if serial was somehow overriding USB, I deselected it.... And it worked!!!!

So N95 USB Connection to PC Suite problem solved. Make sure ONLY USB is selected, at least to get it working. I didn't play around to see if it would work again with serial selected also.

Tuesday, March 07, 2006

OpenVera

Got an Open Vera problem? Wondering how best to structure your classes? Trying to understand how to use vera shell, hdl tasks or hdl nodes? Ask away. I can't promise to be able to answer everything, but I've been using it daily for 18 months now and I have a reasonable working knowledge.

If you ask me there is a lack of third party information out there on Vera. So I thought I would try and help a little. I like Vera, but I have only previously verified with raw HDL so anything has to be better than that.

Write your question as a comment and I will try and answer it as soon as I can.

Friday, January 13, 2006

A Perl Gotcha

I've been using perl for about 6 years now. I don't claim to be an expert as I tend to be working on things by myself and thus don't learn from others. Plus it tends to be text manipulation in a small script, so less need for all the wonderous things that perl can do.

Anyway, a short while ago I had a problem and eventually when I figured out what was going on I was amazed that I didn't already know it, and that I hadn't already come across it.

foreach my $tmp (@my_array) {
$tmp =~ s/(\w+)\.(\w+)/$1/;
# do somthing with $tmp;
}

I never knew that $tmp is an actual pointer into the array, and thus I am modifying the array entry with the regular expression, not just the tmp variable.

instead, use a variable to index the array, or use $_

foreach my $i (0 .. $#my_array) {
my $tmp = $my_array[$i];
#etc.
}

foreach (@my_array) {
my $tmp = $_;
#etc
}

Well there are a million ways of doing it. Probably better than those too.

Thursday, January 05, 2006

iTunes Lost Libraries

My wife is a music fan and uses iTunes (yes now that there are ways to buy music online we have stopped being big bad "pirates", Aaargg! Lets retire and drink rum matey!).

Unfortunetly there are still major shortfalls in the online music purchase world. I for one would like to see a central clearing house type system that allows me to buy music from anyone, play it on all devices, and be able to re-download lost music...

Which gets me to the problem at hand. Windows XP seems to be really bad at losing files if your computer crashes (well we can't have everything, at least it doesn't crash too often anymore). Problem is, all to often it seems to be the iTunes library xml files. That really sucks if you spend a lot of time getting playlists just right as most iPod owners will do.

So I eventually decided that an easy backup solution was needed. Of course I really should have a full backup solution for everything, but hey, who does. I do it every so often to make sure we have copies of our purchased music, and not too much else changes very regularly.

Anyway here it is. Basically it makes a copy of your iTunes metadata (library lists, playlists play count, ratings etc) and deletes older backups. It's an old school batch file and you should run it using task scheduler, its up to you to choose to schedule it daily or weekly (don't go to monthly as the script deletes anything at least a month old, so you might end up with one copy of an already corrupted file).

How to use:

1. open a dos prompt (Start > Run > Open "cmd") and check your date syntax (date /t). If the result is Day DD/MM/YYYY then downlad this file. If your syntax is American (Day MM/DD/YYYY) then download this file. You will need to unzip them to the .bat file, use Winzip if you don't already have something.
2. copy the batch file from step 1 into your iTunes directory (usually Documents and Settings/My Music/iTunes or something like that)
3. edit the file if you want your backup to go anywhere else but a "backup" directory in that same location.
4. Setup your Task Scheduler (Start > Control Panel > Scheduled Tasks > add scheduled task). First browse for the file you copied to your iTunes area and make it the "program you want to run". The selec a time to run when your computer is most likely to be on, and at the period you would like (daily or weekly?).
5. You are done.

The backups will be in the backup/yyyy/mm/dd directory. The first time the script runs in any particular month, the second to previous month will be deleted (ie "more than a month ago"), at the beginning of Feb the previous year will be deleted.

There's More
While I am complaining about iTunes matters. iTunes doesn't seem to be able to regenerate the library list too well either. If I import from directory and give it my whole Itunes directory it misses half the files. Whats up with that Apple? (I know, I know, "buy a mac").

The ksh script segmentation fault

This is what got me started into writing this blog... The segmentation fault you never want to see. My sympathies if you have made it here searching for information on how to deal with seg faults.

The script was not mine, but the author is better than me at shell scripting (I prefer perl) so I was more of a victim trying to help out.

The idea of the script was to search recursevily through a list of directories looking for certain files and concatenating strings from those files together. It all worked well until code was added to speed things up by ignoring areas that had already been searched.

The odd thing was that some people had segmenetation faults, others not. And particular ways of running the script would fail and others not. Finally we even noted that running the script from a particular location would effect the results also.

Through the use of echo we managed to figure out that the variable containing a big long string was getting screwed up... but it was fine the last time we touched it. At some point in time it just got corrupted. Well I guess thats part of the deal with segmenetation faults, memory allocation problems will do things that logically (or at least within the realm of the script) should not happen.

The segmentation produced a core dump, but gdb (which I am far from being proficient in) couldn't seem to do anything at all.

Finally we found the problem, but why it mostly worked but on the odd occasion (but repeatable occasion) wouldn't is still beyond me.

The problem (we think - it went away anyway) was the clearing of a variable while in an until loop using that variable. However the variable was being set again before the loop ended.

Say for example:
until [ -z "${VAR} ] ; do
# some code
VAR=
# some more code
VAR=${SOME_OTHER_VAR}
done

It would seem to be one of two things.
1. The until loop uses a pointer to the label VAR. Which gets changed when it is set to equal null (VAR= ). Memory problems occur and everything goes strange.... But im not sure why they would do that.

or

2. I came across lots of references to segmentation faults when using unset, maybe setting to null uses the same code as unset? But I doubt it.

Anyway, it seems to work now.

The Start

Well this is the start. I want try and write about issues I solve at work and in my hobbies at home. I design ASIC's for a consultancy, so my ramblings will be about VHDL, Verilog, Vera (openVera), Perl and other random IT interests I have. As most engineers, I'm far from being an english lit graduate, so excuse my mistakes.