USB superspeed peripherals Forum Discussions
Hi,
I am working on an FX 3 USB 3,0 device with the firmware developed using the FX3 EZ USB Suite and am seeing some device
registration issues.
The device has a two-phase install. When the device is plugged our driver identifies the device, downloads the device specific
firmware, and triggers a re-enumeration of the device which then comes up using the downloaded firmware and our driver then
hooks it in as a device which sits on top of WinUSB.
The device specific firmware has USB descriptors that should allow it load as either a USB 2.x device running at HS and FS, or
as a USB 3.0 device capable of running at SS, HS, and FS, depending upon which USB slot it is connected to.
Here are the issues that I am seeing:
1. When I plug my device into a USB 3.0 port, it will occasionally register as a USB 3.0 device running at HS, and occasionally as
a USB 2.1 device running at HS. It seems almost random as to which of the two types it will register as.
2. When I attach my device to the USB 3,0 port both usbview.exe and usblyzer.exe takes a long time to run up, or refresh, and list
the devices. This sluggishness does not happen when my device is not connected.
3. When it does register as a USB 3.0 device it does not register as running at SS, but only HS.
4. In neither case do the apps recognize or display the string descriptors I have configured for my device.
When I plug it into a USB 2 port it registers correctly and the strings are seen and displayed by both usbview and usblyzer.
Can anyone offer any suggestions as to why I am seeing these issues?
I have seen on this forum (http://www.cypress.com/forum/usb-30-super-speed/looking-fx3-descriptors-work-winusb) that if the device is to be used with WinUSB you need additional descriptors.
Below are the descriptors for my device (anonymized where necessary).
Thanks,
Peter Young
Xitron Europe
------------------------------------------------------------------------------------
/* Standard device descriptor for USB 3.0 */
const uint8_t CyFxUSB30DeviceDscr[] __attribute__ ((aligned (32))) =
{
0x12, /* Descriptor size */
CY_U3P_USB_DEVICE_DESCR, /* Device descriptor type (0x01) */
0x00,0x03, /* USB 3.0 */
0x00, /* Device class */
0x00, /* Device sub-class */
0x00, /* Device protocol */
0x09, /* Maxpacket size for EP0 : 2^9 = 512 bytes */
VENDOR_ID, /* Vendor ID <anonymised> */
PRODUCT_ID, /* Product ID <anonymised> */
0x01,0x00, /* Device release number */
0x01, /* Manufacture string index */
0x02, /* Product string index */
0x00, /* Serial number string index */
0x01 /* Number of configurations */
};
/* Standard device descriptor for USB 2.0 */
const uint8_t CyFxUSB20DeviceDscr[] __attribute__ ((aligned (32))) =
{
0x12, /* Descriptor size */
CY_U3P_USB_DEVICE_DESCR, /* Device descriptor type (0x01) */
0x10,0x02, /* USB 2.10 */
0x00, /* Device class */
0x00, /* Device sub-class */
0x00, /* Device protocol */
0x40, /* Maxpacket size for EP0 : 64 bytes */
VENDOR_ID, /* Vendor ID <anonymised> */
PRODUCT_ID, /* Product ID <anonymised> */
0x01,0x00, /* Device release number */
0x01, /* Manufacturer string index */
0x02, /* Product string index */
0x00, /* Serial number string index */
0x01 /* Number of configurations */
};
/* Binary device object store descriptor */
const uint8_t CyFxUSBBOSDscr[] __attribute__ ((aligned (32))) =
{
0x05, /* Descriptor size */
CY_U3P_BOS_DESCR, /* Device descriptor type (0x0F) */
0x16,0x00, /* Length of this descriptor and all sub descriptors */
0x02, /* Number of device capability descriptors */
/* USB 2.0 extension */
0x07, /* Descriptor size */
CY_U3P_DEVICE_CAPB_DESCR, /* Device capability type descriptor (0x10) */
CY_U3P_USB2_EXTN_CAPB_TYPE, /* USB 2.0 extension capability type (0x02) */
0x02,0x00,0x00,0x00, /* Supported device level features: LPM support */
/* SuperSpeed device capability */
0x0A, /* Descriptor size */
CY_U3P_DEVICE_CAPB_DESCR, /* Device capability type descriptor (0x10) */
CY_U3P_SS_USB_CAPB_TYPE, /* SuperSpeed device capability type (0x03) */
0x00, /* Supported device level features */
0x0E,0x00, /* Speeds supported by the device : SS, HS and FS */
0x03, /* Functionality support */
0x0A, /* U1 Device Exit latency */
0xFF,0x07 /* U2 Device Exit latency */
};
/* Standard device qualifier descriptor */
const uint8_t CyFxUSBDeviceQualDscr[] __attribute__ ((aligned (32))) =
{
0x0A, /* Descriptor size */
CY_U3P_USB_DEVQUAL_DESCR, /* Device qualifier descriptor type (0x06) */
0x00,0x02, /* USB 2.0 */
0x00, /* Device class */
0x00, /* Device sub-class */
0x00, /* Device protocol */
0x40, /* Maxpacket size for EP0 : 64 bytes */
0x01, /* Number of configurations */
0x00 /* Reserved */
};
/* Standard super speed configuration descriptor */
const uint8_t CyFxUSBSSConfigDscr[] __attribute__ ((aligned (32))) =
{
/* Configuration descriptor */
0x09, /* Descriptor size */
CY_U3P_USB_CONFIG_DESCR, /* Configuration descriptor type (0x02) */
0x53,0x00, /* Length of this descriptor and all sub descriptors */
0x01, /* Number of interfaces */
0x01, /* Configuration number */
0x00, /* Configuration string index */
0x80, /* Config characteristics - Bus powered */
0x32, /* Max power consumption of device (in 8mA unit) : 400mA */
/* Interface descriptor */
0x09, /* Descriptor size */
CY_U3P_USB_INTRFC_DESCR, /* Interface Descriptor type (0x04) */
0x00, /* Interface number */
0x00, /* Alternate setting number */
0x05, /* Number of end points */
0xFF, /* Interface class */
0x00, /* Interface sub class */
0x00, /* Interface protocol code */
0x00, /* Interface descriptor string index */
/* Endpoint descriptor for Debug Consumer EP */
0x07, /* Descriptor size */
CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type (0x05) */
CY_FX_DEBUG_CONSUMER, /* Consumes debug (0x81) */
CY_U3P_USB_EP_BULK, /* Bulk endpoint type (0x02) */
0x00,0x04, /* Max packet size = 1024 bytes */
0x00, /* Servicing interval for data transfers : 0 for bulk */
/* Super speed endpoint companion descriptor for Debug Consumer EP */
0x06, /* Descriptor size */
CY_U3P_SS_EP_COMPN_DESCR, /* SS endpoint companion descriptor type (0x30) */
(CY_FX_EP_BURST_LENGTH - 1), /* Max no. of packets in a burst(0-15) - 0: burst 1 packet at a time (0x03) */
0x00, /* Max streams for bulk EP = 0 (No streams) */
0x00,0x00, /* Service interval for the EP : 0 for bulk */
/* Endpoint descriptor for Debug Producer EP */
0x07, /* Descriptor size */
CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type (0x05) */
CY_FX_DEBUG_PRODUCER, /* Produces debug (0x01) */
CY_U3P_USB_EP_BULK, /* Bulk endpoint type (0x02) */
0x00,0x04, /* Max packet size = 1024 bytes */
0x00, /* Servicing interval for data transfers : 0 for bulk */
/* Super speed endpoint companion descriptor for Debug Producer EP */
0x06, /* Descriptor size */
CY_U3P_SS_EP_COMPN_DESCR, /* SS endpoint companion descriptor type (0x30) */
(CY_FX_EP_BURST_LENGTH - 1), /* Max no. of packets in a burst(0-15) - 0: burst 1 packet at a time (0x03) */
0x00, /* Max streams for bulk EP = 0 (No streams) */
0x00,0x00, /* Service interval for the EP : 0 for bulk */
/* Endpoint descriptor for API Consumer EP */
0x07, /* Descriptor size */
CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type (0x05) */
XI_API_CONSUMER, /* Responses back to Plugin/DLL (0x82) */
CY_U3P_USB_EP_BULK, /* Bulk endpoint type (0x02) */
0x00,0x04, /* Max packet size = 1024 bytes */
0x00, /* Servicing interval for data transfers : 0 for bulk */
/* Super speed endpoint companion descriptor for API Consumer EP */
0x06, /* Descriptor size */
CY_U3P_SS_EP_COMPN_DESCR, /* SS endpoint companion descriptor type (0x30) */
(CY_FX_EP_BURST_LENGTH - 1), /* Max no. of packets in a burst(0-15) - 0: burst 1 packet at a time (0x03) */
0x00, /* Max streams for bulk EP = 0 (No streams) */
0x00,0x00, /* Service interval for the EP : 0 for bulk */
/* Endpoint descriptor for API Producer EP */
0x07, /* Descriptor size */
CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type (0x05) */
XI_API_PRODUCER, /* Commands FROM the Plugin/DLL (0x04) */
CY_U3P_USB_EP_BULK, /* Bulk endpoint type (0x02) */
0x00,0x04, /* Max packet size = 1024 bytes */
0x00, /* Servicing interval for data transfers : 0 for bulk */
/* Super speed endpoint companion descriptor for API Producer EP */
0x06, /* Descriptor size */
CY_U3P_SS_EP_COMPN_DESCR, /* SS endpoint companion descriptor type (0x30) */
(CY_FX_EP_BURST_LENGTH - 1), /* Max no. of packets in a burst(0-15) - 0: burst 1 packet at a time (0x03) */
0x00, /* Max streams for bulk EP = 0 (No streams) */
0x00,0x00, /* Service interval for the EP : 0 for bulk */
/* Endpoint descriptor for Video Producer EP */
0x07, /* Descriptor size */
CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type (0x05) */
XI_VID_PRODUCER, /* Video data from the Plugin/DLL (0x06) */
CY_U3P_USB_EP_BULK, /* Bulk endpoint type (0x02) */
0x00,0x04, /* Max packet size = 1024 bytes */
0x00, /* Servicing interval for data transfers : 0 for bulk */
/* Super speed endpoint companion descriptor for Video Producer EP */
0x06, /* Descriptor size */
CY_U3P_SS_EP_COMPN_DESCR, /* SS endpoint companion descriptor type (0x30) */
(CY_FX_EP_BURST_LENGTH - 1), /* Max no. of packets in a burst(0-15) - 0: burst 1 packet at a time (0x03) */
0x00, /* Max streams for bulk EP = 0 (No streams) */
0x00,0x00, /* Service interval for the EP : 0 for bulk */
};
/* Standard high speed configuration descriptor */
const uint8_t CyFxUSBHSConfigDscr[] __attribute__ ((aligned (32))) =
{
/* Configuration descriptor */
0x09, /* Descriptor size */
CY_U3P_USB_CONFIG_DESCR, /* Configuration descriptor type (0x02) */
0x35,0x00, /* Length of this descriptor and all sub descriptors */
0x01, /* Number of interfaces */
0x01, /* Configuration number */
0x00, /* COnfiguration string index */
0x80, /* Config characteristics - bus powered */
0x32, /* Max power consumption of device (in 2mA unit) : 100mA */
/* Interface descriptor */
0x09, /* Descriptor size */
CY_U3P_USB_INTRFC_DESCR, /* Interface Descriptor type (0x04) */
0x00, /* Interface number */
0x00, /* Alternate setting number */
0x05, /* Number of endpoints */
0xFF, /* Interface class */
0x00, /* Interface sub class */
0x00, /* Interface protocol code */
0x00, /* Interface descriptor string index */
/* Endpoint descriptor for producer EP */
0x07, /* Descriptor size */
CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type (0x05) */
CY_FX_DEBUG_CONSUMER, /* Consumes debug (0x81) */
CY_U3P_USB_EP_BULK, /* Bulk endpoint type (0x02) */
0x00,0x02, /* Max packet size = 512 bytes */
0x00, /* Servicing interval for data transfers : 0 for bulk */
/* Endpoint descriptor for consumer EP */
0x07, /* Descriptor size */
CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type (0x05) */
CY_FX_DEBUG_PRODUCER, /* Produces debug (0x01) */
CY_U3P_USB_EP_BULK, /* Bulk endpoint type (0x02) */
0x00,0x02, /* Max packet size = 512 bytes */
0x00, /* Servicing interval for data transfers : 0 for bulk */
/* Endpoint descriptor for producer EP */
0x07, /* Descriptor size */
CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type (0x05) */
XI_API_CONSUMER, /* Responses back to Plugin/DLL (0x82) */
CY_U3P_USB_EP_BULK, /* Bulk endpoint type (0x02) */
0x00,0x02, /* Max packet size = 512 bytes */
0x00, /* Servicing interval for data transfers : 0 for bulk */
/* Endpoint descriptor for consumer EP */
0x07, /* Descriptor size */
CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type (0x05) */
XI_API_PRODUCER, /* Commands FROM the Plugin/DLL (0x04) */
CY_U3P_USB_EP_BULK, /* Bulk endpoint type (0x02) */
0x00,0x02, /* Max packet size = 512 bytes */
0x00, /* Servicing interval for data transfers : 0 for bulk */
/* Endpoint descriptor for consumer EP */
0x07, /* Descriptor size */
CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type (0x05) */
XI_VID_PRODUCER, /* Video data from the Plugin/DLL (0x06) */
CY_U3P_USB_EP_BULK, /* Bulk endpoint type (0x02) */
0x00,0x02, /* Max packet size = 512 bytes */
0x00, /* Servicing interval for data transfers : 0 for bulk */
};
/* Standard full speed configuration descriptor */
const uint8_t CyFxUSBFSConfigDscr[] __attribute__ ((aligned (32))) =
{
/* Configuration descriptor */
0x09, /* Descriptor size */
CY_U3P_USB_CONFIG_DESCR, /* Configuration descriptor type (0x02) */
0x20,0x00, /* Length of this descriptor and all sub descriptors */
0x01, /* Number of interfaces */
0x01, /* Configuration number */
0x00, /* COnfiguration string index */
0x80, /* Config characteristics - bus powered */
0x32, /* Max power consumption of device (in 2mA unit) : 100mA */
/* Interface descriptor */
0x09, /* Descriptor size */
CY_U3P_USB_INTRFC_DESCR, /* Interface descriptor type (0x04) */
0x00, /* Interface number */
0x00, /* Alternate setting number */
0x02, /* Number of endpoints */
0xFF, /* Interface class */
0x00, /* Interface sub class */
0x00, /* Interface protocol code */
0x00, /* Interface descriptor string index */
/* Endpoint descriptor for consumer EP */
0x07, /* Descriptor size */
CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type (0x05) */
CY_FX_DEBUG_CONSUMER, /* Endpoint address and description (0x81) */
CY_U3P_USB_EP_BULK, /* Bulk endpoint type (0x02) */
0x40,0x00, /* Max packet size = 64 bytes */
0x00, /* Servicing interval for data transfers : 0 for bulk */
/* Endpoint descriptor for producer EP */
0x07, /* Descriptor size */
CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type (0x05) */
CY_FX_DEBUG_PRODUCER, /* Endpoint address and description (0x01) */
CY_U3P_USB_EP_BULK, /* Bulk endpoint type (0x02) */
0x40,0x00, /* Max packet size = 64 bytes */
0x00 /* Servicing interval for data transfers : 0 for bulk */
};
/* Standard language ID string descriptor */
const uint8_t CyFxUSBStringLangIDDscr[] __attribute__ ((aligned (32))) =
{
0x04, /* Descriptor size */
CY_U3P_USB_STRING_DESCR, /* Device descriptor type */
0x09,0x04 /* Language ID supported */
};
/* Standard manufacturer string descriptor */
const uint8_t CyFxUSBManufactureDscr[] __attribute__ ((aligned (32))) =
{
0x0E, /* Descriptor size */
CY_U3P_USB_STRING_DESCR, /* Device descriptor type */
'X',0x00,
'i',0x00,
't',0x00,
'r',0x00,
'o',0x00,
'n',0x00
};
/* Standard product string descriptor */
const uint8_t CyFxUSBProductDscr[] __attribute__ ((aligned (32))) =
{
0x18, /* Descriptor size */
CY_U3P_USB_STRING_DESCR, /* Device descriptor type */
'U',0x00,
'S',0x00,
'B',0x00,
' ',0x00,
't',0x00,
'o',0x00,
' ',0x00,
'S',0x00,
'C',0x00,
'S',0x00,
'I',0x00
};
/* Microsoft OS Descriptor. */
const uint8_t CyFxUsbOSDscr[] __attribute__ ((aligned (32))) =
{
0x3A,
CY_U3P_USB_STRING_DESCR,
'X', 0x00,
'i', 0x00,
't', 0x00,
'r', 0x00,
'o', 0x00,
'n', 0x00,
' ', 0x00,
'U', 0x00,
'S', 0x00,
'B', 0x00,
' ', 0x00,
't', 0x00,
'o', 0x00,
' ', 0x00,
'S', 0x00,
'C', 0x00,
'S', 0x00,
'I', 0x00,
' ', 0x00,
'C', 0x00,
'o', 0x00,
'n', 0x00,
'v', 0x00,
'e', 0x00,
'r', 0x00,
't', 0x00,
'e', 0x00,
'r', 0x00
};
const uint8_t CyFxUsbDscrAlignBuffer[32] __attribute__ ((aligned (32)));
Show LessHello,
We're using CX3 to transfer data from image sensor to Host app.
Structure: Image sensor - CX3 - Host App (USB2.0 port)
Image sensor: Raw 10, 4000 x 3000 x30fps -> streaming to CX3
I/F: MIPI
It's ok to drop the frame rate but image data should be received by Host App as it's quality (4000x3000)
USB 2.0 bandwidth is low so we couldn't received the image by Host App (the DMA buffer seem to be overwritten)
[Question] Any way to configure DMA buffer of CX3 to transfer this 4K image data to Host App through USB2.0 port without changing image quality?
Regards,
Show LessHi
We implemented uvc streaming application using our sensor on linux in super speed mode on cx3. There are also 2 usb virtual com ports. Everything is working fine while the cx3 is connected to super speed port on PC. We want to use a number of sensors so we connect the cx3 through usb 3 hub. The streaming is always failed after a short time. We get CY_U3P_ERROR_INVALID_SEQUENCE error in commit buffer and application reset doesn't help, we immediately get the same error after DMA channels recreate and reset of state machine. It happens only if we use hub. Are there a known problems using hubs with cx3? May be we should use specific hub model?
Thanks,
Roman Tcharny
Show LessHi,
I want to use CX3 to receive 1280x720p@15hz YUV422 sensor input and My CX3 MIPI Setting is as follow,
CY_U3P_CSI_DF_YUV422_8_2,//CY_U3P_CSI_DF_YUV422_8_2, //CY_U3P_CSI_DF_RAW10, | /* dataFormat */ | ||||
2, | /* numDataLanes */ | ||||
7, | /* pllPrd (0x0F = 15) | */ | |||
333, | /* pllFbd (0x1FF = 511) | */ //400.8MHz 19.2*(333+1)/(7+1)/2^1 = 400.8 | |||
CY_U3P_CSI_PLL_FRS_250_500M, | /* pllFrs | */ | |||
CY_U3P_CSI_PLL_CLK_DIV_8, | /* csiRxClkDiv */ //mipi detect clk 100 mhz , | ||||
CY_U3P_CSI_PLL_CLK_DIV_8, | /* parClkDiv | */ //para 100Mhz | |||
0x0806, | /* mclkCtl | */ | |||
CY_U3P_CSI_PLL_CLK_DIV_2, | /* mClkRefDiv */ //12 400.8/2 / (8+1+6+1) = 12.525 (12.5) | ||||
1280, | /* uint16_t hResolution */ | ||||
1 |
When I use AMPCAP to preview, CX3 Firmware UVCGpifCB always stay in state "CX3_PARTIAL_BUFFER_IN_SCK1" so the DMA callback is not work. What does it mean? How can I debug this issue? Thanks.
Show LessHi,
I used FX3 as a usb control device, then modified the firmware to enumerate the device as a UAC device.
and I want use another DSP board connect to FX3 via I2S.
there is only 1 line for data transfer(I2S-SD), and the DSP board have 2 line for data in/out(ADCDAT/DACDAT)
1. how should I connect the two device?
2. does the FX3's I2S support dumplex-mode?
Thanks.
Show Lessi am interfacing an image sensor to fx2lp
fx2lp CY7C68013A-56LTXC,it has RDY0 AND RDY1 signals
i am referring AN61345 slavefifo code,
my image sensor has LV and FV output,is it compulsary to connect
LV to RDY0
FV to RDY1 in gpif mode
or can i use other fx2lp gpio for LV and FV
For an example PA1 to FV?
i have attached my project gpif interfcace and schematic.
please tell me
Show LessDear Sir,
I use CyU3PGpioComplexUpdate () to update PWM,
but, when threshold = CY_FX_PWM_PERIOD (100 %,high level expected) or threshold =0 (0%,low level expected), the real PWM is 50%.
Does anyone know why?
David
Show LessIf i run FX3,FLAGA is going 1 to 0 and stays 0 forever
FLAG B is going low to high when i request the data from the control centre.
FLAG B is changing ,but FLAG A is not changing??why??
and data is missing in the control centre.
PCLK=100MHZ
I set CyU3PGpifSocketConfigure (0,CY_U3P_PIB_SOCKET_0,3,CyFalse,1);
as per AN65974 app note(EXAMPLE 3,FIGURE 13),
Before running FPGAi am running FX3,
HELP ME
Show LessHi,
I try to build my first project(CYUSB3014, \dma_examples\cyfxbulklpauto) in Eclipse, but it occurs some error. I fix part of them and it still exists other just like the following table.
Where can I find the define of ' CYU3P_AUTO_START '?
Description | Resource | Path | Location | Type |
Symbol 'CYU3P_AUTO_START' could not be resolved | cyfxbulklpauto.c | /USBBulkLoopAuto | line 673 | Semantic Error |
I have sample code for testing the camera streaming from the fx3 when connecting the camera, I have to perform the interrupt transfer by the side when the camera starts streaming,
I have an fx3 board and camera connected, I have used the libuvc and libusb libraries with opencv, I have used in the code to do,
#include <stdio.h>
#include <opencv/highgui.h>
#include <opencv2/core.hpp>
#include <opencv2/opencv.hpp>
#include "libuvc/libuvc.h"
#include "libuvc/libuvc_internal.h"
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <iostream>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/opencv.hpp>
#include <thread>
using namespace std;
using namespace cv;
void cb(uvc_frame_t *frame, void *ptr) {
uvc_frame_t *bgr;
uvc_error_t ret;
IplImage* cvImg;
int wid = frame->width;
int hei = frame->height;
unsigned short data16[wid*hei];
unsigned char * bytedata = (unsigned char*) frame->data;
for(int ii=0; ii < wid*hei; ii++) {
data16[ii] = (unsigned short) (bytedata[2*ii]) | (unsigned short) (bytedata[2*ii+1] << :sunglasses: ;
}
cv::Mat Bayer( hei, wid, CV_16UC1, (void*) data16);
double min, max;
cv::minMaxLoc(Bayer, &min, &max);
cv::Mat bgrmat(wid,hei,CV_16UC3);
cv::cvtColor(Bayer, bgrmat, CV_BayerBG2RGB);
cv::pyrDown(bgrmat,bgrmat);
cv::pyrUp(bgrmat,bgrmat);
bgrmat.convertTo(bgrmat,CV_8UC3);
Bayer.convertTo(Bayer,CV_8UC3);
#if 0
#endif
cv::namedWindow("Test", CV_WINDOW_AUTOSIZE);
cv::imshow("Test", bgrmat);
cv::waitKey(1);
}
void task1() {
struct libusb_device_handle *usb_devh;
uvc_device_handle_t *internal_devh;
struct libusb_device_descriptor desc;
uvc_device_t *dev;
int result;
int recv;
unsigned char data_in[4];
result = libusb_open(dev->usb_dev, &usb_devh);
fprintf(stderr, " result %d\n", result);
}
int main(int argc, char **argv) {
uvc_context_t *ctx;
uvc_error_t res;
uvc_device_t *dev;
uvc_device_handle_t *devh;
uvc_stream_ctrl_t ctrl;
struct libusb_device_handle *usb_devh;
struct libusb_device_descriptor desc;
res = uvc_init(&ctx, NULL);
if (res < 0) {
uvc_perror(res, "uvc_init");
return res;
}
puts("UVC initialized");
res = uvc_find_device(
ctx, &dev,
0, 0, NULL);
if (res < 0) {
uvc_perror(res, "uvc_find_device");
} else {
puts("Device found");
res = uvc_open(dev, &devh);
if (res < 0) {
uvc_perror(res, "uvc_open");
} else {
puts("Device opened");
uvc_print_diag(devh, stderr);
res = uvc_get_stream_ctrl_format_size(
devh, &ctrl, UVC_FRAME_FORMAT_YUYV, 400, 400, 30);
uvc_print_stream_ctrl(&ctrl, stderr);
if (res < 0) {
uvc_perror(res, "get_mode");
} else {
int dummy;
int result;
res = uvc_start_streaming(devh, &ctrl, cb,&dummy, 0);
if (res < 0) {
uvc_perror(res, "start_streaming");
} else {
puts("Streaming for 10 seconds...");
uvc_error_t resAEMODE = uvc_set_ae_mode(devh, 1);
uvc_perror(resAEMODE, "set_ae_mode");
int i;
unsigned char data_in[4];
int recv;
while(1){
result = libusb_interrupt_transfer(devh->usb_devh, 0x82, data_in, 4, &recv, 1000);
printf("%d",result);
for(int i = 0; i < recv; i++)
{
printf("%02x ",data_in[i]);
}
printf("\n");
}
sleep(1);
// }
sleep(200);
uvc_stop_streaming(devh);
puts("Done streaming.");
}
}
uvc_close(devh);
puts("Device closed");
}
uvc_unref_device(dev);
}
uvc_exit(ctx);
puts("UVC exited");
return 0;
}
I have tested the interrupt transfer and camera streaming separately, which is working fine.
Show Less