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.

2 comments:

  1. It's very interesting because I try to connect to this scale using "Prolific USB-to-Serial Comm Port" and opening COM port but protocole seems protected : never same value between start and stop characters. I didn't find any information on this problem and my weigh didn't answer to email.

    Have you suceed to write a complete code to connect and reveive data from this scale directly on USB port ? If it is, could share it please ?

    Regards,

    Andevia

    ReplyDelete
    Replies
    1. Andevia, in the end, I didn't write code to connect to this device, I simply used the scale as a 'Keyboard Wedge' where pressing the Send button pushed the weight into the keyboard buffer.

      Delete