Windows Phone 8 USB communication - c++

I would just like to know if it would be possible to communicate to external hardware through USB with a Windows Phone application. More specifically I would like to communicate with my 3d printer by simply porting an existing open-source C++ application. Do any of you know if this is possible and possibly have any information on how to do this. Possibly some api references.
Also if any of you know of a way to do this on a Symbian device, that would also help.

There are no public APIs for using USB in this way (i.e. as a host device) on Windows Phone.

Related

Can I write device driver for iOS in C++?

I came up with a project that requires me to write a driver for a micro-controller connected to an iPhone via the lightning port. Is it possible to write the driver at all, if I don't plan on releasing it to the App Store?
Also, my second question is: What language do I have to use? I'm pretty familiar with C++ and I'm completely new to Apple devices, so I have no idea if I need to use Swift.
It's not possible to write drivers for iOS. The only way to access the port (and Bluetooth classic) is the External Accessory Framework.
Some common accessory features are accessible through other frameworks like Game ControllerFramework. The WWDC2013 Designing Accessories for
iOS and OS X and WWDC2014 lists some of the frameworks you can use to interact with accessories.
You need MFi as a hardware vendor and for the AppStore (you need to provide your custom protocol string/s, if any). The program provides detailed information about the iPod Accessory Protocol (iAP).
Maybe you can find this SO question useful USB-Programming on iPhone

Accessing COM device names in C++/Win7

I'm trying to write a program that sends COM port information to devices that may get unplugged and end up with a different COM port number. Using SetupDi, I know it's possible to list all the COM ports on a computer by number, but given that the number might change I'm trying to find a better way to access the COM ports.
The COM devices I'm using are FTDI serial-to-com adapters that let me program the device model. I'd love to be able to choose a COM port based on the device model. I've tried (almost) all of the properties that I can get to using SetupDi, but no dice. It looks like there's a difference between the device list SetupDi lets me access, and the devices that show up under Devices and Printers (where the model name does show up). Is there any way to get devices in the Devices and Printers window programmatically and map them to COM port using Windows APIs?
The link below is a great (if not the only) comprehensive overview on how to enumerate COM ports on Windows and extract extra information in various ways:
http://www.naughter.com/enumser.html
What we use in our own software (Docklight) is according to what the "UsingSetupAPI1" way from the enumser.cpp file shows (SetupAPI - GUID_DEVINTERFACE_COMPORT). The UsingSetupAPI1 example demonstrates how to extract the device name as shown in the Windows Device Manager, along with the COM number. This is called "friendlyNames" in the enumser.cpp code.
Another way to identify and communicating to your device could be not asking Windows in the first place, but the FTDI D2XX API:
http://www.ftdichip.com/Support/SoftwareExamples/CodeExamples.htm
We use the D2XX API for communication when we know it is always a FTDI device. Identification is simpler and we have much better performance / less latency than using Windows Communications API via "virtual COM port".
If we need to correlate between COM port numbers and a FTDI device ID, we use the FTDI D2XX API's ListDevices and GetComPortNumber functions.

Code example for virtual HID (Human Interface Device)

I need example of code (or some tutorial) for making virtual HID (Human Interface Device).
If possible with bluetooth integration and made for linux using QT/C++.
Practically, I want to make my own cellphone application which will have few buttons (but it will work as keyboard - sending keystrokes), without requiring server-side application (it will control windows/linux/mac operating systems), and HID seems to me best choice. Unfortunately, I can't find any code samples or tutorials for that.
The thing is I don't know how I am supposed to make service and register it (make it available over bluetooth so OS can recognize it as keyboard and pair with it).
So far I have found about BlueZ, but as I mentioned, I cant find any code samples or tutorials.
UPDATE: I am trying to make my cellphone (Nokia N9 - Maemo 6/MeeGo OS - Linux) to pretend as HID device via BlueTooth so I can send keystrokes to PC.
The first question that comes into my mind is this usb device made by you ?
I don't understand what making my own cellphone application means . So you have a device that is a cell phone or what please be more explicit
Anyway a solution for you might be the libusb library works very well on both windows and linux machines.
If you need to study about usb hid devices and how to interact with them you can find a lot of very good tutorials here.
Please be more explicit in order to help you.

Read data from Wii-balanceboard

