Sending data to Teensy

Status
Not open for further replies.

Pointy

Well-known member
Hi,

I am getting a bit more adventurous with my Teesny project and now need to send some data to the Teensy from the PC. I know I could use the serial method, but just wondered if I could do it directly through the USB in windows. I only need to send a couple of bytes to indicate the status of some software LEDs, so that I can get the Teensy to turn on some real ones. The current project is using a Teesny++ 2 but I do have a spare Teensy 3 if required.

I did find this PIC based solution and I briefly tried the PC software side but I couldn't get it to work with my custom USB Teensy device.

Regards,

Les
 
It looks like RawHID is the way to go, I don't know how I missed it before!

Regards,

Les
 
While I have had some success with this, and I am able to turn on & off the Teensy LED using a 3rd party piece of software (I used this VB Template), I still have a minor niggle.

I have added a Keyboard interface to the rawHID USB type for the Teensy++ 2.0, as this is needed for my project to send keystrokes to a another piece of software. As soon as I did this the USB_RawHID example stopped printing to the Serial monitor window, although everything else seems to work. I assume I should be able do this without issue?

I have checked and double checked the usb.c & usb_private.h and can't see anything wrong.

Does anyone else have any ideas?

Regards,

Les
 
I had another look at this today and found out that if I change the PRODUCT_ID back to 0x0486 the serial messages work. So is something with the serial monitor window hard coded to only except messages from certain PIDs? Maybe something to do with teesny_gateway & fake_serial?

Regards,

Les
 
Yes, exactly. It doesn't touch unknown HID devices & interfaces.

If you'd like to build your own, the hid_listen source code is a pretty good starting point.

http://www.pjrc.com/teensy/hid_listen.html

Thanks for the heads up Paul.

I managed to get the hid_listen source to compile with Visual C++ 2010 Express. (which was an achievement on it's own for me, as C++ is not my strong point)

I tried to use the rawHID basic example as a test, but I don't seem to be reading anything, rawhid_read always returns 0.

I need to spend some more time on this I guess.

Regards,

Les
 
Lines 547 to 554 in rawhid.c
Code:
		if (vid > 0 && vid != (int)(attrib.VendorID)) {
			CloseHandle(h);
			continue;
		}
		if (pid > 0 && pid != (int)(attrib.ProductID)) {
			CloseHandle(h);
			continue;
		}

in line 70
Code:
rawhid_t * rawhid_open_only1(int vid, int pid, int usage_page, int usage)

this function is called from line 41 of hid_listen.c with these values
Code:
		hid = rawhid_open_only1(0, 0, 0xFF31, 0x0074);

but look at lines 78 and 79 in rawhid.c
Code:
// TODO; inputs are ignored and hardcoded into this signature....
	const unsigned char signature[]={0x06,0x31,0xFF,0x09,0x74};

So that looks like the part to change. I don't understand HID signatures so can't help further, but that should get you started.
 
Thanks for the reply, I did get it working in the end, it was just me being a doofus! (I missed the Usage Page 0xFFC9 & Usage 0x04 in usb_rawhid.c)

Regards,

Les
 
Although I got this working using the RawHid Test C source code, and through my own app in VB, I couldn't get it to work with the hid_listen code. I was getting an INVALID_USER_BUFFER error from ReadFile in rawhid_read. Changing char buf[64] to char buf[65] in hid_listen.c fixed it for me though.

Regards,

Les
 
Status
Not open for further replies.
Back
Top