Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


rapi events


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-18-2007, 10:15 PM
Junior Member
 
Join Date: Apr 2007
Location: Germany
Posts: 34
Unhappy rapi events

I am fiddling with RAPI, look at this code:
Sub Globals
End Sub

Sub App_Start
FormMain.Show
rapi.New1
rapi.Connect
End Sub

Sub rapi_Connected
Msgbox("PDA connected")
End Sub

Sub rapi_Disconnected
Msgbox("PDA not connected")
End Sub
I allways get the disconnect event, but never the connect event. What's wrong?
__________________
iPAQ 6515, MDA compact
Reply With Quote
  #2 (permalink)  
Old 10-19-2007, 08:13 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,346
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

I cut and pasted your code and the same happens on my system. I get the Disconnected event but not the Connected event.

I use an Axim X30 connecting to Vista and Windows Mobile Device Center 6.1.
Reply With Quote
  #3 (permalink)  
Old 10-19-2007, 09:18 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,346
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

I think that you - like me - have misunderstood how this works. I expected to run the program then connect the device then get the Connected event, it doesn't seem to work like that!

The device needs to have established a connection with the PC BEFORE the "rapi.connect" code is executed. Look at the example with a timeout in the overview of the help. Make the timeout large. Running the program then connecting the device never gives a Connect event. However connecting the device THEN running the program gives both events.
Reply With Quote
  #4 (permalink)  
Old 10-22-2007, 09:02 AM
Junior Member
 
Join Date: Apr 2007
Location: Germany
Posts: 34
Default

Agraham, thank you. I agree with you that the connect event ist only fired when you are trying to connect with the rapi.connect method.

But now I am totally confused ... I try to connect periodically by a timer event ... now I get a connect event even when the device is physically disconnected Please have a look at my attached example.

I am creating a file sync program, but this connect event is driving me nuts.

Attached Files
File Type: zip RAPItest.zip (22.7 KB, 9 views)
__________________
iPAQ 6515, MDA compact
Reply With Quote
  #5 (permalink)  
Old 10-22-2007, 11:55 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,346
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

I get the same effect when running your code from the IDE but I think that you are calling Rapi.connect too often. Slow the timer down to 5 seconds and the behaviour changes. However I think that repeated calls of Rapi.Connect are dangerous as I have crashed both the IDE and a separately compiled exe of your code by disconnecting and reconnecting the device.

It seems that it is best to treat Rapi.Connect as a "one-off deal". You only call it once per "run" of an application and it either connects or doesn't.

If you start the application without the device connected Rapi.Connect will not connect after the device is connected.

If you start the application with the device connected then Rapi.Connect will give a connect event and a disconnect event when the device is disconnected. Further (not too frequent!) calls to Rapi.Connect don't reconnect and can cause a hang if the device is reconnected.

A further consideration is that under the IDE it is the IDE that is seen to have issued the Rapi.Connect call so once a program under development has connected you have to exit the IDE and restart to connect again.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
ActiveSync and Rapi Lasse Questions & Help Needed 1 09-19-2007 01:25 PM
more events Sven Kommers Basic4ppc Wishlist 3 06-08-2007 09:53 AM
RAPI library leo Questions & Help Needed 3 05-23-2007 06:04 PM
Image Mouse events LineCutter Basic4ppc Wishlist 1 05-19-2007 10:24 AM


All times are GMT. The time now is 04:13 PM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0