Closed zhuyeaini9 closed 2 years ago
Hello @zhuyeaini9 , thank you for reaching out to us.
I can confirm that I reproduced the problem with FTDI 232RQ (PID: 0x6001), that is almost the same as your chip (comparison here)
It is something FTDI specific, but I'll prepare an example how to handle this
Hello again @zhuyeaini9
I could reproduce the same issue on Windows too: FTDI chips use their custom packet format, so the first two bytes are not data but rather status bytes. They are coded as follows:
The real RX data start at data[2]
. So very simple RX handler would look like this:
static void handle_rx(uint8_t *data, size_t data_len, void *user_arg) {
if (data_len > 2) {
// You can check the status bytes here
for (int j = 2; j < data_len; j++) {
putchar(data[j]); // Print to ESP monitor
}
}
}
However, the FTDI chip won't send you any data before you configure it's line properties (parity, stop bits...) and baudrate via FTDI's custom commands.
ATM, I'm updating the CDC driver to allow such extension. I'll keep you updated.
thanks@tore-espressif,really helpful. for the line coding setting. I remember I also try the method:cdc_acm_host_line_coding_set after open the device,but the log show error of it: //--------------------------------- E (9640) cdc_acm: cdc_acm_host_set_control_line_state(1113): //---------------------------------
That's correct, FTDI chips don't use commands as defined in USB CDC specification but their own vendor specific commands.
The FTDI implementation is currently under internal review. I'll update this issue when it gets public, thanks!
That's correct, FTDI chips don't use commands as defined in USB CDC specification but their own vendor specific commands.
The FTDI implementation is currently under internal review. I'll update this issue when it gets public, thanks!
got it.
any update?
@zhuyeaini9 sorry for the delay.
If you are willing to test my work-in-progress code, you can try this example: https://github.com/tore-espressif/esp-idf/tree/feature/usb_host/cdc_custom_commands/examples/peripherals/usb/host/cdc/cdc_acm_vcp
The API can change in the official release, though.
There are couple of points we need to internally agree upon/fix:
Your feedback would be greatly appreciated, thanks!
thanks update!
I try your example cdc_acm_vcp,it works well! I can get correct reply from my cmd: //--------------------------------------------------------- I (313) VCP example: Installing USB Host I (343) VCP example: Installing CDC-ACM driver I (343) VCP example: Opening FT232 UART device I (743) FT23x: Baudrate required: 115200, set: 115384 I (743) VCP example: Setting up line coding I (743) FT23x: Baudrate required: 115200, set: 115384 Manual Read RD -0.64220,0.11727,0.47023 //---------------------------------------------------------
Hello, Thank you for your work @tore-espressif Does this example works also with the FT2232D ?
Hello, Thank you for your work @tore-espressif Does this example works also with the FT2232D ?
Hello, I have not tested with FT2232D.
You can easily try it out by updating the PID of the device in the driver and invoke this constructor https://github.com/espressif/esp-usb/blob/master/host/class/cdc/usb_host_ftdi_vcp/include/usb/vcp_ftdi.hpp#L38
Thank you so much for your quick reponse, the codes are compatible also with the SIP ESP32-S3-PICO as it has the USB 1.1 OTG support right ?
yep, all modules based on S3 have USB 1.1 host support.
You are the best guys, thank you !
Beaware of hardware of your development board. Not all boards have USB (pin 19 and 20) wired out to USB-A connector
Excuse me, please. Can this library be independent of ESP32? I believe it can be used on other boards as well, since it's written entirely in C++ code. Am I right? Also, does this library support bidirectional communication?
Hi all: I used the esp32s3 board to develop one usb host fuction. I used the master branch code. the device was the cdc-like device which connect to esp32s3's usb[GPIO 19 20] via one usb to uart chip(ft231xq). I can find this device by the example of usb host lib,which show below info: //----------------------------------------------------------------------- Device descriptor bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0x0 bDeviceSubClass 0x0 bDeviceProtocol 0x0 bMaxPacketSize0 8 idVendor 0x403 idProduct 0x6015 bcdDevice 0.00 iManufacturer 1 iProduct 2 iSerialNumber 3 bNumConfigurations 1 I (5417) CLASS: Getting config descriptor Configuration descriptor bLength 9 bDescriptorType 2 wTotalLength 32 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 bMaxPower 90mA Interface descriptor bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 0xff iInterface 2 Endpoint descriptor bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 0x2 BULK wMaxPacketSize 64 bInterval 0 Endpoint descriptor bLength 7 bDescriptorType 5 bEndpointAddress 0x2 EP 2 OUT bmAttributes 0x2 BULK wMaxPacketSize 64 bInterval 0 I (5477) CLASS: Getting Manufacturer string descriptor FTDI I (5487) CLASS: Getting Product string descriptor FT231X USB UART I (5487) CLASS: Getting Serial Number string descriptor DQ008964 //----------------------------------------------------------------------- but when I try the example of cdc_acm_bg96, of course I change the code of vid,pid to my device. comment some code of bg96 special,like send AT cmd etc. so the code is simple: 1.open the device with rx handle function. 2.print data of rx handle function. the device seems open ok from log: //-------------- D (2430) USBH: Processing actions 0x100 D (2430) USBH: New device 1 D (2440) cdc_acm: New device connected D (2440) cdc_acm: Checking list of connected USB devices D (2450) CDC_ACM: Submitting poll for BULK IN transfer D (2450) CDC_ACM: in xfer cb //------------- but I received repeated messages which has len 2, first was 0x11,two was 0x60. it received again and again. the device is ok,I connect it to pc's usb port. it works,it not send the 0x11 0x60 message. it just return message after I send some cmd to it. I check the ascii,the 0x11 ofter used for XON flag,I don't know what should I do. from the cdc_acm_bg96's readme,the device should be support: //--------------------------------------
Supported Devices
The CDC-ACM Host driver supports the following types of CDC devices:
CDC-Like Vendor Specific Devices
The CDC-ACM Class driver supports CDC-like devices that meet the following requirements:
0xFF
For CDC-like devices, users are responsible for ensuring that they only call APIs (e.g.,
cdc_acm_host_send_break()
) that are supported by the target device. //-----------------------------------------------any advice is welcome!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!