[NUC972/NUC980]USB gadget虚拟2个以上的VCOM在window下只识别出一个

Nuvoton_N329 |浏览146次
收藏|2023/08/03 16:33

满意回答

2023/08/03 16:43

通过修改/drivers/usb/gadget/serial.c中n_ports=2可以虚拟出2个VCOM(ttyGS0和ttyGS1),window识别却只有一个串口。

原因在于多个串口通过IAD来分割,

所以在device descriptor中需要支持IAD protocal

使用了IAD的设备,设备描述符中类(Class)、子类(SubClass)和协议(Protocol)的值必须定义成如下数值:

bDeviceClass = 0xEF (miscellaneous device class)

bDeviceSubClass = 0x02 (common class)

bDeviceProtocol = 0x01 (interface association descriptor)

在serial.c中判断n_ports > 1时候使用IAD protocol

static int __init init(void)

{

/* We *could* export two configs; that'd be much cleaner...

* but neither of these product IDs was defined that way.

*/

if (use_acm) {

serial_config_driver.label = "CDC ACM config";

serial_config_driver.bConfigurationValue = 2;

if(n_ports == 1)

device_desc.bDeviceClass = USB_CLASS_COMM;

else

{

printk("IAD setting\n");

device_desc.bDeviceClass = USB_CLASS_MISC; //0xef

device_desc.bDeviceSubClass = 0x02;

device_desc.bDeviceProtocol = 0x01; //IAD

}


nuvoton2022

其他回答(0)
0人关注该问题
+1
 加载中...