RSU

[Sunday, January 31, 2010]

Install GNU Radio on Ubuntu 9.10 (Karmic) - from scratch (Windows Machine).

26 comments

Installing GnuRadio on Ubuntu 9.10 tutorial with screenshots.

GnuRadio was a pain to setup until last year. I remember spending around 2 days to get it up and running. Like most open source softwares it lacks a solid documentation, but nevertheless it is a wonderful piece of software. Not long ago, GnuRadio folks made the whole installation process much easier by making it a Debian package for Ubuntu 9.04 and literally all you needed had to do was click "install" in the package manager.

A few days back, I upgraded one of my dev machines to Ubuntu 9.10 (Karmic), the latest version and ran into trouble. So that you don't waste time figuring out what I already did, here is a quick tutorial. Since few folks I know that wish to use GnuRadio but don't even have Ubuntu installed, I will start from scratch.

You can skip to Step 6 if you already have Ubuntu 9.10 up and running.



1. Goto http://wubi-installer.org and download Wubi 9.10

Wubi


2. Run Wubi.exe and when you get to the screen with options, choose the drive you wish to install Ubuntu 9.10 to [It will not effect your current OS in any way]. Choose the desktop environment as Ubuntu, and a username/password that you desire.

wubi installer
Image from: http://cache.techie-buzz.com/images/posts/wubi-installer.png



3. Click Install and Wubi will download a .iso image of Ubuntu that is right for your system. Don't be alarmed if you see amd64 in the torrent that it downloads. Ubuntu has one common 64-bit version which works on AMD/Intel.

4. You will be prompted to reboot. Do it, and you will see a new option in the boot menu. Select "Ubuntu", and in the next screen choose the first option.

photo-1.jpg Ubuntu Boot option after wubi install


5. Ubuntu will complete the installation. When you get to the login screen use the password that you entered in Step 2.

photo-2.jpg



6. You should now have your brand new Ubuntu 9.10 up and running. Now the fun begins. Lets install GnuRadio. Open the Synaptic Package Manager.

[Off topic: In case you are wondering how to make your Ubuntu look slick like this, leave a comment below and I will post a quick tutorial]
MyScreenshot1.png

7. Goto Settings > Repositories > Other Software and click Add.

8. Enter the following in the APT line and click Add Source. Do this for all three below.


deb http://gnuradio.org/ubuntu stable main
deb-src http://gnuradio.org/ubuntu stable main
deb http://mirrors.kernel.org/ubuntu jaunty main universe
Thanks to jne for pointing out the last repo.

adding package source to ubuntu

The list should look something like this:

repo.png


9. Click Close and back on the main window click the reload button. [Reloading is important for the packet manager to load new packages].

reloading synaptic package manager


10. Now search for gnuradio and in the results, right click on gnuradio and click Mark for Installation. Do the same for gnuradio-companion.

MyScreenshot3.png


Screenshot-3.png

Once selected, the package manager will also mark dependencies for installation. All packets that are marked for installation are highlighted green.
Screenshot-5.png


11. Click Apply and apply on any confirmation dialog popups.

Screenshot-6.png



12. If the installation goes smooth, you should now have GnuRadio Installed!

13. To test our installation, open a new terminal window and run the following command:
grc


GRC should open up.

Screenshot-7.png


14. Now make a flow graph to test it out. Simply use Audio Source or Signal Source and hook it up to the FFT or Scope graphical sinks.

Screenshot-8.png




15. Hit Execute button (the one with an icon of gears). And Voila! it works!

Screenshot-9.png


16. Congratulation! Now enjoy a cup of Hot Chocolate and have fun with GnuRadio :)

Two sample GRC flowgraphs to get you started (Right click and Save As..):

AudioVisualizer.grc
VariableSignalSource.grc

If you find a mistake or something doesn't work, please feel free to leave a comment so that I can fix it.

[Thursday, December 3, 2009]

How To Get Spotify for Free in Any Country (Including US)!

0 comments

Spotify is an online music streaming service done right. In my opinion, it is far more better than LaLa, Pandora, Last.fm or similar online music services. For starters, it has virtually no buffering delays, and most importantly it has tons of Hindi music, which is something that I find lacking in most popular music services. Anyone familiar with iTunes interface will feel at home as Spotify has a similar layout, playlist support, album arts and search by artist, album or song name.


Alright, so Spotify is great but unfortunately its free version is invitation only, and to make it worse its available only in a few european countries.Visiting the Spotify website from outside any of the allowed countries stumps you with a "Why is Spotify not available in my country?" message.


Picture 4.png


But here is the good new! You can get access to Spotify, for FREE with NO invitation, in ANY country. I have been using Spotify for free for a few weeks now. It seems the restrictions are applicable only until you create an account, after that Spotify doesn't care where the hell on the globe you are. So if you can get past the account registration, you should be good to go! Here's how you do exactly that:


1. Goto Dave Proxy



