如何解锁虚拟串口(与32feet.Net和EMDK相关)?
我确实需要一个虚拟串行端口,因为程序#1 必须为使用 System.IO.Ports.SerialPort 的第二个程序(程序#2)设置蓝牙连接,不是吗?不要求程序#1 和程序#2 使用相同的串行端口同时运行。
32Feet.NET:好的。但如果我启动 SuD 7 次(一次又一次),就会收到“没有可用端口”。 COM9-> COM7-> COM5-> COM4-> COM2-> COM0-> “没有可用的端口”。
program#1 调用
bdi.SetServiceState(BluetoothService.SerialPort, true)
32feet.Net 在 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Bluetooth\Serial\Ports 中创建密钥
32feet.Net 通话
RegisterDevice(portPrefix, portIndex, "btd.dll", ref pep);
程序#2:this.comX.Open(); ... this.comX.Close();
EMDK:如果我启动 SuD 7 次(一次又一次),则会抛出 IndexOutOfRangeException。 COM2-> COM4-> COM5-> COM6-> COM7-> COM9-> IndexOutOfRangeException。
program#1:我正在使用 LocalComPort,并且 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Bluetooth\Serial\Ports 未更新。
程序#2: this.comX.Open(); ... this.comX.Close();
原因是什么?没有剩下 process#1 和 process#2。
I do need a virtual serial port since a program#1 has to set up a bluetooth connection for a second program (program#2) that uses System.IO.Ports.SerialPort, don't I? It isn't a requirement providing that program#1 and #2 run concurrently using the same serial port.
32Feet.NET: Ok. But I get "No ports available" if I start the SuD 7 times (one after another). COM9 -> COM7 -> COM5 -> COM4 -> COM2 -> COM0 -> "No ports available".
program#1 invokes
bdi.SetServiceState(BluetoothService.SerialPort, true)
32feet.Net creates Key in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Bluetooth\Serial\Ports
32feet.Net calls
RegisterDevice(portPrefix, portIndex, "btd.dll", ref pep);
program#2: this.comX.Open(); ... this.comX.Close();
EMDK: An IndexOutOfRangeException is thrown if I start the SuD 7 times (one after another). COM2 -> COM4 -> COM5 -> COM6 -> COM7 -> COM9 -> IndexOutOfRangeException.
program#1: I'm using LocalComPort and HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Bluetooth\Serial\Ports isn't updated.
program#2: this.comX.Open(); ... this.comX.Close();
What is the reason? There's no process#1 and process#2 left.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一旦您设置了一次端口,为什么还需要再次设置呢?使用 SetServiceState,配置将永远在注册表中设置,因此将永远存在,例如重新启动后...大概您在 EMDK 中使用的方法也是如此。我不认识这个名字(也许只是摩托罗拉),但在我的 M3 Sky 上,我使用了 BTExplorerApi,它在端口设置功能中有一个永远和一个非永远标志。
在 32feet.NET 上使用 MSFT 堆栈。 (注:彼得是这方面的专家,而不是我)。 :-,( 据我了解,如果您使用类 BluetoothSerialPort,这将创建一个临时配置的端口(不是重新启动等)。也许这就是您想要的?
Once you've set the port up one time why do you ever have to do it again? With SetServiceState the configuration is set in the Registry for ever and thus will be there for ever, e.g. after a reboot... Presumably the same is true for the method you are using in EMDK. I don't recognise that name (maybe it is Motorola only) but on my M3 Sky I have used the BTExplorerApi and it has a for-ever and a not-for-ever flag in the port-set-up function.
On 32feet.NET with the MSFT stack. (Note: Peter was the expert in this not me). :-,( As I understand it if you use class BluetoothSerialPort, that will create a port that's configured temporary (not over reboot etc). Maybe that's what you want?
使用案例场景:X 先生使用一个移动设备和一个串行 RS232 蓝牙适配器与多个设备进行通信。但对于第七个,将不再有任何虚拟串行端口。
我在 ES400 上使用 32feet.Net,无故障。对于MC55、MC35,出现了所讨论的现象。这就是我提出这个问题的原因。
我还不知道幕后发生了什么。但就 EMDK 而言:如果不再需要连接,则必须取消设备配对。
我对 Motorola ES400 和 MC55 使用 EMDK:
我对 Motorola MC35 使用 32feet.NET(调用 RegisterDevice 的蓝牙串行端口):
Use case scenario: Mr. X uses one mobile device and one serial RS232 Bluetooth adapter to communicate with several units. But for the seventh there won't be any virtual serial port left.
I was using 32feet.Net for ES400 trouble-free. For MC55, MC35 the phenomena under discussion appears. And that was the reason why I created this question.
I don't know what's going on under the hood yet. But as far as EMDK concerned: if the connection isn't needed any longer, you have to unpair the device.
I'm using EMDK for Motorola ES400 and MC55:
I'm using 32feet.NET for Motorola MC35 (BluetoothSerialPort that invokes RegisterDevice):