Raspberry Pi Wifi dropping connection

Started playing with my Raspberry Pi this weekend and noticed that the wifi connection would not stay up for long when connected through SSH. After some digging online I found that the wifi was getting put in sleep mode. Here’s how to fix it:

  • Create a new file named 8192cu.conf at the following location /etc/modprobe.d/8192cu.conf
    sudo nano /etc/modprobe.d/8192cu.conf
  • Write the following command
    options 8192cu rtw_power_mgnt=0 rtw_enusbss=0

    (This makes sure that the power management is turned off thus preventing the dongle from going to sleep mode.)

  • You can go further and ensure that the connection remains up and stable by sending a ping request from your Pi to the router using crontab:
    crontab -e

    (Adds a new entry to crontab.)

  • Enter the following at the end of the file:
    */1 * * * * ping -c 1 192.168.1.2

    (Change the 192.168.1.2 to the IP of your router. The IP of the router can be found by opening a command prompt in Windows and running the ipconfig command and checking the number besides “default gateway“.)

If you don’t have a Edimax wifi dongle you may have to find how to disable the power management for your device.

Source: http://www.xbmchub.com/forums/raspberry-pi-discussion/8037-your-wifi-dongle-dropping-connection-mainly-edimax-ew-7811un.html

CLIArgsMadeEasy2

CLIArgsMadeEasy is back with a long overdue update. This is the third major release of this extension although the second one didn’t receive a major version number.

This is still an alpha version. Please report back any bugs you may find.

New features

  • Dropped toolbar support in favour of toolbox which makes it more easy to manage and edit your command line. Open it inside View -> Other Windows -> CliArgsMadeEasy
  • Remove or change between command line arguments with a click of a button.
  • No more clogging the windows registry, data gets saved in .suo file.
  • Detect startup project inside solution folders.
  • Compatible with VS2012 and VS2013.

Changelog

  • v1.0.5:
    • Added ability to duplicate and edit (buttons were added for each CLI arguments.)
    • Changed the way CLI args get added and changed.
  • v1.0.4:
    • Fixed VSIX problem for VS2012 installation.
    • Fixed bug where deleting command line arguments wouldn’t set them in Visual Studio.
    • Fixed bug where we could add the “Type some arguments”.
    • Changed default shortcuts:
      • ctrl+alt+0 – open CLIArgsMadeEasy window.
      • ctrl+alt+9 – focus on command line arguments.
      • ctrl+alt+8 – focus on project filter.
      • ctrl+alt+7 – focus on command line history.
  • v1.0.3:
    • Fixed VSIX installation for VS2013. Common installer for both VS2012 and VS2013.
    • Fixed bug where changing CLI Args through project properties didn’t update the extension.
    • Added empty CLI args when pressing enter with no arguments in the box.
  • v1.0.2:
    • Added key shortcuts:
      • ctrl+alt+0 – focus on command line arguments.
      • ctrl+alt+9 – focus on project filter.
      • ctrl+alt+8 – focus on command line history.
      • tab – focus next command line.
      • enter or space – select current command line.
      • delete – removes current command line.
      • escape – set focus on command line arguments.
    • Fixed bug detecting when startup project was deleted.
  • v1.0.1:
    • Removed erroneous menu entry from Visual Studio under Tools – You can find the tool window in: View -> Other Windows -> CliArgsMadeEasy
    • Command line arguments text box expands to show full text.
    • Added new icon.

Description

Command Line Arguments Made Easy (CLIArgsMadeEasy) is a Visual Studio extension that eases the access and change of the startup project’s command line arguments. Instead of having to go to project properties or instead of using the command window to run your program with different arguments, CLIArgsMadeEasy adds a toolbox for you to add and edit your custom arguments.

If you like this add-in and want to support it, donate by clicking in the button:

Download

Download CLIArgsMadeEasy2 v1.0.5 alpha here. (for Visual Studio 2012 / 2013)

Many thanks to Diogo Teixeira (aka fozi) for the add-in idea and testing of the program. And I also have to thank Matt Phillips for showing interest in the add-in which inspired me to make a second release.
Thanks to everyone who’s been reporting bugs and helping me building a stable version of CLIArgsMadeEasy.

Realtime Bus

I’ve used TTC (Toronto Transit Commission) to get to work and move around in Toronto. They implemented a good service where each bus is equipped with a GPS device transmitting its location and through today’s technologies that information reaches the internet and the phone of each one of us accurately and in real-time.

The apps available for WP7 didn’t have all the features that I wanted so I decided to build my own app.

Some features I wanted in my app that didn’t find in others:

  • Fast access to favourites
  • Map with routes
  • Information for multiple cities
  • Alerts (TTC only)

RealtimeBus_3 RealtimeBus_1 RealtimeBus_4

You can find the application here: http://www.windowsphone.com/en-us/store/app/realtime-bus/69bd4a05-65b4-4633-b40d-7d18d9f46edc

