Answered by:
Serial Comm with Leonardo in Windows Store C# Application

Question
-
I'm currently working on getting a Leonardo device recognized and communicating with my app over a serial port in C# for the Windows 8 App Store. I'm using http://msdn.microsoft.com/en-us/library/windows/hardware/dn312121(v=vs.85).aspx#step2 as a guide, in conjunction withhttp://code.msdn.microsoft.com/windowsapps/USB-CDC-Control-sample-5ba19caa to guide me.
I'm having problems however in the sense that my Arduino device isn't showing up despite me entering my PID/VID and Class/Subclass/Protocol so I feel I'm missing some steps and was hoping someone that has experience with this could point me to a more specific/granular example.
My device is an Arduino Leonardo and I'm running windows 8.1 using Visual Studio 2013 Ultimate, code is in C#
Any help is appreciated!
"Knowledge is Power. Power Corrupts. Stay in school. Be evil.
- Moved by Matt SmallMicrosoft employee, Moderator Friday, January 24, 2014 2:03 PM Hardware question
Thursday, January 23, 2014 8:54 PM
Answers
-
There is support for USB devices which use the in-box class or winusb.sys drivers. See the USB devices documentation and the sample Shadowsfury initially linked.
There is no support for using USB devices which require vendor supplied drivers. I'm not familiar with the Leonardo, but from Dick's post it sounds like the Leonardo requires a custom driver and so isn't supported in Windows.Devices.Usb.
--Rob
- Marked as answer by Anne Jing Monday, February 10, 2014 1:45 AM
Friday, February 7, 2014 11:02 PMModerator -
Right. The Leonardo has use a USB controller chip that can be programmed with the the right Microsoft OS Descriptor Specification descriptor for the WinUSB Device. The WinUSB Device documentation explains how to set up and configure such a device.
Once you do that it won't be seen as a serial device, but your app can connect to it through winusb.
- Marked as answer by Rob Caplan [MSFT]Microsoft employee, Moderator Tuesday, March 24, 2015 8:05 PM
Wednesday, March 18, 2015 3:23 PMModerator
All replies
-
Hi,
I'm not familiar with the examples that you link. However, I wouldn't do that anyway. I just use the built-in SerialPort class (type) - that is, use the SerialPort control from the Toolbox. When the correct device driver is installed for your Leonardo, its serial port name will appear in Control Panel/Device Manager under Ports (COM and LPT). It will be a generic USB Serial Communications Port. If will not have a device description that associates it with an Arduino. However, if you unplug the Leonardo, the associated port will "disappear" and when plugged back in, it will "reappear" in the list. You then communicate with it like any other serial device.
I have several Arduino communications examples in my book, but online resources are numerous. BTW, conventional serial communication is the only way to communicate with the Leonardo, AFAIK. The Leo does not support USB communication as a host or client like the Arduino Due (for example).
Dick
Dick Grier. Author of Visual Basic Programmer's Guide to Serial Communications 4. See www.hardandsoftware.net.
Sunday, January 26, 2014 7:02 PM -
Hey Dick,
Thanks for your reply. If it were up to me I wouldn't do it that way either but because I'm targeting the Windows 8 App Store to deploy the SerialPort class and control is not available to me. I've gotten serial communication function using the SerialPort class before, in addition to various other methods, but I am still in search of a solution applicable to the Windows 8 App Store.
Cheers!
-Karoly
"Knowledge is Power. Power Corrupts. Stay in school. Be evil.
Tuesday, January 28, 2014 6:09 PM -
So, what I've found (I don't develop Store apps, so my knowledge is limited) is this:
http://msdn.microsoft.com/en-US/library/windows/apps/dn263090
What this indicates to me is that the only support for serial devices is through the SerialPort portion of the Bluetooth RFComm API. The rational is, I suspect, Bluetooth is a device interface that does not, specifically, require that the device manufacturer provide a device driver. Most Bluetooth devices will work "out of the box." However, devices that use USB host services will not. System.IO.Ports.SerialPort is not an API that can be used in a Windows Store app, again, I suppose, because WinRT devices do not provide an "out-of-box" host USB interface.
So, I suspect, the only way to interface with external serial devices is to incorporate client Bluetooth hardware in the device. This, actually, is pretty simple (about $5 worth of hardware will do the job). However, that interface would still have to be incorporated in the device. I have a document in my book that shows one way to add a Bluetooth client hardware interface to an existing serial device.
As I said, though, I haven't written a corresponding Windows Store application that would work with the Bluetooth RFComm APIs. So, while these look like they should do the job, the "proof is in the pudding."
Dick
Dick Grier. Author of Visual Basic Programmer's Guide to Serial Communications 4. See www.hardandsoftware.net.
Friday, February 7, 2014 9:51 PM -
There is support for USB devices which use the in-box class or winusb.sys drivers. See the USB devices documentation and the sample Shadowsfury initially linked.
There is no support for using USB devices which require vendor supplied drivers. I'm not familiar with the Leonardo, but from Dick's post it sounds like the Leonardo requires a custom driver and so isn't supported in Windows.Devices.Usb.
--Rob
- Marked as answer by Anne Jing Monday, February 10, 2014 1:45 AM
Friday, February 7, 2014 11:02 PMModerator -
The Leonardo is a serial device (USB VSP). That is, normally it would use System.IO.Ports.SerialPort, which seems, unfortunately, not to be available for use in Windows Store applications. At least, that is my reading of the documentation.
Also, the actual device driver for the Virtual Serial Port that the Leonardo setup, similar to that used by some other Arduino boards, is not signed. Thus, I think it is not possible to use the Leo anyway.
Dick
Dick Grier. Author of Visual Basic Programmer's Guide to Serial Communications 4. See www.hardandsoftware.net.
- Marked as answer by Anne Jing Monday, February 10, 2014 1:45 AM
- Unmarked as answer by Rob Caplan [MSFT]Microsoft employee, Moderator Wednesday, March 18, 2015 3:19 PM
Sunday, February 9, 2014 9:36 PM -
I am in the same situation as you. However, my research showed me other alternative than bluetooth. It's possible to install an other driver for the arduino that will allow it to be seen as an usb device. Look at that blog for example, it show how to do it:
http://www.ryanlane.com/2013/11/getting-an-ardunio-uno-working-with-windows-8-1-apps/
This guy didn't post how to setup communication but, from his other post, it seem like he managed to do it. Other did too:
http://forum.arduino.cc/index.php?topic=139439.0
https://twitter.com/Pete_Brown/status/543492008766357504/photo/1
Personally, my arduino is now detected in my app as a usb device. Now, I'm working on the communication.
- Edited by Karl-Etienne Forand-Dubois Wednesday, March 18, 2015 1:59 PM
Wednesday, March 18, 2015 1:44 PM -
Right. The Leonardo has use a USB controller chip that can be programmed with the the right Microsoft OS Descriptor Specification descriptor for the WinUSB Device. The WinUSB Device documentation explains how to set up and configure such a device.
Once you do that it won't be seen as a serial device, but your app can connect to it through winusb.
- Marked as answer by Rob Caplan [MSFT]Microsoft employee, Moderator Tuesday, March 24, 2015 8:05 PM
Wednesday, March 18, 2015 3:23 PMModerator