如何解锁虚拟串口(与32feet.Net和EMDK相关)?

发布于 2024-12-03 22:38:07 字数 1037 浏览 0 评论 0原文

我确实需要一个虚拟串行端口,因为程序#1 必须为使用 System.IO.Ports.SerialPort 的第二个程序(程序#2)设置蓝牙连接,不是吗?不要求程序#1 和程序#2 使用相同的串行端口同时运行。

  • 32Feet.NET:好的。但如果我启动 SuD 7 次(一次又一次),就会收到“没有可用端口”。 COM9-> COM7-> COM5-> COM4-> COM2-> COM0-> “没有可用的端口”。

    1. program#1 调用

      bdi.SetServiceState(BluetoothService.SerialPort, true)

    2. 32feet.Net 在 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Bluetooth\Serial\Ports 中创建密钥

    3. 32feet.Net 通话

      RegisterDevice(portPrefix, portIndex, "btd.dll", ref pep);

    4. 程序#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".

    1. program#1 invokes

      bdi.SetServiceState(BluetoothService.SerialPort, true)

    2. 32feet.Net creates Key in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Bluetooth\Serial\Ports

    3. 32feet.Net calls

      RegisterDevice(portPrefix, portIndex, "btd.dll", ref pep);

    4. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

在你怀里撒娇 2024-12-10 22:38:07

一旦您设置了一次端口,为什么还需要再次设置呢?使用 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?

想挽留 2024-12-10 22:38:07

一旦您设置了端口一次,为什么还需要再次设置?

使用案例场景:X 先生使用一个移动设备和一个串行 RS232 蓝牙适配器与多个设备进行通信。但对于第七个,将不再有任何虚拟串行端口。

我在 ES400 上使用 32feet.Net无故障。对于MC55、MC35,出现了所讨论的现象。这就是我提出这个问题的原因。

我还不知道幕后发生了什么。但就 EMDK 而言:如果不再需要连接,则必须取消设备配对。

我对 Motorola ES400 和 MC55 使用 EMDK

/// <summary>
/// Removes the pairing, turns Bluetooth off and disables the bluetooth object.
/// </summary>
public void ReleaseLink(){
    try{
        this.remoteDevice.UnPair();
        this.bluetooth.Dispose();

我对 Motorola MC35 使用 32feet.NET(调用 RegisterDevice 的蓝牙串行端口):

if (!bdi.Authenticated)
{
    string pair = rd.Pin;
    paired = BluetoothSecurity.PairRequest(bdi.DeviceAddress, pair);

    if (!paired)
    {
         return;
    }
}

spp = BluetoothSerialPort.CreateClient(new BluetoothEndPoint(remoteAddress,BluetoothService.SerialPort));

public void ReleaseLink()
{
    try
    {
        BluetoothSecurity.RemoveDevice(spp.Address);
        spp.Dispose();

Once you've set the port up one time why do you ever have to do it again?

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:

/// <summary>
/// Removes the pairing, turns Bluetooth off and disables the bluetooth object.
/// </summary>
public void ReleaseLink(){
    try{
        this.remoteDevice.UnPair();
        this.bluetooth.Dispose();

I'm using 32feet.NET for Motorola MC35 (BluetoothSerialPort that invokes RegisterDevice):

if (!bdi.Authenticated)
{
    string pair = rd.Pin;
    paired = BluetoothSecurity.PairRequest(bdi.DeviceAddress, pair);

    if (!paired)
    {
         return;
    }
}

spp = BluetoothSerialPort.CreateClient(new BluetoothEndPoint(remoteAddress,BluetoothService.SerialPort));

public void ReleaseLink()
{
    try
    {
        BluetoothSecurity.RemoveDevice(spp.Address);
        spp.Dispose();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文