Wednesday 21 December 2011

Connecting to the USB My Weigh Ultraship U2 scale using Visual Studio C# 2010 - Part 2

Having discovered the Vendor ID (VID) and Product ID (PID) of the My Weigh Ultraship U2 USB scale by examining the devices connected to the PC using the Windows Device Manager, I can now use a USB Sniffer to intercept and log the data being exchanged between the USB scale and the Windows PC.

The sniffer I used was called USB Sniffer and is based on an earlier project that was called USB Snoopy. This program lets you view all of the USB devices connected to your PC and shows their VID and PID so that you can quickly identify the exact device you are interested in looking at.

To use the USB Sniffer/Snoopy you install it and then, I found, that I had to run it as administrator in order for it to be able to access and install the relevant services that it needed to view the data. You run it as an administrator by right-clicking on the SnoopyPro.exe file and selecting the Run As administrator option.

When the program starts, choose the View menu and select the option to Show USB Devices which will show a list similar to the one below. You can see our Ultraship U2 USB highlighted in blue with VID 04D9 PID E002. There are actually two entries for it that are identical.


In order for Snoopy to be able to intercept the data between the USB device and the PC, you need to install services that will capture this data. The first thing to do is, from the menu options at the top of the window listing your USB devices, choose the File, Unpack Drivers option. Next choose the File, Install Service option.

Snoopy is now prepared and you can select the device that you want to monitor. Do this by right clicking on the entry in the list of USB devices and select the Install and Restart option. The list of devices should be updated showing that monitoring for the device has been installed, as shown below.


As soon as you do this, the original program window opens a USB Log window that will be used to record and display the data exchanged.



The data is not displayed live as it comes in, but the window does update to show the number of packets that have been logged. To see the data choose the Tools, Analyse Log option. This will show a summary of all of the packets that have been transferred between the PC and the USB device.


And finally, to see the actual data exchanged, you can click on the + button at the start of each row in the log to show the full detail of the data exchanged.


In the screenshot above, I have selected the exchange containing the weight information which we can see has transferred 8 bytes of information, 2b 20 20 30 2e 30 30 30. This was created by pressing the send button on the Ultraship U2 USB scale. The weight was at zero when the button was pressed.

Remember to uninstall and restart your USB device when you have finished interrogating it. Do this via the USB Devices list by right clicking on your device and choosing the Uninstall and Restart option. Then, choose the File, Uninstall Service option before exiting out of Snoopy altogether.

Friday 16 December 2011

Connecting to the USB My Weigh Ultraship U2 scale using Visual Studio C# 2010 - Part 1

I'm trying to figure out how to connect to a My Weigh weighing scale, the Ultraship U2 to be specific. I'm going to want to connect to it and control it using Visual C# 2010. This post details my findings as I worked through the issues of identifying what I would need to find out in order to do this.

I'll say from the start of this post that if you have any additional information about this device and about how to connect to it, make sure you let me and everyone else know in the comments.

Identifying the Ultraship's Vendor ID and Product ID


The My Weigh Ultraship U2 is a USB HID (Human Interface Device) and as such its Vendor ID and Product ID can be found in the Device Manager of your Windows PC. 

Connect the scale to your PC and on Windows 7, open your Start Menu and right click on Computer and select Properties. This opens the Control Panel -> System and Security -> System Page where you need to select Device Manage from the top left.

From the Device Manage window that opens, it is easiest to reorganise the view of the devices by going to the View menu and selecting Devices By Connection.


The Ultraship U2 scale is the HID-Compliant Device that you can see highlighted in the image above. You can right-click on it and select properties, then select the details tab and where you see the Property drop down, select Hardware IDs.


From this Device Properties window, you can now see the VID and PID for the scale.
  • VID 04D9
  • PID E002
Now that I know VID 04D9 PID E002, I need to find out how to access the device using from Visual C# 2010. Any suggestions?