【问题标题】:Supporting USB to UART device via virtual com , Not able to send clearcomm CDC command microsoft.net支持通过虚拟 com 的 USB 到 UART 设备,无法发送 clearcomm CDC 命令 microsoft.net
【发布时间】:2020-12-01 05:58:05
【问题描述】:

我们正在尝试通过 microsoft .net 串行端口支持 STM32 复合设备。我找不到支持发送 clearcomm 命令 (04) 的方法。下面列出了.net串口支持页面

https://docs.microsoft.com/en-us/dotnet/api/system.io.ports.serialport.basestream?view=dotnet-plat-ext-5.0

我们可以使用方法 public bool BreakState { get; 发送中断命令(0x23)放; }。

有没有办法检查 microsoft 串口框架与 CDC 命令中方法的映射关系?

【问题讨论】:

  • 什么是 ClearComm 命令,它在哪台计算机上执行?如果命令是发送字节数据,那就是Write方法。
  • Write 正在向设备发送数据,但 COM 端口支持 Ioctl 类型的命令。 Clearcomm 状态清除与 comport 关联的错误计数器。

标签: c# .net serial-port virtual


【解决方案1】:

你说的clearcomm是Win32 API的ClearCommError
ClearCommError function (winbase.h)

似乎 System.IO.Ports.SerialPort 没有明确的接口。
查看此源,它似乎在读取BytesToRead/BytesToWrite 属性和EV_RXCHAR or EV_ERR event 发生时在内部调用。
internal int BytesToRead
internal int BytesToWrite
private void CallEvents(int nativeEvents)

请尝试一下。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-13
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 2014-01-03
    • 2013-11-02
    • 2011-06-28
    • 1970-01-01
    相关资源
    最近更新 更多