09-19-2017 02:41 AM
Dear all,
it's been a while I am struggling with this topic, so please help me.
I want to communicate with a device using VISA. The device has a PIC32MX470. I used the NI VISA wizard to create the .inf file and succesfully installed it. the device is recognized by NI MAX. In the properties, I see that there is no BULK IN pipe, so when I try the basic VISA write and VISA read, I am able to succesfully write to the device but I cannot read using the VISA READ as there is no bulk in pipe (please see screenshots).
I see the solution in this topic :
but the engineer who wrote the firmware code for our device says that this solution is not working for us.
I am wondering if I can only use the USB Interrupt function to read since the BULK IN pipe is not enabled to this kind of PIC, or if it is just a firmware problem in the uc not detected and the above post is the right solution... If I have to use the interrupt, using the LV example, I receive a timeout error...
Please help me to solve this topic...
09-19-2017 08:14 AM
Dou have a description of the USB command protocol used by the device? USB != USB unfortunately.
09-20-2017 06:49 AM
Dear Intaris,
thanks for your message and the support.
I talked with the software engineer and he gave me the following three files for USB communication as implemented in the firmware of our device:
- USB_confg.h --> USB configuration file (USB working mode, etc)
- USB_descriptors.c --> USB descriptor file (used for enumeration)
- main.c --> Basic firmware with USB command protocol
Please let me know if you find something not correct...
Thanks
09-20-2017 07:17 AM
No, I mean more of a documentation as to which commands and via which communications pipe...... (Like old instrument manuals with RS-232 commands).
Basic USB enumeration is useless for actual device communication. We already know there's no Bulk IN Endpoint.
09-20-2017 08:56 AM
No, at the moment we don't have any documentation ready. We are starting now to use this basic code to implement different commands on the base of this code for USB protocol, but we don't fully know very well the USB protocol. So short answer is no, we don't have any communication or manual for this code. Also because the code is still under development...
09-21-2017 01:35 AM
Ok, I understood that no bulk in pipe is present in HID devices after many researches. I understand then that I am obliged to use the RAW Interrupt communication. I think the solution is not so far, just understand why when I use the USB RAW Interrupt example, I always get a timeout error.... Should I have to set something to enable the communication? I also tried to write something using the bulk out pipe and right after reading using the interrupt example, and also I got the timeout...How can I send to the PIC the interrupt event?`Thanks for the support.
09-21-2017 02:22 AM - edited 09-21-2017 02:26 AM
I'm sorry, I think you've understood something wrong. The HID definition in the USB standard states that the HID class requires ONLY Control (which every single class requires in order to be able to enumerate at all) and Interrupt endpoints. There may be HIDs out there which use Bulk, but that is an extra, not a part of the HID specification at all.
Here's an exerpt from the HID class definition document from the appropriate USB standard:
09-21-2017 02:27 AM
Ok, but if I read USB_descriptor.c file I sent here, I only see the endpoint descritpor corresponding to interrupt and not bulk, so I think that this particular HID does not have the bulk. Is it possible to add it by firmware, or should I use the interrupt pipe only? and if I have to use interrupt, why I always get timeout error?
Thanks a lot for the support
09-21-2017 02:41 AM
Thanks, when I posted my last comment I did not see you posted this. It is clear to me now, some HID device MAY have the bulk in pipe, but this is clearly not the case for our. Here is what I read in the USB_descriptor.c file:
/* HID Class-Specific Descriptor */
0x09,//sizeof(USB_HID_DSC)+3, // Size of this descriptor in bytes
DSC_HID, // HID descriptor type
0x11,0x01, // HID Spec Release Number in BCD format (1.11)
0x00, // Country Code (0x00 for Not supported)
HID_NUM_OF_DSC, // Number of class descriptors, see usbcfg.h
DSC_RPT, // Report descriptor type
HID_RPT01_SIZE,0x00,//sizeof(hid_rpt01), // Size of the report descriptor
/* Endpoint Descriptor */
0x07,/*sizeof(USB_EP_DSC)*/
USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor
HID_EP | _EP_IN, //EndpointAddress
_INTERRUPT, //Attributes
0x40,0x00, //size
0x01, //Interval
/* Endpoint Descriptor */
0x07,/*sizeof(USB_EP_DSC)*/
USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor
HID_EP | _EP_OUT, //EndpointAddress
_INTERRUPT, //Attributes
0x40,0x00, //size
0x01 //Interval
};
It is clear that only Interrupt is described. My questions are:
- If we modify this and add the endpoint descriptor for bulk in pipe, will it work, or simply this PIC does not support this pipe?
- If not and I have to use interrupt, how can I enable the interrupt not to get a timeout error when attempting to use the labvew example?
Thanks and sorry, it's the first time I work with USB protocol, and it seems to me very hard to understand and I am not at all a software engineer
09-21-2017 09:24 AM
This information deals puely with my existing but limited experience interfacing with HID devices via VISA Raw.
1) All commands being sent TO the device are sent via CONTROL Pipe. EVERY USB device has a default CONTROL Endpoint index ZERO. This is the communications path used to enumerate devices.
2) Some devices do ALL of their communications via CONTROL pipes.
3) Control requests can lead to the device returning data, that is, it is capable of bidirectional communication.
4) Interrupt will typically only be for receiving updates in status from the device.
So, simply "Adding a Bulk in" is not feasible without fundamentally changing the device firmware. Whether this is do-able or needed I cannot comment as I don't know the device but my instict would say "no"
https://forums.ni.com/t5/LabVIEW/Nugget-2-of-n-USB-Control-transfers-using-VISA/td-p/757011
Recommended reading if you're getting started. I've done the basic footwork for this before.