I would like to port my MQX 4.0 code for the Jade Robot (https://mimetics.ca) as well as create a new product's code in MQX for KSDK.
For these products, I would like to implement blocking bi-directional HID communications (meaning that there are no device drivers/inf files required by the user).
I started out with the USB CDC examples that are provided with the KSDK but the example does not implement blocking (receives are polling continuously, which will affect the performance of the application).
Does anybody have any code which provides blocking USB CDC and, going further, how to update the USB Descriptor (I *think* that's all that's required) to implement the communications as HID?
See the attached files for an example of how to use bi-direction HID communication, which was a feature added in KSDK 1.1. The easiest method is to just copy the C:\Freescale\KSDK_1.1.0\usb\example\device\hid\hid_mouse folder, rename it to something new (like "hid_generic"), remove the hid_mouse.c/.h files, and put in the attached files. It's all interrupt driven, so it's not blocking, but you could add that in there.
I'm trying to copy the hid_mouse example into my workspace and build it before copying in your files (so I have a working copy and not a potentially corrupted) and failing miserably.
I have attached the copy/build instructions that I have developed for doing this. Notice that I copy in the files that are used in the original project and then add the include folders that are pointed to by the files (I've been careful to try and use the same ones) but:
Could you please look through my instructions and see if there's something that I've screwed up/missing?
I think you're trying to make it more complicated than it needs to be. My assumption is you already have the built-in USB demos working, so you have the libraries already compiled.
First go to Windows Explorer and in C:\Freescale\KSDK_1.1.0\usb\example\device\hid\, copy the "hid_mouse" demo. Rename that copied folder to "hid_generic". Inside C:\Freescale\KSDK_1.1.0\usb\example\device\hid\hid_generic, delete the 4 .c and .h files. Then copy and paste the files I attached before into that directory (C:\Freescale\KSDK_1.1.0\usb\example\device\hid\hid_generic)
Then in KDS, import the project at C:\Freescale\KSDK_1.1.0\usb\example\device\hid\hid_generic. It will still be named "hid_mouse" but you can change that later. Then inside that project in KDS, in the "Sources" folder, delete the existing files listed. Then copy into the "Sources" folder those 4 files that you had just unzipped. And then compile and debug like normal. That's it.
Hope that helps get you up and going.
Okay, I think I have built the application correctly. Attached is a text file listing the steps I took (they required more than just copying the folder into a new one) along with screen shots showing the device parameters.
Now, when I actually try to communicate with it, using a Chrome App (attached), I am not getting anything through. I have put breakpoints at different places within hid_generic_app_param_callback of hid_generic.c to try to catch communications.
To install the Chrome App, first unzip "hid Test Application" and save it on your PC's hard drive.
Next, in the Chrome Browser, click on the "Hamburger" (three horizontal lines at the top right of the dialog box) and then click on "More tools" and then "Extensions". Then, click on "Load unpacked extensions", find and select the folder the unzipped "hid Test Application". It will come up in the "Extensions" window and to execute it, click on "launch". If a Freedom board running the usb_generic app is running, it will see it.
I have put a breakpoint at line 172 of usb_generic.c (in hid_generic_app_param_callback) as well at the receive and send method calls. In "hid Test Application", I have put breakpoints at the various send/receive locations.
There is no problem with connecting/disconnecting to the Freedom board.
When I try to send data, Chrome returns "Transfer Failed" and when I try to receive data, Chrome returns "Transfer Failed". None of the breakpoints I have put in hid_generic_app_param_callback of the KSDK for MQX application are ever activated.
Do you have a PC app that shows hid communications working? I don't know if the problem is with the MQX code or with the Chrome code (but for my product, I will be using teh Chrome code).
Any other ideas where the problems lay?
My guess is that it's something with the Chrome app settings. Check to make sure the app is trying to communicate to the correct VID/PID that the board is using. That would be my best guess at the issue since it seems to be enumerating correctly, but you're not seeing any data transactions. Those breakpoints you mentioned are the correct ones.
We use an internal app to do testing with this code, but cannot release it publicly due to some licensing constraints. This is why this bi-directional HID demo is not included by default with KSDK, since there's not an easy way for customers like you to run a complete demo. I can only supply the USB source.
Some good progress. I am sending data to the Freedom board (on Report 0) and I can set a breakpoint at line 172 of hid_generic.c and see the requests: USB_DEV_EVENT_DATA_RECEIVED, followed by USB_DEV_EVENT_SEND_COMPLETE
But, my receive always returns immediately with nothing.
Is there something that needs to be done to set up the reply/setup to wait until the data is ready? I feel like there should be some kind of explicit write to indicate that data will be pending.
I've attached the Chrome App code that I'm using (it's actually quite simple) and for more information, you can see the API reference here: https://developer.chrome.com/apps/hid
Any ideas what is happening with the receive would be greatly appreciated.
If you look at the attached code, in the "manifest.json" file, you'll see that I entered in the FSL VID (0x2504 - 9476 decimal) and PID (0x0405 - 1029 decimal). If you use any other VID/PID the application will not recognize (and connect with) the Freedom board with the code.
I was going to ask how do you know your internal app works and follow it up by saying that the Chrome USB HID APIs work but I just took a look at an new example ("blink1") and it seems that they've recently updated the HID APIs to work for all HID devices and not just requiring a later version of Chrome. Let me look at the code over the next day or so and I'll let you know if the problem was the version of Chrome that I was working with.
Thanx for getting back to me - hopefully we'll end up with code that can be used with Chrome as an interface for MQX devices.