Posts Tagged “usb”

Interfacing with the control gateway Device CKOZ 00/03 we got an API from Moeller to communicate to their wireless dimmer actuators. The device offers a RS232/RJ11 connector or per default a USB one.

The USB connection however does not work on a COM Port but offers only standard USB HID connection. We needed a library to open up a connection to this USB Devices and talk to it. We used the Sourceforge LibUSBDotNet library for this ( http://libusbdotnet.sourceforge.net/ ) in an older version as described later in the belower forum entry. Problems arise not while connecting to a device but while finding and communicating with the right device endpoints. Here is a tutorial on how to do that:

- Read on FROM http://community.sharpdevelop.net/forums/p/7995/22800.aspx#22800 and take experimental source code from ttp://sourceforge.net/projects/xcom-hp
- Modify VID hex = 188A and PID Hex 1101 in Class USBPort
- Modify READ AND WRITE ENDPOINT in Class USBPort ,
since we get the Moeller endpoint ids from the helper tool  testlibusb-win.exe, we can see 2 endpoints
EP moeller 1 81h == 129  == READENDPOINT
P Moeller 2 02h == 2 == WRITERNDPOINT
From the Library LibUSBDotNet we see in class ReadEndpoints (start at 129 == 0×81 )and WriteEndpoints (start at 1), so it is clear which one has to be assigned
- in USBPort.openDevice() the lines device.SetConfiguration(1) and device.ClaimInterface(0) are crucial for working

When it all stopped working

Right the day after, the solution with the LibUSBDotNet Lib was not working anymore without a single code change tested on three Win XP PCs. The crucial line

[code lang="java"]device.SetConfiguration(1)[code] freezes the PC and requires a reboot to even close the application and reaccess the Moeller gateway once again. However the SimpleHID Write test application still could communicate to the Moller gateway. So set a broken device apart, we needed a new solution. We found the very handy Jan Axelson Lakeview Research - http://www.lvr.com/usb.htm that offers a bunch of resources to the USB topic.

With generic_hid_cs and usbhidio_V2.3.cs it offers free c# src for accessing generic USB devices. Both seem quite similar and are working with the obove Vendor and ProductID for our purpose. Finally this resolved the USB communication odyssey

Comments Comments Off