Thread: rapi events
View Single Post
  #5 (permalink)  
Old 10-22-2007, 12:55 PM
agraham's Avatar
agraham agraham is offline
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,700
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
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