2. Enter https://www.spotify.com/en/get-started/ in the text box and hit Go. If you see a warning screen, press Continue.


Picture 5.png


3. Voila! You should see a registration form that allows you to create an account. [If it doesn't work, then either Spotify fixed the hole or banned Dave Proxy. Trying another proxy should probably work. See note at the end.]



Update: Forgot to mention that you should enter UK as country use a UK Zipcode to register. (example postal code: SE22 9EP).


Picture 6.png


4. Once you have an account, Download Spotify client.




Picture 7.png


5. Enjoy!   




Picture 8.png


Note: Incase Spotify folks decide to ban the Dave Proxy, try using another proxy from Here.



[Thursday, July 9, 2009]

iPhone Silent Mode/Switch state detection using SDK.

1 comments

I wanted my app to "buzz" only when the phone was in silent mode, or in other words, the button was set to vibration. To find this out pragmatically you can use the following code snippet, that I figured out after some struggling with the API.



CFStringRef state;
UInt32 propertySize = sizeof(CFStringRef);
AudioSessionInitialize(NULL, NULL, NULL, NULL);
AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);
if(CFStringGetLength(state) > 0)
NSLog(@"Vibration Off");
else
NSLog(@"Vibration On");

The string returned by querying the property kAudioSessionProperty_AudioRoute can be blank or Speaker. It can also be Lineout depending on if the phone is docked or not. So if its blank, length is 0, and hence no audio route is currently available. i.e. silent mode is active.

[Monday, July 6, 2009]

iPhone Programming: Creating Network Socket Connections

5 comments

My current project involves creating an iPhone application that communicates with another application (hosted on a PC). Ideally, I wanted to do this via Bluetooth, but like a lot of other (useful) stuff, Apple's API doesnt expose it for any communication other than peer-to-peer (iphone to iphone) and audio gateway. So using that was out of question, though my personal side project is to write a program for PC that fools the iphone into thinking that its talking to one of its own. So for now I am using the WiFi/Network connection.

My goal: Create a simple app, that connect to a TCP host, sends "Hello World" and closes the connection.

Being a complete beginner in iPhone development, my first step was check out the Apple's official Networking guides. I found and followed Cocoa Streams how-to. This document is filed under iPhone Reference, and can be accessed from the developer webpage. After hours of struggling with the seemingly simple code, I realized that iPhone OS does not support +getStreamsToHost:. I have filed a bug regarding this document's classification. After some chitchatting and more documentations, I found the correct way to create a connection is to use the CFNetwork framework, which is well explained by Apple here.

Following the sample code, I created an app that uses CFStreams to create a socket connection.



-(IBAction) connect_button {

CFWriteStreamRef writeStream = NULL;

CFStringRef host = CFSTR("10.212.97.159 ");
UInt32 port = 22701;

CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, host, port, NULL, &writeStream);

CFWriteStreamSetProperty(writeStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);

if(!CFWriteStreamOpen(writeStream)) {
NSLog(@"Error Opening Socket");
}
else{
UInt8 buf[] = "Hello WOrld!";
int bytesWritten = CFWriteStreamWrite(writeStream, buf, strlen((char*)buf));
NSLog(@"Written: %d", bytesWritten);

if (bytesWritten < 0) {
CFStreamError error = CFWriteStreamGetError(writeStream);
/** How do I print out description? All i get is -1 here. i.e What is perror() equivalent? **/
}

}

CFWriteStreamClose(writeStream);

}


Very simple and familiar looking code, so this should definitely work. Right? Well no it did not. I kept getting an error, which is stored in CFStreamError type. Problem is I had no way of interpreting that error. The CFError type is very well documented, but CFStreamError has a lot of loose ends. I spent quite a time trying to figure out what the error meant so that I could debug my application.

Update: The above code works! I still do not know how to print out the description of CFStreamError, but I found the error when I rewrote the code. The culprit is Line 5. Do you see it? :). Its the whitespace after the IP. Damn! That little error wasted atleast a few hours of my coding time.

Finally, I gave up on apple's way of networking and decided to do it the classic C-style way. I found an amazing library called the SmallSockets that uses the linux style of sockets under the hood, wrapped inside a Obj-C class. Downloaded it, added the headers file in my project and Voila!, it worked! All under 5 minutes!


-(IBAction) connect_button {
Socket *socket;
int port = 22701;
NSString *host = @"10.212.97.159";

socket = [Socket socket];
@try{
[socket connectToHostName:host port:port];
[socket writeString:@"Hello World!"];
//** Connection was successful **//
//[socket retain]; // Must retain if want to use out of this action block.
}
@catch (NSException* exception) {
NSString *errMsg = [NSString stringWithFormat:@"%@",[exception reason]];
NSLog(errMsg);
socket = nil;
}

//** Disconnect **//
[socket close];
}


Though my project is now up and running with 2-way network comm, I still want to get back to the CFNetwork and figure out where I went wrong, and try to implement a bare bone hello world app, the apple way.