Connecting to FT232R USB UART device in Windows Runtime 8.1 - c#

I'm trying to connect to FT232R USB UART device using Windows Runtime Component for Windows Store application. Unfortunately, nothing seem to work.
My device has a vid of 0x0403 and a pid 0x6001 which seem pretty standard for this type of the device.
I tried this approach but in my case the ClassCode and SubClassCodde are both 0x00 respectively and InterfaceClassCode and InterfaceSubClassCode are both 0xFF. All this data comes from the USB view utility.
Using selector based on these class and subclass codes no device is found by DeviceInformation.FindAllAsync(selector). Also selector created based on vid and pid does not find any device.
Without the selector the device is found but I receive null in UsbDevice.FromIdAsync(serviceInfo.Id).
I also tried the FTDI approach. I downloaded the FTDI drivers and referenced the FTDI.D2xx.WinRT.winmd and FTDI.D2xx.WinRT.USB.winmd. I used the approach documented in this PDF but FTDI.D2xx.WinRT.FTManager.GetDeviceList() returns empty list.
The DeviceCapabilities are defined as they should according to documentation I found:
<Capabilities>
<m2:DeviceCapability Name="usb">
<!--FT232AM, FT232BM, FT232R and FT245R Devices-->
<m2:Device Id="vidpid:0403 6001">
<m2:Function Type="name:vendorSpecific" />
</m2:Device>
</m2:DeviceCapability>
</Capabilities>
What am I doing wrong?

Well, after long hours of fighting I found the solution. Posting it here in case anyone will need it in the future.
First of all, you should follow the official FTDI guide to install FTDI drivers from here.
You will need to remove default drivers installed by Windows for your device.
Do it this way:
It's important to check the "Delete the driver software for this device" checkbox.
Do so for Serial controller also:
Afterwards disable Windows automatic drivers installation as described here.
Then scan for hardware changes in the Device manager and you'll see the unrecognized device.
Install drivers for it manually.
Afterwards you'll see your device under Universal Serial Bus devices and not controllers.
Now your device will be fully accessible using the FTDI API.
Here is a link to API guide in case you need it. It also has an explanation on how to install correct FTDI drivers.

Related

Is it possible to have our windows Handheld application as a USB receiver?

apologies if the question is quite basic, I am inexperienced in USB programming and I might be missing some conceptual detail here.
For our industrial solution we are supposed to provide communication between our PC wpf application and windows embedded HH 8.1 application. Ideally we would like this to be over USB.
I see a lot of sample code to connect directly to USB devices from host role.
However in our case the Windows Embedded HH device (Panasonic FZ-E1) will have the device role listening. I could not find any way to register to raw data sent from our PC application via USB events. I examined UMDF (user mode driver framework) which has examples about writing drivers for usb devices, yet it seems like it is for device manufacturers and us not being the manufacturer for Panasonic HH we should not/cannot use our own driver and we have to use the WinUSB driver it already has in place.
Windows Embedded 8.1 HH has some USB apis unlike windows phone, yet all the functionality provided in the API seems like connecting to external USB devices with the host role. When we use USBlyzer I see that there is some USB traffic towards the device from the PC so it looks it should be possible for the HH to have the listening device role. What am I missing here, any ideas?
Any help/direction is greatly appreciated.
P.S: I also tried windows connectivity api examining the source code of windows phone power tools yet it seems like the the dlls for addon packages here to handle transfer via agents is not there for newer versions of windows phone anymore.

