<small id='je1IB'></small><noframes id='je1IB'>

  • <i id='je1IB'><tr id='je1IB'><dt id='je1IB'><q id='je1IB'><span id='je1IB'><b id='je1IB'><form id='je1IB'><ins id='je1IB'></ins><ul id='je1IB'></ul><sub id='je1IB'></sub></form><legend id='je1IB'></legend><bdo id='je1IB'><pre id='je1IB'><center id='je1IB'></center></pre></bdo></b><th id='je1IB'></th></span></q></dt></tr></i><div id='je1IB'><tfoot id='je1IB'></tfoot><dl id='je1IB'><fieldset id='je1IB'></fieldset></dl></div>
      <bdo id='je1IB'></bdo><ul id='je1IB'></ul>

      1. <tfoot id='je1IB'></tfoot>

      2. <legend id='je1IB'><style id='je1IB'><dir id='je1IB'><q id='je1IB'></q></dir></style></legend>

        获取 USB 适配器的 com 端口号

        get com port number of an USB adapter(获取 USB 适配器的 com 端口号)

          <tfoot id='sK1ww'></tfoot>
              <i id='sK1ww'><tr id='sK1ww'><dt id='sK1ww'><q id='sK1ww'><span id='sK1ww'><b id='sK1ww'><form id='sK1ww'><ins id='sK1ww'></ins><ul id='sK1ww'></ul><sub id='sK1ww'></sub></form><legend id='sK1ww'></legend><bdo id='sK1ww'><pre id='sK1ww'><center id='sK1ww'></center></pre></bdo></b><th id='sK1ww'></th></span></q></dt></tr></i><div id='sK1ww'><tfoot id='sK1ww'></tfoot><dl id='sK1ww'><fieldset id='sK1ww'></fieldset></dl></div>
                <legend id='sK1ww'><style id='sK1ww'><dir id='sK1ww'><q id='sK1ww'></q></dir></style></legend>

                <small id='sK1ww'></small><noframes id='sK1ww'>

                  <bdo id='sK1ww'></bdo><ul id='sK1ww'></ul>
                    <tbody id='sK1ww'></tbody>
                  本文介绍了获取 USB 适配器的 com 端口号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试编写一个使用 arduino mega 和基于 FTDI 的 USB 转 RS485 适配器的程序.

                  I am trying to write a program that uses an arduino mega and a FTDI-based USB to RS485 adapter.

                  我想让程序对用户友好,因此我不希望用户手动检查 com 端口号,但我想自动检测它.这是代码片段

                  I want to make the program user-friendly, thus I don't wont the user to manually check the com port number, but I want to auto-detect it. Here's a snippet of the code

                      ManagementScope scope = new ManagementScope();
                      SelectQuery query = new SelectQuery("SELECT * FROM Win32_SerialPort");
                      ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
                  
                      try
                      {
                          foreach (ManagementObject item in searcher.Get())
                          {
                              String description = item["Description"].ToString();
                              String deviceID = item["DeviceID"].ToString();
                  
                              Console.WriteLine("Porta " + description + " deviceID " + deviceID);
                  
                              if (description.Contains("USB Serial Port"))
                                  return deviceID;
                          }
                      }
                      catch (ManagementException)
                      {
                      }
                  

                  我无法理解的一点是为什么我可以找到 Arduino 的 USB 串行端口(匹配 description.Contains("Arduino") )但找不到 USB 的 com 端口RS485 接口.

                  The point that I am not able to understand is why I can find the USB Serial port of the Arduino (matching description.Contains("Arduino") ) but not the com port of the USB RS485 port.

                  您知道为什么会发生这种情况吗?查询 SELECT * FROM Win32_SerialPort 错了吗?

                  Do you have an idea why this could happen? is the query SELECT * FROM Win32_SerialPort wrong?

                  推荐答案

                  嗯,研究了几个论坛后,我发现如果我运行查询 SELECT * FROM 会列出与 USB/RS485 适配器关联的 com 端口Win32_PnPEntity .

                  Well, after studying several forums, I discovered that the com port associated to the USB/RS485 adapter is listed if I run the query SELECT * FROM Win32_PnPEntity .

                  但我真的不明白为什么 arduino 的串行端口由查询显示,而另一个端口与另一个查询显示......我的意思是,它们都是 uSB<-> 串行适配器!

                  But I really don't understand why the serial port of the arduino is shown by a query and the other port with the other query.... I mean, those are both uSB<->serial adapters!

                  这篇关于获取 USB 适配器的 com 端口号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)
                  Parameter count mismatch with Invoke?(参数计数与调用不匹配?)
                  How to store delegates in a List(如何将代表存储在列表中)
                  How delegates work (in the background)?(代表如何工作(在后台)?)
                  C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)
                  Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)
                  • <tfoot id='ZyvyP'></tfoot>

                      <bdo id='ZyvyP'></bdo><ul id='ZyvyP'></ul>

                        <small id='ZyvyP'></small><noframes id='ZyvyP'>

                        <i id='ZyvyP'><tr id='ZyvyP'><dt id='ZyvyP'><q id='ZyvyP'><span id='ZyvyP'><b id='ZyvyP'><form id='ZyvyP'><ins id='ZyvyP'></ins><ul id='ZyvyP'></ul><sub id='ZyvyP'></sub></form><legend id='ZyvyP'></legend><bdo id='ZyvyP'><pre id='ZyvyP'><center id='ZyvyP'></center></pre></bdo></b><th id='ZyvyP'></th></span></q></dt></tr></i><div id='ZyvyP'><tfoot id='ZyvyP'></tfoot><dl id='ZyvyP'><fieldset id='ZyvyP'></fieldset></dl></div>

                          <legend id='ZyvyP'><style id='ZyvyP'><dir id='ZyvyP'><q id='ZyvyP'></q></dir></style></legend>
                            <tbody id='ZyvyP'></tbody>