STM32虚拟Com端口有什么问题?我打不开
我有核仁STM32H743ZI板。我正在使用CubeMX HAL(我尝试了几个版本)和TrueStudio。“虚拟COM端口”在Windows 10中出现(我尝试了默认的Windows驱动程序和ST驱动程序),但无法打开端口。我的C#程序在我尝试打开它时写入“参数不正确”:STM32虚拟Com端口有什么问题?我打不开,stm32,usbserial,nucleo,cubemx,truestudio,Stm32,Usbserial,Nucleo,Cubemx,Truestudio,我有核仁STM32H743ZI板。我正在使用CubeMX HAL(我尝试了几个版本)和TrueStudio。“虚拟COM端口”在Windows 10中出现(我尝试了默认的Windows驱动程序和ST驱动程序),但无法打开端口。我的C#程序在我尝试打开它时写入“参数不正确”: SerialPort port = new SerialPort("COM8", 9600, Parity.None, 8, StopBits.One); port.Open(); // System.IO.IOExcept
SerialPort port = new SerialPort("COM8", 9600, Parity.None, 8, StopBits.One);
port.Open(); // System.IO.IOException: 'The parameter is incorrect.'
同样的消息给我写了程序Realterm,PuTTY do nothing和“Tera Term”程序工作正常-我可以向我的MCU程序发送和接收数据
谁知道是什么
在我的C#程序和终端程序中,我使用相同的参数
USB设备查看器信息:
[Port1] : STMicroelectronics Virtual COM Port
Is Port User Connectable: yes
Is Port Debug Capable: no
Companion Port Number: 17
Companion Hub Symbolic Link Name: USB#ROOT_HUB30#4&2f29167c&0&0#{f18a0e88-c30c-11d0-8815-00a0c906bed8}
Protocols Supported:
USB 1.1: yes
USB 2.0: yes
USB 3.0: no
Device Power State: PowerDeviceD0
---===>Device Information<===---
English product name: "STM32 Virtual ComPort"
ConnectionStatus:
Current Config Value: 0x01 -> Device Bus Speed: Full (is not SuperSpeed or higher capable)
Device Address: 0x0A
Open Pipes: 3
===>Device Descriptor<===
bLength: 0x12
bDescriptorType: 0x01
bcdUSB: 0x0200
bDeviceClass: 0x02 -> This is a Communication Device
bDeviceSubClass: 0x00
bDeviceProtocol: 0x00
bMaxPacketSize0: 0x40 = (64) Bytes
idVendor: 0x0483 = STMicroelectronics
idProduct: 0x5740
bcdDevice: 0x0200
iManufacturer: 0x01
English (United States) "STMicroelectronics"
iProduct: 0x02
English (United States) "STM32 Virtual ComPort"
iSerialNumber: 0x03
English (United States) "354BB9433137"
bNumConfigurations: 0x01
---===>Open Pipes<===---
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x82 -> Direction: IN - EndpointID: 2
bmAttributes: 0x03 -> Interrupt Transfer Type
wMaxPacketSize: 0x0008 = 0x08 bytes
bInterval: 0x10
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x01 -> Direction: OUT - EndpointID: 1
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x81 -> Direction: IN - EndpointID: 1
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00
---===>Full Configuration Descriptor<===---
===>Configuration Descriptor<===
bLength: 0x09
bDescriptorType: 0x02
wTotalLength: 0x0043 -> Validated
bNumInterfaces: 0x02
bConfigurationValue: 0x01
iConfiguration: 0x00
bmAttributes: 0xC0 -> Self Powered
MaxPower: 0x32 = 100 mA
===>Interface Descriptor<===
bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
bNumEndpoints: 0x01
bInterfaceClass: 0x02 -> This is Communications (CDC Control) USB Device Interface Class
bInterfaceSubClass: 0x02
bInterfaceProtocol: 0x01
iInterface: 0x00
-> This is a Communications (CDC Control) USB Device Interface Class
===>Descriptor Hex Dump<===
bLength: 0x05
bDescriptorType: 0x24
05 24 00 10 01
-> This is a Communications (CDC Control) USB Device Interface Class
===>Descriptor Hex Dump<===
bLength: 0x05
bDescriptorType: 0x24
05 24 01 00 01
-> This is a Communications (CDC Control) USB Device Interface Class
===>Descriptor Hex Dump<===
bLength: 0x04
bDescriptorType: 0x24
04 24 02 02
-> This is a Communications (CDC Control) USB Device Interface Class
===>Descriptor Hex Dump<===
bLength: 0x05
bDescriptorType: 0x24
05 24 06 00 01
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x82 -> Direction: IN - EndpointID: 2
bmAttributes: 0x03 -> Interrupt Transfer Type
wMaxPacketSize: 0x0008 = 0x08 bytes
bInterval: 0x10
===>Interface Descriptor<===
bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x01
bAlternateSetting: 0x00
bNumEndpoints: 0x02
bInterfaceClass: 0x0A -> This is a CDC Data USB Device Interface Class
bInterfaceSubClass: 0x00
bInterfaceProtocol: 0x00
iInterface: 0x00
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x01 -> Direction: OUT - EndpointID: 1
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x81 -> Direction: IN - EndpointID: 1
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00
[Port1]:意法半导体虚拟COM端口
端口用户是否可连接:是
是否支持端口调试:否
配对端口号:17
配套集线器符号链接名称:USB#根#集线器30#4&2f29167c&0&0#{f18a0e88-c30c-11d0-8815-00a0c906bed8}
支持的协议:
USB 1.1:是的
USB 2.0:是的
USB3.0:没有
设备电源状态:PowerDeviceD0
---=>设备信息设备总线速度:满(不具备超高速或更高的能力)
设备地址:0x0A
明管:3
==>设备描述符这是一个通信设备
bDeviceSubClass:0x00
bDeviceProtocol:0x00
bMaxPacketSize0:0x40=(64)字节
idVendor:0x0483=意法半导体
idProduct:0x5740
BCD设备:0x0200
i制造商:0x01
英语(美国)“意法半导体”
IPProduct:0x02
英语(美国)“STM32虚拟组件”
iSeries号码:0x03
英语(美国)“354BB9433137”
bNumConfigurations:0x01
---=>打开PipesEndpoint描述符方向:IN-EndpointID:2
bmAttributes:0x03->中断传输类型
wMaxPacketSize:0x0008=0x08字节
bInterval:0x10
=>端点描述符方向:OUT-端点ID:1
bmAttributes:0x02->批量传输类型
wMaxPacketSize:0x0040=0x40字节
b间期:0x00
=>端点描述符方向:IN-EndpointID:1
bmAttributes:0x02->批量传输类型
wMaxPacketSize:0x0040=0x40字节
b间期:0x00
---=>已验证完整配置描述符配置描述符
bNumberFaces:0x02
B配置值:0x01
i配置:0x00
BM属性:0xC0->自供电
最大功率:0x32=100 mA
=>接口描述符这是通信(CDC控制)USB设备接口类
Binterface子类:0x02
bInterfaceProtocol:0x01
界面:0x00
->这是一个通信(CDC控制)USB设备接口类
==>描述符十六进制转储这是一个通信(CDC控制)USB设备接口类
==>描述符十六进制转储这是一个通信(CDC控制)USB设备接口类
==>描述符十六进制转储这是一个通信(CDC控制)USB设备接口类
==>描述符十六进制转储端点描述符方向:IN-EndpointID:2
bmAttributes:0x03->中断传输类型
wMaxPacketSize:0x0008=0x08字节
bInterval:0x10
==>接口描述符这是一个CDC数据USB设备接口类
Binterface子类:0x00
bInterfaceProtocol:0x00
界面:0x00
=>端点描述符方向:OUT-端点ID:1
bmAttributes:0x02->批量传输类型
wMaxPacketSize:0x0040=0x40字节
b间期:0x00
=>端点描述符方向:IN-EndpointID:1
bmAttributes:0x02->批量传输类型
wMaxPacketSize:0x0040=0x40字节
b间期:0x00
STM32H7的固件FW1.4.0工作不正确。我必须使用FW1.3.2和CubeMX 5.2.1
但若我初始化FMC总线,虚拟COM端口再次工作不正确,若我注释初始化,它再次工作正确
MX_USB_DEVICE_Init();
// MX_FMC_Init();
有趣的是,什么样的C函数:“fopen(“COM6”、“r+”)、fwrite、fgetc、fclose”-在Windows 10中使用FW1.4.0而无需端口配置。FW1.4.0的错误在于写入端口参数(波特率、位或其他),虚拟COM端口Windows驱动程序出现异常,如果无法将参数写入USB设备我也有同样的问题,我可以读取设备并查看哪个COM端口,但我无法打开一个。(对于CDC) 然后我遇到了以下帖子,最后一个答案是我的问题的解决方案: 这里提到你需要添加几个l
/*******************************************************************************/
/* Line Coding Structure */
/*-----------------------------------------------------------------------------*/
/* Offset | Field | Size | Value | Description */
/* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/
/* 4 | bCharFormat | 1 | Number | Stop bits */
/* 0 - 1 Stop bit */
/* 1 - 1.5 Stop bits */
/* 2 - 2 Stop bits */
/* 5 | bParityType | 1 | Number | Parity */
/* 0 - None */
/* 1 - Odd */
/* 2 - Even */
/* 3 - Mark */
/* 4 - Space */
/* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */
/*******************************************************************************/
static uint8_t lineCoding[7] // 115200bps, 1stop, no parity, 8bit
= { 0x00, 0xC2, 0x01, 0x00, 0x00, 0x00, 0x08 };
static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length)
{
/* USER CODE BEGIN 5 */
switch(cmd)
{
...
case CDC_SET_LINE_CODING:
memcpy(lineCoding, pbuf, sizeof(lineCoding));
break;
case CDC_GET_LINE_CODING:
memcpy(pbuf, lineCoding, sizeof(lineCoding));
break;
...
}