В чем проблема с виртуальным Com-портом STM32? Я не могу открыть это - PullRequest
0 голосов
/ 07 июня 2019

У меня плата Nucleo 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.IOException: 'The parameter is incorrect.'

то же сообщение пишет мне программа Realterm, PuTTY ничего не делает, и программа "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

1 Ответ

0 голосов
/ 26 июня 2019

Прошивка FW1.4.0 для STM32H7 работает некорректно. Я должен использовать 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 в записи параметров порта (в бодах, битах или других), и драйвер Windows для виртуального COM-порта возникает исключение, если не может записать параметры в USB-устройство

...