.NET Components for Mobility

Error creating virtual port on WM5

Last post 07-22-2010 9:11 PM by acarlos. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 07-20-2010 10:42 PM

    Error creating virtual port on WM5

    Hello, I'm trying to create a virtual port for connection to a device from WM5, but just get an error: "Error creating virtual port". I tested on another smart phone with WM6.1 and no errors happened. Does anyone have any idea what the problem in WM5?

    Code:
    BluetoothEndPoint endPoint = new BluetoothEndPoint(btAddress, BluetoothService.SerialPort);
    for (int i = 0; i
    {
    try
    {
    COM = BluetoothSerialPort.CreateClient("COM" + i, endPoint);
    if (COM != null)
    {
    MessageBox.Show("COM OK!!!!!");
    break;
    }
    }
    catch (Exception ex)
    { MessageBox.Show("Error port: COM" + i + ": " + ex.Message);
    }
    }
    I also tried the code below:
    COM = BluetoothSerialPort.CreateClient (endpoint);
    
    and not worked.

    PS: I am using 32feet.NET 2.5_0125

    Tks.
  • 07-21-2010 6:49 AM In reply to

    Re: Error creating virtual port on WM5

    I'm not the expert in this, but from the User Guide: "On Windows Mobile, two methods to create a port exist in the library, the first is class BluetoothSerialPort, this creates a connection immediately but the underlying API it uses is rather unreliable, and it seems not to work at all on various device types. ... ..."

    Its a real shame about this.  There isn't a good way to create virtual serial port, I always recommend using a direct socket connection, see more in the serial port section in the User Guide etc, and on using BluetoothClient.

  • 07-21-2010 7:33 PM In reply to

    Re: Error creating virtual port on WM5

    If your device is running Windows Mobile 5 or above there is a better way to hook up a virtual COM port. Use the BluetoothDeviceInfo.SetServiceState passing in the Guid for SerialPortProfile (See BluetoothService class). On Windows Mobile the system reserves a number of ports and can hook them up dynamically based on either setting up the profile through the Settings UI or via the registry - this method does the hard work of checking the current settings in the registry and assigning the next available port. The only gotcha is that in the current version the code works sequentially through the available port numbers and often COM0 is the first. A lot of software doesn't recognise COM0 or COM ports above 9. I'm just altering the code for our next release so that if COM0 is the first supported port it is bumped to the end of the list which should increase the chance of being allocated a port between 1-9. Like the desktop equivalent of this method it provides no feedback on what port was assigned, you can query this through the registry though:-

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Bluetooth\Serial\Ports\xxxxxxxxxxxx

    string value "Port"

    I'm not sure if there is a logical place in the object model where we can expose this as a property.

    This is safer than the BluetoothSerialPort method as it will play fairly with other settings added by the user. BluetoothSerialPort should still be used for Windows CE devices which don't have support for Serial Port within the standard settings dialogs.

    Peter

  • 07-22-2010 9:11 PM In reply to

    Re: Error creating virtual port on WM5

    Tks.
Page 1 of 1 (4 items)
Copyright © 2001-2012 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy. OrcsWeb's Windows Cloud Server Hosting