I've build a simple USB device with an ATmega328p running at 12 MHz with a crystal, following the "typical circuit" on the V-USB homepage, but running at 5V with the two zener diodes at D+ and D-.
It is running fine; it is detected very reliably on a Linux PC and my kernel USB driver module is loaded when the device connects:
Code: Select all
[56524.707406] usb 2-1.1: new low-speed USB device number 64 using ehci-pci
[56524.807554] usb 2-1.1: New USB device found, idVendor=d0de, idProduct=0001
[56524.807563] usb 2-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[56524.807569] usb 2-1.1: Product: USBTherm
[56524.807574] usb 2-1.1: Manufacturer: Dode
[56525.387240] usbtherm: USB device was connected
[56525.387817] usbcore: registered new interface driver usbtherm
Getting the descriptor from the kernel driver like that works fine:
Code: Select all
usb_get_descriptor(dev->usbdev, USB_DT_DEVICE, 0x00,
&usb_dev_desc, sizeof(usb_dev_desc));
Now I'd like to send a custom "vendor" request and have the driver send back a temperature value (max 8 bytes) read "on the fly". For that I have:
- Set USB_CFG_IMPLEMENT_FN_READ to 1
- make clean...
- Implemented the function usbFunctionRead()
- Return USB_NO_MSG from usbFunctionSetup()
From the kernel driver I am calling:
Code: Select all
unsigned char data[8];
usb_control_msg(dev->usbdev, usb_rcvctrlpipe(dev->usbdev, 0),
0, USB_TYPE_VENDOR, 0, 0, data, sizeof(data), 1000);
In the device, usbFunctionSetup() is entered and USB_NO_MSG is returned, but usbFunctionRead() is never called and the timeout of 1 second is hit.
In Wireshark, I can see the "URB CONTROL out" request and the response when the timeout occurs and the response contains a strange URB status:
Code: Select all
URB status: No such file or directory (-ENOENT) (-2)
What could I be doing wrong?