ActiveSync, WM2005 and recovery

Hi,

We're using RAPI to enable communication between our desktop and PPC application over ActiveSync. One of the requirements on our application is that it must be able
to recover from failure, such as cable removal or similiar. This works fine with WM2003, but WM2005 doesn't appear to be able to recover as easily.

The scenario is simple: open a RAPI stream, remove the USB-cable (while the stream is open) and reopen the stream. With WM2005, it will only be possible to reinitialize if our app is restarted.
When attempting to reconnect after cable-removal, we will _always_ get error 0x80070015 (device not ready). This does not occure on WM2003.

This is roughly what we're doing (note - pseudo code):

-------------------------------------------------------------
bool reinitialized = false, reloaded = false, opened = false;

// Dynamically link against RAPI
rapi_dll = LoadLibrary("rapi.dll");
CeRapiInit = GetProcAddress(...), CeRapiUninit = ...;

while(!opened || !(reinitialized && reloaded))
{
CeRapiInit();

try
{
CeRapiInvoke(bla, bla, bla);
opened = true;

} catch (...)
{
if(!reinitialized)
{
// Try to simply reinitialize rapi
CeRapiUninit();

reinitialized = true;
}
else if(!reloaded)
{
// Reload the DLLs (far fetched)
FreeLibrary(rapi_dll);
LoadLibrary(rapi_dll);

reloaded = true;
}
}
}
-------------------------------------------------------------

Any ideas Has anyone else had problems with this

Thanks in advance,
Nille



Answer this question

ActiveSync, WM2005 and recovery

  • Rob Grunkemeyer

    Nah, doesn't work either. If I kill wcecomm, ActiveSync won't be able to connect to the device at all, actually (I need to restart my computer).

    I don't get it. Since it works if I restart my app, it seems reasonable that something is cleaned up when the app exit. But what, I wonder...

    Regards,
    Nille


  • Deedhun

    In case anyone else has this problem, we ended up implementing the ActiveSync stuff in a separate process that we kill when the connection terminates. Works like a charm ;)

    Regards,

    Nille


  • Henk Gijsbert

    Hi,

    Our app retries into eternity if the connection won't open, so that's not it. I have in fact tried to reconnect an hour or so after
    cable removal, with the same result (device not ready).

    Regards,
    Nille


  • fripper

    The main difference between WM5 and WM2003 devices that comes to mind is that WM5 devices use RNDIS connection that takes about 3-5 seconds to initialize, because it tries to get a DHCP address, eventually fails and assigns private addresses to both sides of the RNDIS connection. I suggest that you add a 5 second delay and see if it helps

  • aaks

    I see. I'm afraid this might be one of the "quirks" of the ActiveeSync. RAPI is implemented as out-of-process COM server and it is possible that destroying the proxy (rapi.dll) does not ensure the proper cleanup. Could you (for the test purposes) check if doing what you do already AND killing and restarting ActiveSync process (wcecomm and WCESMgr.exe) helps If it does, perhaps we could take it from there

  • ActiveSync, WM2005 and recovery