Im trying to get the output from a Wii Fit (balance board). I can find the device via the C++ Bluetooth enumerators but attempts to connect via a windows socket are failing.
Im wondering if anyone has had success in such a direction (C++, windows) I'd love to hear how you did it.
The Wii Balance Board is a HID device. To understand communications with the Balance Board, you need to know a little bit about Bluetooth HID. There's good information on WiiBrew about the Wiimote and the Wii Balance Board.
I don't think you can use Windows Sockets to connect to a HID device. The Windows Socket Bluetooth interface only allows you to connect to RFCOMM-based services. HID is based on L2CAP which is further down the Bluetooth protocol stack. There's some information at MSDN about that limitation.
If you're just looking to hack around with it, you can try Bluecove for Java. You may be able to do something using another stack (for example, Widcomm). If you're locked in to Windows and C++, you may have to look into writing an custom HID driver for the Balance Board.
As pwc said there is a limitation in the MS Bluetooth API, so with sockets you cannot have something else except RFCOMM, but this doesn't mean you cannot go down at L2CAP layer. What you have to do is to implement a client profile driver and you can use as starting point an article from MSDN: Creating a L2CAP Client Connection to a Remote Device and vice-versa: Accepting L2CAP Connections in a Bluetooth Profile Driver
Next of course as pwc said you have to study Bluetooth HID and WiiBrew for the communication protocol.
Also a good document to read is Bluetooth Wireless Technology FAQ - 2010 which states clear that it is possible to have L2CAP connections with Microsoft Bluetooth stack driver. Of course not with sockets.
When using HID on a Bluetooth device there is generally no need to create a L2CAP connection directly. All(???) of the Bluetooth stacks on Win32 have support for Bluetooth HID and provide access to the HID stream/control through the native Windows HID API. No (direct) L2CAP required! :-)
On WinCE there is built-in support for Bluetooth HID also, but I'm not sure there's a way to access a HID API.
That's how Brian Peek's wiimore library works -- it uses the HID API. The good thing about that is that one gets supports for all(?) the Bluetooth stacks that way -- they each support HID devices via the Windows HID API, whereas to use L2CAP directly one would have to support each of the stacks' APIs... (That's if they have one! BlueSoleil has no L2CAP API as far as I can see).
So, on Win32 one should just pair with the device and check that the HID checkbox is checked on its Bluetooth Service control panel tab (whichever Bluetooth stack is in use). In my 32feet.NET library one can discover the device and then ensure that HID is enabled for it with:
BluetoothDeviceInfo[] list = btCli.DiscoveryDevices();
var deviceInfo = list[n]; // Select the correct device
deviceInfo.SetServiceState(BluetoothService.HumanInterfaceDevice, true);
(That should work on MSFT and BlueSoleil; there's no API for that on Widcomm AFAIK -- although when paired it might be automatically enabled anyway).
The one possible exception case is that apparently some devices are not fully compliant with the Bluetooth/HID specs, I'm told the PS3 blu-ray controller is like that. Then one might want to try L2CAP connections directly -- however its likely that the stack's support for HID will interfere with third-party applications trying to provide the same service...

C++ USB Programming

I am new to hardware programming(especially USB) so please bear with me and my questions. I am using C++ and I need to send/receive some data (a byte array) to/from a USB port on a microprocessor board.
Now, I have done some serial port programming before and I know that for a serial port you have to open a port, setup, perform i/o and finally close the port. I am guessing to use a USB port, it is not as simple as what I mentioned above.
I do know that I want to use Microsoft standard drivers and implement standard Windows IO commands to accomplish this, since I believe there are no drivers for the microprocessor board for me to interact with.
If somebody can point me in the right direction as to the steps needed to "talk" to a USB port (open, setup, i/o) via standard Windows IO commands, I would truly and greatly appreciate it. Thanks you so much!!
USB in a nutshell is excellent background reading.
For a generic USB module try LibUSB which includes some examples of talking to standard devices. LibUSB-Win32 is the windows port of that library.
You're right though, it's nowhere near as simple as an RS232 port.
What microprocessor are you using? Does it come with any USB hardware or are you thinking of trying to implement it all in software (not something I'd recommend even contemplating!). A lot of microprocessors come with code samples which can emulate simple HID USB devices like keyboards / mice etc. which you can use as a starting point. Failing that, there's probably a few off-the-shelf options which will save you a lot of headaches :-)
Find out the USB chipset used on the microprocessor board, e.g. Ftdi, Cypress, etc. These manufacturers supply drivers, libraries and example programs for the comms, this is the easiest way.
There are no 'standard' drivers as such unless your board is set up as an HID device, however if you are using Windows, Microsoft supply a WinUSB.sys 'generic' driver which may or may not meet your needs (it doesn't support Isochronous transfers).
Should you write a driver for the USB device that will attach itself. If you know the type of chip that has the USB i/o on the board, the driver will be for that device.
There may already be driver's for that chip if it is an STM or there may be an API to help develop drivers for it. It would probably be a custom device but you should look through device types to see if there is an existing type that matches your device. If so there may also be a driver already for it which you can use. Information about the board is necessary.
WRITE YOUR OWN DRIVER
With out getting too far into it, you should learn Microsoft's driver model, the difference between user mode and kernal mode drivers, what driver node's represent, driver hierarchy and how they logically attach themselves, different types of drivers (filter, function, bus), how kernal driver's communicate with user interface, dynamic link libraries, frameworks and API's, WDM framework/API, KMDF and UMDF API's and this is just a short list.
OR you can use an existing driver.
USE USB MICROCONTROLLER SUPPLIED DRIVER
We do not know what firmware the USB microcontroller is using, if any. If there is no firmware (if say the chip came with out it or relies on eprom to store it and not flash) then if we knew if the chip supports usb bootloader, you can flash it or load it's firmware through the USB and there is no need for JTAG or other peripherials. Likely the usb alone is capable of getting you off the ground and anywhere from there. Typically these types of questions arise when considering board's with out a USB microcontroller.
Here is a link to a slighly related driver. Most USB microcontrollers serve the purpose of switching USB communication to UART as most microconrollers that actually do the thinking and control everything are not equiped with USB i/o but instead UART or some other i/o pins like I2C or SPI etc..
https://www.silabs.com/products/mcu/Pages/USBXpress.aspx
That driver may actually work, if not something similar but for the manufacturer of your USB microcontroller; will almost certainly do the job. Hope this helps.
By hardware programming, do you mean you will be programming the microcontroller? If so, there is no way you will use "standard windows drivers" or anything like that.
The USB standard is very thick. Check it out here
It is a very involved topic and I recommend finding USB implementations already created for your microcontroller. (which we may be able to find if you gave us more info)
What kind of microprocessor and what kind of board?
Many processors come with support for USB ports. Also, some hardware boards come with USB contollers too.
For example, the processor that my shop is using comes with two USB controllers that can act as a hub or as a device. We're even adding another processor to act as a USB controller.