OpenNetCF (Desktop Communications.RAPI) problem . Please help.

  • Thread starter Thread starter Sai
  • Start date Start date
S

Sai

Hi all,

I am using the Desktop.Communication library available here :
http://www.opennetcf.org/communication.asp

It's all good except for one problem that does not seem to go away.

I cannot get the event associated with the delegate RAPIConnectedHandler to
fire.

Here is my vb code which calls into the library.

Dim WithEvents objrapi As OpenNETCF.Desktop.Communication.RAPI
objrapi = New OpenNETCF.Desktop.Communication.RAPI(false)
'Other stuff

Private Sub objrapi_RAPIConnected() Handles objrapi.RAPIConnected
MessageBox.Show("Connected")
End Sub

The "Connected" message never appears. I tried changing the constructor
param to true but could not get it work. I need the event based mechanism to
be able to time-out in case the device is not in its cradle. Synchronously
calling the library (with the param=true), causes the code to wait
indefinitely on the constructor because CeRapiInit does not return if the
device is not in the cradle.

I'd greatly appreciate any help. Thanks
Sai
 
I am having the same issue. I have been working on it on and off for a few
days, and I have even emailed Chris Tacke about it.

I would also greatly appreciate any help, or an update at least. Thank you.

Jason
 
See my post above. The parameters aren't in the order specified by the
documentation.
 
I apologize, I should have explained myself more clearly. I am having issues
with the connected property, not copying files to and from the device. I
cannot get the RAPIConnectedHandler event to fire when initializing the
class non-blocking.


Jason
 
You might try something like putting a file in the root on the device,
rather than in a subdirectory and setting the filename to "\filename.ext".
If that works, that's a pretty good clue...

Paul T.
 
This is about the connected property issue.

My colleague and I looked at the RAPI code and found that the InitThread
method never gets called.
It seemed like the thread was not getting fired. So I added the thread.start
method and sure enough the InitThread method got called.

// create a wait thread
m_initThread = new Thread(new ThreadStart(InitThreadProc));

m_initThread.Start();

However, the following loop just runs indefinitely even though the device
was connected all along.

do

{

ret = WaitForSingleObject(m_hInitEvent, 250);

if((ret == WAIT_FAILED) || (ret == WAIT_ABANDONED))

{

throw new RAPIException("Failed to Initialize RAPI");

}

} while(ret != WAIT_OBJECT_0);

Thanks


Sai

P. S. : Dave Corun, kindly post different issues in different discussion
threads. This is leading up to quite a bit of confusion. Thanks.
 
Thanks, I made the changes that you described and I could see that the
thread now starts.

What are your values for int ret and m_hInitEvent? Mine are 258 and 3440,
respectively. I believe the problem is with the CreateEvent statement,
although I couldn't be absolutely sure. I believe the text for lpName
parameter is incorrect. I have looked around for quite a while and haven't
been able to find an example of when the createevent function was used for
this purpose. The lpName is suppose to contain the "object" that you want to
create the event for. then the waitforsingleobject is suppose to tell you
when that object has been created. at least this is how i understand it. I
am pretty sure that "OpenNETCF.RAPI" can't happen because there is nothing
named "RAPI" in the OpenNETCF namespace. This is all I have found. Any other
help would be appreciated because I can guarantee that I have missed
something.

Thanks,
Jason
 
This would be correct, i believe.



private void InitThreadProc()

{

RAPIINIT ri = new RAPIINIT();

ri.cbSize = 12;

int hRes = CeRapiInitEx(ref ri);

int hWait = WaitForSingleObject(ri.heRapiInit, 250);

m_connected = false;

if (hWait == 0)

{

m_connected = true;

}

CeRapiUninit();

}
 
Back
Top