How to debug a Windows 8 app upgrade in Visual Studio

Some times it’s useful to debug if your new update breaks anything to users who have the previous version of your app. The process to debug this is not very straightforward but here it is:

– Create a package with first version (right click on the project -> store -> create package)
– Install the package.
– Run app and make sure it saves some user data.
– Make a new package with second version.
– Install package.
– On the Start menu, search for Debuggable Package Manager and then start it.
– A PowerShell window properly configured for the AppxDebug cmdlet appears.
– To enable debugging of an app, you must specify the PackageFullName identifier of the app.
– Type Get-AppxPackage at the PowerShell prompt (to view a list all apps that includes the PackageFullName.)
– At the PowerShell prompt, enter Enable-AppxDebug PackageFullName where PackageFullName is the PackageFullName identifier of the app.
– Run app
– Launch Visual Studio
– Go to Debug -> Attach to process…
– In the list of available processes select the one called WWAHost.exe and with the name of your app in the Title column.

UVideos Xbox Application

I moved to Canada last summer by the end of July to join Digiflare. As soon as I arrived I was assigned to work as a Lead Developer on my first Xbox project. The project had to be ready for Black Friday (Nov 23rd) so it had to be launched on November the 20th because new Xbox application roll out on Tuesdays.

It was a tough project but we we’re able to deliver successfully on time.

 

You can find more information on the project in this page: http://www.xbox.com/en-US/live/partners/univision

It has been very interesting to learn the insides of a Lakeview application and I’ll keep at it in the near future.

“New” technologies (Discovering the TI world)

Today’s post describes my adventure into the world of TI (Texas Instruments) programming. A little bit out of its time but nevertheless interesting to anyone who likes to learn new things and open their horizons.

My cousin is a few months away of completing his Civil engineering degree and is really interested in TI programming, doing scripts that help him solve problems really fast instead of having to do them manually (most useful in exams). He does all the programming in TI-Basic, a language similar to Basic but specific to TI calculators and like most (if not all) of these interpreted languages, they don’t provide any security if you want to sell your programs. Thus he turned to C programming. Now, C is a whole new beast when compared with this TI-Basic language and it’s much harder to start doing some interesting things without your programs crashing all over the place.

He asked me for help but having no knowledge of this TI-Basic or C tools/libraries/APIs available for these calculators and without access to internet and limited documentation and samples I wasn’t able to get complete the program although I did manage to make half of it. This was a 4 hour marathon that started around 22h30 till 2h30 and I had to admit defeat at the time since I was very tired but I promised to help him to finish the program. I don’t have a TI calculator so I needed to find a way to test it in my PC and fortunately there is an IDE along with an emulator and ROM image available for free on the internet. I’ll list what’s needed to be able to run and the debug C programs for TI calculators because it took me a while to get everything up and running due to incompatible versions of software.

  1. Download and install TIGCC 0.96 beta 8 (Unofficial version)
  2. Download and install TiEmu 3.02a
  3. Download TI Voyage 200 ROM image (my cousin’s model)
  4. Create a project in TIGCC
  5. Run the project (Debug –> Run)
  6. When the TiEmu wizard appears select “You have downloaded a FLASH upgrade on the TI website”
  7. Then select the TI Voyage 200 ROM image you’ve downloaded before.

Voilà! If everything went well you should see the program running on the emulator.

If you want to debug your project, follow these steps:

  1. Project –> Options
  2. Select the “Compilation” tab and then the option “Generate debug information”
  3. Run the project (Debug –> Run)

You should see new windows open if you followed these steps. These are the debug windows that will help you find your bugs.

Here are a few snippets I had to discover here and there through samples / documentation:

/* Retrieves strings passed into the program */
ESI argptr;
int argtype;
char *str;
InitArgPtr (argptr);
while ((argtype = GetArgType (argptr)) != END_TAG)
{
  if (argtype == STR_TAG)
  {
    str = GetStrnArg(argptr);
    printf("%s", str);
  }
  else
    break;
}
/* Get a variable from TI-Basic into C */
SYM_ENTRY *sym_entry = SymFindPtr (SYMSTR ("variableName"), 0);
if (!sym_entry)
  return FALSE;
ESI expr = HToESI(sym_entry->handle);
int argType = GetArgType(expr); /* Retrieves the type of the expression */
long num = GetIntArg(expr); /* Retrieves an integer if the expression holds an integer (positive or negative) */
/* Directly from TIGCC documentation: Run a TI-Basic program or statement from C */
char fname[25];
HANDLE h;
strcpy (fname, name);
strcat (fname, "()");
push_parse_text (fname);
h = HS_popEStack ();
TRY
  NG_execute (h, FALSE);
FINALLY
  HeapFree (h);
ENDFINAL

