Thursday 21 August 2014

Viewing the .net Debug Log using DbgView

Every day is a learning day, and today I needed some way for my client to view the debug log for the Debug Version of an Application I created to test a piece of hardware which was acting up.

After a little searching around I came across the Microsoft Sysinternals DebugView application;

http://technet.microsoft.com/en-us/sysinternals/bb896647

Microsoft describe this DebugView as;

… an application that lets you monitor debug output on your local system, or any computer on the network that you can reach via TCP/IP. It is capable of displaying both kernel-mode and Win32 debug output, so you don't need a debugger to catch the debug output your applications or device drivers generate, nor do you need to modify your applications or drivers to use non-standard debug output APIs.

So, in order to view the Debug Log I had already created in my App was as simple as;

  1. Download the DebugView Application from http://download.sysinternals.com/files/DebugView.zip
  2. Extract the contents of the ZIP to a location on your hardrive
  3. Run the DebugView Application as an administrator
  4. Run your Application
  5. Your Debug Messages will appear in the Window;

 

image

If you find that some other applications are also emitting debug information, then you can setup a filter, so that only your application is shown;

  1. Next to the Debug Messages for you application will be a number in square brackets. This is the PID of your application. Take a note of this number.
  2. Press the Filter/Highlight button;

    image

  3. The Filter Highlight dialog will be shown;
  4. In the Include Box, remove the Star and enter your PID;

    image

  5. Press OK, and now you should only see the debug output from your application.


It’s worth noting that each time you start your application, it’s PID will change, so bear that in mind as your Filter will need adjusting to suit of course. You can either remove the filter to find your PID, or use Task Manager.

Very handy.

Friday 13 June 2014

Freeing up Reserved / Allocated Serial ports

In my line of work, I spend a lot of time interfacing to devices using a Serial (RS232) connection. This often necessitates the use of USB to Serial port converters.

A frustrating issue I often come up against is that, each time a new one of these converters is attached, or indeed an existing to a new USB port, it allocates itself a new port.

This port is then not automatically freed again by Windows, which means that you end up with a bunch of reserved serial ports allocated to converters which are no longer attached or used. Further, you cannot ordinarily see USB devices which have been removed from the system, so manually removing the devices isn’t simple either.

To get around this, you can perform the following steps to allow you to show the removed USB devices, and uninstall them, freeing the ports, and allowing you to reallocate your device com ports;

  1. First, remove any USB to Serial Converters you may have attached, as these will have live allocated COM ports.
  2. Then. launch a Command Prompt as Administrator, by right clicking on the Command Prompt shortcut, and selecting “Run as administrator”;

    image
  3. We now need to allow the Device Manager to let us see removed USB devices. So, type; set devmgr_show_nonpresent_devices=1 and hit Enter… Don’t worry, nothing will be shown in response to this;

    image
  4. Next we need to launch the Device Manager, so type; start devmgmt.msc and hit the Enter key, which will bring up the Device Manager.
  5. Now we want to show all the Hidden USB devices, so click the View menu and select “Show hidden devices”;

    image
  6. You’ll now see that a bunch of extra nodes have been added to the Device tree. The one we’re interested in is the Ports (COM & LPT) section. So expand this node by clicking the small arrow to the left of the label;

    image
  7. You should now see a selection of devices which appear slightly greyed out. Each device will indicate it’s allocated COM port. All we need to do is remove each of these devices, freeing up its COM port. This is achieved by simply selecting the device you want to remove, and either hitting the Delete key on your keyboard or going to the Action menu and selecting Uninstall.
  8. Each time you attempt to uninstall a device you will be asked to confirm the uninstallation. There will also be a checkbox to allow you to “Delete the driver software for this device”. You can leave this un-ticked, as we know we’ll need to use this device in the future.

    image
  9. You should now be able to re-connect your USB to Serial Port Converters, watch each one get reinstalled, where WIndows will automatically assign the lowest COM port available.
  10. You can of course select your own choice of COM port for each device. This is achieved by right clicking on the device who’s COM port you wish to change and selecting Properties;

    image
  11. This will bring up the Device Properties window. From here select the Port Settings Tab, and press the Advanced Button;

    image
  12. This will show the Advanced Settings for the COM port. The COM Port Number can then be selected from the “COM Port Number” dropdown;

    image
  13. Select your COM port, And OK all the open Windows.

I hope this helps somebody else as much as it helped me!

Friday 30 May 2014

XBMC–Some YouTube videos refuse to play

I noticed that a few YouTube videos refused to play. Having searched around, I came upon a thread in the XBMC YouTube plugin code repository;

https://code.google.com/p/youtubexbmc/issues/detail?id=95#c217

martinpe...@gmail.com  linked to an updated YouTubePlayer.py file;

YouTubePlayer.py

Copying this file to your XBMC Addons directory, over the existing file, fixes the problem nicely.

Evidently, some YoutTube videos have a ‘$’ in the JS function name, which confuses the original plugin. This plugin replaces the ‘$’ in the function names with ‘_S_’

Hope this helps somebody!