This project has moved and is read-only. For the latest updates, please go here.

Strange problem with MVVM and hid device

Jun 27, 2011 at 9:46 PM


I've got a very strange problem. I've made an usb hid device (pic18f2550 and DS1820).

I'm using Visual Studio 2010, C# , .NET 4.0 Framework, the latest version of MVVM light toolkit and an usb HID driver from Florent Leitner (facility to import functions from hid.dll [DllImport("hid.dll")], thread for reading etc... )

First, I've made very light interface using code-behind for testing the communication between my device and my computer. All fine, my device is detected and informations are read and can be displayed without problem. I've also decided, for learning using this toolkit, to implement the MVVM pattern.

I've made an model class for communitcation with my usb device, using same code as my first program. This class implement a default constructor who create the new UsbInterface (no souci) and enable the connection.

This constructor is tested with Visual Studio unit test, all fine, device is connected.

The interface have an button, RelayCommand and a Action who call the default constructor of my model when button is pressed. (View <-> ViewModel -> Model)

Using debug, the default constructor is called, the new UsbInterface is created, but the Connection always return false.

I really don't know what's append.

My usb device seems running well, USB HID class from Florent Leitner is ok using normal WPF application and my ModelClass.

But this very basic ModelClass(and Usb class) doesn't running on this pattern.

Does someone have any ideas ?




Jun 28, 2011 at 10:24 AM


Since the connection to the USB device is handled at low level, there is no real reason why the MVVM pattern would influence this in any way. There must be a disconnect somewhere.

Can I recommend that you try posting the question with more details to StackOverflow? In my experience this is the best way to get a good reply fast.



Jun 28, 2011 at 12:07 PM

Thanks for answer. I've made a new post on StackOverflow.