How to accept incoming bluetooth connection on Windows 7 desktop (with a c++ or c# program)

I am writing a BT app on an android to connect to a lab device/hardware. At the present time I have a device on loan. However it is not possible for me to always have one while I am developing for it, (commuting, out of town, etc) Therefore I am creating an emulator for it and will run that emulator on my Windows desktop so that my Android client code can make connections to it.
The android code is built with .NET/xamarin and works fine connecting to the real device.
I am comfortable with C++ or C# on the desktop.
I have found this code http://www.codeproject.com/Articles/252882/Bluetooth-Server-Programming-on-Windows online to create and accept BT connections. it looks like a very good start for what I wish to do - which is build a state machine/emulator to mimic the real device. However I have been unable to connect my android device to it.
Note - the connection is a serial port connection. (the UUI coming from the android device is the "well known" serial port connection ("00001101-0000-1000-8000-00805F9B34FB")
I am not sure how to configure the windows 7 desktop and bluetooth services to allow this server/emulator program to accept connections.
I have paired the devices, but unable to connect.
How can I accept incoming Bluetooth serial connections in the C++ or C# code running on Win7 desktop?
If you want to do low level stuff like establish a connection via bluetooth through a C# app then you will need to access the bluetooth stack via its API. If your device is running the Microsofts Bluetooth Stack then you can look at 32feet.net's managed wrapper for Microsofts Bluetooth API. If you have the Widcomm stack then you will have to locate Widcomm's API for it.
To access the microsoft bluetooth stack, you can use the BthUtil.dll.
BthUtil.dll is an unmanaged dll which is part of the Microsoft Bluetooth stack. It's typically utilised for tasks such as turning the bluetooth radio on or off via a function called BthSetMode
(see MSDN for documentation - http://msdn2.microsoft.com/EN-US/library/aa456007.aspx)
You can check the following links:-
http://www.youtube.com/watch?v=Jn05CU3mxzo
Also, check the 32feet.Net
A Brief description of 32feet.Net
32feet.NET is a shared-source project to make personal area networking technologies such as Bluetooth, Infrared (IrDA) and more, easily accessible from .NET code.
Supports desktop, mobile or embedded systems.
32feet.NET is free for commercial or non-commercial use.
If you use the binaries you can just use the library as-is, if you make modifications to the source you need to include the 32feet.NET License.txt document and ensure the file headers are not modified/removed. The project currently consists of the following libraries:-
Bluetooth
IrDA
Object Exchange
Bluetooth support requires a device with either the Microsoft, Widcomm, BlueSoleil, or Stonestreet One Bluetopia Bluetooth stack. Requires .NET Compact Framework v3.5 or above and Windows CE.NET 4.2 or above, or .NET Framework v3.5 for desktop Windows XP, Vista, 7 and 8.
Link
http://32feet.codeplex.com/
Feature link for 32feet.Net
http://32feet.codeplex.com/wikipage?title=Feature%20support%20table&referringTitle=Documentation

How to Know USB device "HID" and "PID"

Please advice me, is there any built in function to retrieve "PID" and "VID" when USB is hooked up to the system? If not, what is the best way to get USB "HID" and "PID"? I need these two to detect USB HID device.
Since your tag specifies C# I'm going to assume that you want to do this using Microsoft Windows.
Using Windows I find this information using Device Manager under Computer Management (right-click on My Computer and select Manage). Using View -> Devices by connection open up the PCI bus node and then all of the USB nodes until you find the device you are looking for. Below is an example from my PC showing three USB devices on Intel(R) 82801G (ICH7 Family) USB Universal Host Controller entries.
Then look at the properties of the device -> then details -> then select property hardware ids and you should get the VID and PID of the device.
Don't know about native .NET, I only used LibUsbDotNet so far, check the examples.
Usually you would install the .NET assembly from the sourcefourge page, add the assembly to your Visual Studio project (References/.NET) and follow the examples (LibUsbDotNet Example Code/Getting Startet Example). Details depend on your C#/.NET/Visual Studio versions.

Mock Device connecting through USB

I have a device and the drivers for this device. What I would like to do is build an application that mocks a USB device to communicate with a third party application.
More specifically, I am attempting to build an application that can mock a USB device that mimics a Microsoft Zune. I want to make it so my application can register as a zune device and then communicate with the client. I have added several DLL's to my application in order to attempt to determine the calls that tell the software a connected device is a legitimate zune, but so far I haven't had much luck.
I'm new to this type of development - that is mimicking hardware devices, and I'm not very experienced in importing dll's that were written in C/C++. I am using Visual Studio 2010 (.net 4.0) to develop my app, and I would appreciate any help anyone can offer me towards mimicking the hardware. I do have the device drivers, which Visual studio refuses to reference directly. I also have an actual physical device, so I can see what the drivers are that it uses in Device Manager.
The goal is as follows
Application registers itself as a usb device, mimicking a Microsoft Zune in a similar fashion to how Virtual Clone Drive mimics a DVD player.
Application is recognized by zune client as a valid microsoft zune.
Zune Software works with application as it does the hardware device (syncing, etc)
I just found something called the Device Simulation Framework, which might be exactly what you need. It will still require significant research into how USB works to finish your solution, though. And probably still typically done using C or C++.
The Zune uses a modified version of the MTP protocol called MTPZ, but I found this sample using the Device Simulation Framework to simulate a regular MTP device. It's called The MTP Device Simulator. I can't tell if source code is available.
Are you able to replace the DLLs used by the zune client software with your own DLLs? In that case, you could wrap the original DLLs with your DLLs and intercept the operations.
Update: To find out the signatures of the functions in the DLL, take a look at the Dependency Walker tool, which will list the exported functions (and lots of other information). I'm guessing you will want to write your replacement DLL in C.
Otherwise, you'll have to write drivers that register a USB device with the proper endpoints. I'm not sure how to do this on Windows - I've only done USB coding on the firmware side, not the driver side. You should be able to use any tutorial for creating a Windows USB driver, like Getting Started with USB Driver Development
Zune specifics information might also be useful. Perhaps this blog post and its sequels could help: Inside the Zune/USB Protocol: Part 1

Getting Info on NON_HID USB Device

How can I get details on NON-HID USB Devices? Like the serial number, etc in c#?
I have created successfully a sample application to retrieve those information on HID only devices but not on NON-HID USB Devices.
Have you looked into LibUSB .Net?
http://sourceforge.net/projects/libusbdotnet/
I remmber seeing that this was possible, I'll try and dig the article out.
You want to retrieve the device descriptors. Assuming a driver has been bound to the device, some of these are already available as they can be seen from Device Manager.

Categories

Resources