Including tigcclib.h will make sure that you have all the TI library functions available in C. For the last snippet you need to follow these steps if you have an error regarding push_parse_text function:

  1. go to Project->Options
  2. select the “Compilation” tab
  3. click on “Program Options…”
  4. select the “Operating System” tab
  5. and set the “Minimum AMS Version” as 1.01

Geo Reminders for WP7

I wanted to build this app since I bought my WP7 but unfortunately it wasn’t possible to have background tasks running on the phone. It was great to know that Mango would bring this functionality to the Windows Phone and I started working on the app right away.

Since I program these WP7 apps outside work it takes a while to get them done. Geo Reminders allows us to program alarms or reminders depending on our location. This is useful to set a reminder for the next time you visit a place for example. Or imagine that you left a book at work and you want to bring it home, you set the reminder that will only go off when you arrive at work so that way you can grab the book and put it near your stuff when you leave.

Here are some screen shots:

georeminders_1georeminders_2georeminders_3

georeminders_4georeminders_5georeminders_6

georeminders_7georeminders_8

The application is available since early March in the marketplace. You can download it here.

Kinect Calibration

This program adjusts Kinect to better see the user, this way the user doesn’t have to move back or forward (unless Kinect’s angles aren’t enough to see the user). I think this is a useful thing to have when you start your Kinect application.

The code is very simple to follow. Use Kinect’s elevation angle to change the Kinect’s “view” and track the user in sight. For each angle count how many joints Kinect is tracking and save that angle as the best if we reach a new maximum number of tracked joints.

void KinectSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
	// Get skeleton information
	using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
	{
		if (skeletonFrame != null && m_skeletonData != null)
		{
			skeletonFrame.CopySkeletonDataTo(m_skeletonData);
		}
	}

	m_curTime = m_watch.ElapsedMilliseconds;

	if (m_calibrationState == CalibrateState.GoingDown)
	{
		// If the sensor reach its lowest angle, let's do a full scan from min angle to max angle.
		if (m_curTime >= WaitTime)
		{
			m_watch.Reset();
			m_watch.Start();

			m_bestAngle = m_kinect.MinElevationAngle;
			m_maxNumTracked = 0;

			m_calibrationState = CalibrateState.GoingUp;
			m_kinect.ElevationAngle = m_angles[m_curAngleIndex++];
		}
	}
	else if (m_calibrationState == CalibrateState.GoingUp)
	{
		if (m_curTime >= WaitTimeGoingUp)
		{
			m_watch.Reset();
			m_watch.Start();

			// If we scanned all the angles, lets adjust kinect to the best angle.
			if (m_curAngleIndex > m_angles.Length - 1)
			{
				m_calibrationState = CalibrateState.GoingBest;
				m_kinect.ElevationAngle = m_bestAngle;
				return;
			}

			m_kinect.ElevationAngle = m_angles[m_curAngleIndex++];
		}

		// For each skeleton, count the number of tracked joints and save the best
		// angle when the number of tracked joints is greater than previous values.
		foreach (Skeleton skeleton in m_skeletonData)
		{
			if (skeleton == null)
				continue;

			if (skeleton.TrackingState == SkeletonTrackingState.Tracked)
			{
				//TODO: Improve algorithm by using the number of inferred joints.
				int numTracked = 0;
				int numInferred = 0;
				foreach (Joint joint in skeleton.Joints)
				{
					if (joint.TrackingState == JointTrackingState.Tracked)
						numTracked++;
					else if (joint.TrackingState == JointTrackingState.Inferred)
						numInferred++;
				}

				if (numTracked >= m_maxNumTracked)
				{
					m_maxNumTracked = numTracked;
					m_bestAngle = m_kinect.ElevationAngle;
				}
			}
		}
	}
	else if (m_calibrationState == CalibrateState.GoingBest)
	{
		// Just wait until kinect adjusts itself to match the best angle.
		if (m_curTime >= WaitTime)
		{
			m_watch.Reset();

			m_calibrationState = CalibrateState.Idle;
			m_kinect.SkeletonFrameReady -= KinectSkeletonFrameReady;

			// Reset Kinect state.
			DisableStreams();
			EnableStreams();

			// Signal that we finished the calibration.
			if (OnCalibrationComplete != null)
				OnCalibrationComplete();
		}
	}
}

You may notice two things about the code:

  • First is that I’m using time to control between Kinect movements. The reason for this is that if we try to compare Kinect with the angle we set, we might not get the same value for different reasons (Kinect sensor is not 100% accurate or it couldn’t physically rotate the sensor to that exact angle).
  • And second is the fact that I’m only scanning the skeleton for some angles. I don’t know if this is a Kinect’s limitation or if I did something wrong in the code but I couldn’t track any joints while Kinect was moving. So what I did was move the sensor between some angles and wait there a bit to count the bones for each one of those angles.

Known limitations:

  • it only supports 1 user at this moment;
  • the scanning process is not ideal.

Download:

Kinect Calibration (13Kb)