Premise [download] Driver: USB-UIRT

Motorola Premise

123

Senior Member
index.php
File Name: Driver: USB-UIRT
File Submitter: 123
File Submitted: 4 Feb 2009
File Updated: 23 Feb 2009
File Category: Premise
Author: 123
Contact: PM me
Version: 0.6

Introduction
The following driver (spUSBUIRT.dll) enables Premise Home Control to send and receive IR codes via a USB-UIRT device.

Version (V0.6) provides the following functions:
  1. Send an IR code, in Pronto format, via any one of the USB-UIRT's three zones (Left, Right, Center) or via all zones concurrently.
  2. Receive IR codes, in UIR format, via the "Center" zone (represents the IR receiver on the front of the device).
  3. Learn IR codes, in Pronto format, via the "Center" zone.
  4. Support multiple USB-UIRT devices.
  5. Send an IR code continuously ("ContinuousSend").
  6. Locks command modes (i.e. cannot request Learn mode while performing ContinuousSend).
Source code (C++) is also available (PM me) to anyone who wishes to see how it was constructed or to enhance it. You will need Visual Studio 2005 (not the Express version) and the Premise HSDK in order to compile the source.

Installation Notes
Before installing the Premise USB-UIRT driver, ensure the USB-UIRT's Windows driver is installed correctly (see the manufacturer's instructions).

Install the Premise USB-UIRT driver as follows:
  1. Extract the DLL file from the attached zip archive.
  2. Copy spUSBUIRT.dll to C:\Program Files\Premise\SYS\bin\devices
  3. In Premise Builder, select File > AddIns.
  4. Checkmark the USBUIRT selection and click OK.
  5. In the Shortcut Bar, click Devices.
  6. Right-click USBUIRT and select New > UUIRT

If you plan to use multiple USB-UIRT's, you must assign each device a unique name using the "uurename" utility from the manufacturer. A USB-UIRT's default name is "USB-UIRT". Here's how to rename it to "USB-UIRT-2":
  1. Plug in the USB-UIRT you wish to rename. Ensure all others USB-UIRT devices are disconnected.
  2. Stop any applications using the USB-UIRT.
  3. Run "uurename" from a command shell.
  4. When prompted to rename the device, choose 'Y'es
  5. Enter the number '2'.
  6. Disconnect then reconnect the device to initialize the new name.

Please post questions and bug reports in the discussion thread associated with this Download post.

Click here to download this file
 
flobik,

I'm very close to completing the multi-device version of the driver (potentially with support for ContinuousSend). I'll send you the latest version when it is finished (end of the week). Send me a PM, containing your email address, and I'll send you the zipped Visual Studio project when it is ready. If you simply want to inspect the code, I can send you the main ".cpp" file instead of the entire VS project. Let me know what you need.

To compile the source code, you'll need Visual Studio 2005 (C++) and the Premise HDSK.
 
Will wonders never cease ...
  1. Version 0.6 of the USB-UIRT driver passed all tests on my development PC. :)
  2. It failed to display debugging messages on my test PC. :p
  3. It won't load on a Tablet PC . :)
Sheesh.

FWIW, version 0.5 also refuses to load on a Tablet PC. Premise generates an alert indicating the "Driver cannot be registered". Thinking it was due to a duplicated GUID somewhere, I reset Premise server to a clean slate and tried again. No luck. I will try to run the "Hello World" driver on the Tablet PC to determine if this is a problem with all home-brew drivers or limited to my USB-UIRT driver. Either way, I have no plans to chase this bug down, so the driver is officially incompatible with Win XP Tablet Edition. Sorry.

As for the AWOL debugging messages, well, V0.6 uses a function called "Systrace" I found in one of the SDK's header files. Essentially, it's a wrapper function for OutputDebugStringW so it *should* work as well as in V0.5 (... not!). Kind of ironic because I added extensive debugging messages to help track down potential problems ... yet it is the debugging mechanism that has failed. :huh:

Version 0.6 offers more functionality than V0.5 yet is substantially smaller (64K versus 80K). For future driver writers, the key space saver was to avoid inheriting from the CPremiseBufferedPortDevice class. This driver does not communicate via a serial or network port (it talks via functions in a manufacturer-supplied DLL) therefore it has no need for the extensive port and data handling functionality provided by CPremiseBufferedPortDevice. I've only scraped the surface of this class but it appears to provide everything you'd possibly need including:
  • Reports the serial/network port's current state.
  • Automatically resets the port if the driver becomes unresponsive.
  • Buffers data transmission and reception.
  • Data buffer handling (purge, retransmit, etc)
  • Acknowledgement Timer; informs you if a transmitted command has not been acknowledged by the device within a specified time frame.
  • Heartbeat Timer; can be used to periodically poll the device(s).
The only thing I needed was a parent class called CPremiseSubscriber that allows my driver to subscribe to property changes (i.e. informed of state changes to Send, Learn, ContinuousSend).

The guys who designed this architecture really knew their stuff!

ADDENDUM
My mistake; the debug messages aren't displayed on my development PC either. What I had tested on the two PCs wasn't the same version so I had different results. I now realize that I'm not using Systrace correctly. Another example of RTFM! Should be a quick fix ...
 
Version 0.6 of the Premise USB-UIRT driver is now available.

New Features
  1. Supports multiple USB-UIRT devices.
  2. Can transmit an IR code continuously (ContinuousSend mode).
  3. Locks out conflicting command modes (i.e. prevents entering Learn mode if the device is in ContinuousSend mode).
Handy things to know
  • Unsupported Properties
    The AutoClip and EnableLogging properties have been removed from the driver's UI because I have no plans to support them.
  • Use V0.6
    If you are using V0.5, I recommend you uninstall it and use V0.6. Even if you don't need V0.6's added features, it employs far more error-checking than V0.5. Uninstall V0.5, restart the Premise service (prkernel.exe) and then install V0.6. If you don't restart the Premise service it may have a lock on the old "spUSBUIRT.dll" file and prevent you from overwriting it.
  • Don't copy-paste driver instances
    To create new driver instances, right-click USBUIRT and select "New > UUIRT". This is the usual way its done with all drivers. Do not copy and paste an existing driver instance! It will create a "zombie" ... a non-functional driver instance that only appears to be OK. I haven't figured out how to programmatically prevent an end-user from copy-pasting an existing driver instance ... so just don't do it.
  • Ensure USB-UIRT device is connected
    When you create a new driver instance, the USB-UIRT device must be physically connected to the PC and its Windows driver must be installed. If not, the driver instance will show it failed to connect and that's the end of that. The driver instance will not attempt to connect to the device if you plug it in later.
  • USB-UIRT device will be monitored
    The driver will query a properly installed USB-UIRT device every 30 seconds. If there is no response, it will disable the "Connect" property and try to reestablish the connection with the device every 30 seconds thereafter.
  • Debug to see more
    If you enable the driver's Debug property, it will display informative messages about its operating state in the Windows Debug Console (you need DebugView to see them). Enable it if you suspect the driver is misbehaving or if you're curious about what it's doing. The Premise driver's debugging messages always begin with "[USB-UIRT]". The USB-UIRT's Windows driver also generates debugging messages (always visible).
 

Similar threads

C
Replies
0
Views
1K
chucklyons
C
Replies
16
Views
3K
chucklyons
C
C
Replies
2
Views
1K
chucklyons
C
Back
Top