locked
Bluetooth Virtual Com Port Error 2404 RRS feed

  • Question

  •  

    I'm trying to connect to a bluetooth device using the RegisterDevice function.  Unfortunately no matter which port I select I always get error code 2404 ERROR_DEVICE_IN_USE.  There is nothing currently connected to the Bluetooth device and no devices already registered to any com port.  Has anyone had this problem before and know of a way to fix it?  I've included the code snippet below.

     

    char *Bth::BtRegister(char *DeviceAddress)

       {

       char *Addr = DeviceAddress;

       PORTEMUPortParams pp = {0};

       TCHAR Prefix[5];

       int i;

       pp.channel = 1;

       for (i=0; i<12; ++i, ++Addr){

          int c = *Addr;

          if(c >= 'a') c = c - 'a' + 0xa;

          else if (c >= 'A') c = c - 'A' + 0xa;

          else c = c - '0';

          pp.device = pp.device * 16 + c;

       }

       _tcscpy(Prefix, _T(PORT_PREFIX_BT));

       for(i = 0; i < 5; i++){

          DWORD err;

          BtHandle = RegisterDevice(&Prefix[0],

                                                  PORT_SUFFIX_BT,

                                                  L"btd.dll",

                                                  (DWORD)&pp);

          err = GetLastError();

          if(BtHandle) {

             strcpy(&BtPortName[0], PORT_NAME_BT);

             return &BtPortName[0];

          }

       }

       return 0;

    }

    Tuesday, January 22, 2008 5:28 PM

Answers

  • ok, I know it's probably few months to late but for future reference:

    I had the same issue with my bluetooth virtual com ports and it was caused by registering the device using RegisterDevice() and not deregistering it later with UnregisterDevice(). Such device / serial port stay opened until you unregister it, reboot the device or unload/reload the driver perhaps.
    • Marked as answer by floydian78 Tuesday, July 28, 2009 2:07 PM
    Thursday, July 16, 2009 12:27 AM

All replies

  •  Hi,
    Register device should be invoked with the following parameters, Make sure that the variables (&Prefix[0],PORT_SUFFIX_BT and &pp.device) holding correct input.

    HbtPrint= RegisterDevice (L"COM", 6, L"btd.dll", (DWORD)&pp);


    Sree
    Monday, January 12, 2009 12:53 PM
  • ok, I know it's probably few months to late but for future reference:

    I had the same issue with my bluetooth virtual com ports and it was caused by registering the device using RegisterDevice() and not deregistering it later with UnregisterDevice(). Such device / serial port stay opened until you unregister it, reboot the device or unload/reload the driver perhaps.
    • Marked as answer by floydian78 Tuesday, July 28, 2009 2:07 PM
    Thursday, July 16, 2009 12:27 AM