CDC-ACM Usb Host with FTDI adapter

dontpostalot
Posts: 5
Joined: Wed Sep 15, 2021 12:51 pm

CDC-ACM Usb Host with FTDI adapter

Postby dontpostalot » Fri May 06, 2022 9:25 am

Hi

I'm trying to run the CDC-ACM Usb Host example with an FTDI RS485 adapter but my ESP32S2 fails to identify it as a serial device. The bDeviceClass, bDeviceSubClass and bDeviceProtocol fields of the device descriptor are all zero.

Code to list some of the fields:

Code: Select all

usb_device_handle_t current_device;
            // Open USB device
            if (usb_host_device_open(GetCdcAcm(), dev_addr_list[i], &current_device) != ESP_OK) {
Serial1.println("failed to open device");            
			continue; // In case we failed to open this device, continue with next one in the list
            }
            
            const usb_device_desc_t *device_desc;
            ESP_ERROR_CHECK(usb_host_get_device_descriptor(current_device, &device_desc));
			const usb_config_desc_t *config_desc;
			usb_host_get_active_config_descriptor(current_device, &config_desc);
			const usb_standard_desc_t *this_desc = (const usb_standard_desc_t *)config_desc;
			int desc_offset = 0;
			this_desc = usb_parse_next_descriptor(this_desc, config_desc->wTotalLength, &desc_offset);
			
            Serial1.println(device_desc->idVendor); // 0x0403
			Serial1.println(device_desc->idProduct); // 0x6001
			Serial1.println(device_desc->bDeviceClass);
			Serial1.println(device_desc->bDeviceSubClass);
			Serial1.println(device_desc->bDeviceProtocol);
			Serial1.println(device_desc->iSerialNumber);
			Serial1.println(device_desc->bMaxPacketSize0);
			Serial1.println(device_desc->bDescriptorType);
			Serial1.println(device_desc->bNumConfigurations);
			Serial1.println(config_desc->wTotalLength);
			Serial1.println(config_desc->bDescriptorType);
			Serial1.println(config_desc->bNumInterfaces);
			Serial1.println(this_desc->bDescriptorType);
			
			const usb_intf_desc_t* interface_desc = (const usb_intf_desc_t*) this_desc;
			Serial1.println(interface_desc->bInterfaceClass);
			Serial1.println(interface_desc->bInterfaceSubClass);
			Serial1.println(interface_desc->bInterfaceProtocol);
Output:

1027
24577
0
0
0
3
8
1
1
32
2
1
4
255
255
255

The adapter works fine with windows as a serial port. How to make it work with ESP-IDF?

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: CDC-ACM Usb Host with FTDI adapter

Postby ESP_Dazz » Fri May 06, 2022 9:36 am

Have you tried the CDC Virtual COM Port example?

dontpostalot
Posts: 5
Joined: Wed Sep 15, 2021 12:51 pm

Re: CDC-ACM Usb Host with FTDI adapter

Postby dontpostalot » Fri May 06, 2022 9:48 am

I haven't and it looks like that's exactly what I need. Thanks!

User avatar
Michael.Uray
Posts: 7
Joined: Sat Nov 05, 2022 3:13 pm

Re: CDC-ACM Usb Host with FTDI adapter

Postby Michael.Uray » Wed Jun 26, 2024 7:53 am

ESP_Dazz wrote:
Fri May 06, 2022 9:36 am
Have you tried the CDC Virtual COM Port example?
I am wondering if this virtual COM port example would also work with an ESP32-C6.
It says there that USB OTG is required, which the C6 does not have, but it has UHCI support.
Is there a way to connect an USB-Serial adapter to the ESP32-C6?

ESP_Sprite
Posts: 9709
Joined: Thu Nov 26, 2015 4:08 am

Re: CDC-ACM Usb Host with FTDI adapter

Postby ESP_Sprite » Thu Jun 27, 2024 8:39 am

Michael.Uray wrote:
Wed Jun 26, 2024 7:53 am
I am wondering if this virtual COM port example would also work with an ESP32-C6.
It says there that USB OTG is required, which the C6 does not have, but it has UHCI support.
Is there a way to connect an USB-Serial adapter to the ESP32-C6?
No. UHCI in the ESP32 series is an UART function block; it has nothing to do with USB.

Who is online

Users browsing this forum: No registered users and 252 guests