I've managed to write data to the device but I have problems receiving data from it. I think the endpoint address is wrong or so.
Here's what I use to read from the device (in a seperate thread than the application):
The code and the endpoint looks ok to me, except that you use readInterrupt() for a bulk end-point (bmAttributes 0x03). But if I remember right, that should also work.
From you post I assume you wrote the firmware yourself. Are you sure that the device is sending data? Maybe you could try and write a simple program which continuously sends some data regardless of any other conditions.
If you post the USB descriptors I will have a look at them.
Regards, Spandi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I've managed to write data to the device but I have problems receiving data from it. I think the endpoint address is wrong or so.
Here's what I use to read from the device (in a seperate thread than the application):
public void run() {
while(enabled){
try {
int numberOfBytesRead = dev.readInterrupt(0x81, readData, readData.length, 2000, false);
for(int i=0;i<numberOfBytesRead;i++){
if(enabled)
sb.append(String.valueOf(readData[i]));
}
outputTextArea.setText(sb.toString());
} catch (USBException e){
e.printStackTrace();
}
}
}
This is what TestLibUsb returns:
__________________________________________
DLL version: 0.1.12.1
Driver version: 0.1.12.1
bus/device idVendor/idProduct
bus-0/\\.\libusb0-0001--0x1ff1-0x1ff1 1FF1/1FF1
- Manufacturer : Barco N.V.
- Product : USB Keypad Emulator
wTotalLength: 41
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: a0h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 3
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 01h
bmAttributes: 03h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
If you want I post the entire C descriptor programmed into the PIC MCU if this is of any further assistance.
I hope someone is willing to help me !
Thanks in advance !
Best regards,
RoDeNtJe
Hi RoDeNtJe
The code and the endpoint looks ok to me, except that you use readInterrupt() for a bulk end-point (bmAttributes 0x03). But if I remember right, that should also work.
From you post I assume you wrote the firmware yourself. Are you sure that the device is sending data? Maybe you could try and write a simple program which continuously sends some data regardless of any other conditions.
If you post the USB descriptors I will have a look at them.
Regards, Spandi
Hi,
I got it working now. It received data correctly, but I made a mistake with the timeout of data being received and the error handling for it.
Thanks for your help and for this wrapper. It works very nice and it's quite easy to use.
Best regards,
RoDeNtJe