ealary Posted May 29, 2013 at 04:06 PM Posted May 29, 2013 at 04:06 PM Hi ! I want to use IPConnection to Enumerate each device connected to a Host (localhost for example) without user waiting (System.out.readline). How i can did that ? There isn't function to check that :/ Regards. ealary Quote
JavaLaurence Posted May 29, 2013 at 06:12 PM Posted May 29, 2013 at 06:12 PM Enumerating a stack configuration does not require user interaction. What is your issue with System.out.readXXX ? Quote
ealary Posted May 29, 2013 at 09:10 PM Author Posted May 29, 2013 at 09:10 PM My issue is that i want wait to enumerate all device in an Host (Can have many host) before doing any processing. The issue with System.out.read is to past this statement, an user should interact. Without System.out.read, ipcon are disconnected and we aren't certain had enumerated devices... (Sorry for my English) Quote
JavaLaurence Posted June 1, 2013 at 07:57 AM Posted June 1, 2013 at 07:57 AM After re-reading what you wrote a few times (yes, I'm afraid your English is poor), I think I understand what you mean. I'm afraid the core issue is how to coordinate multiple threads. The enumeration callbacks are called on a different thread than your own application thread. The callbacks are performed by a thread that is started by the Tinkerforge framework. There are two approaches to solve the problem: a) the hack: include a hard-coded delay of a few seconds b) the proper way: use proper thread synchronization (e.g. using wait/notify, or any of the higher level concurrency mechanisms in java.util.concurrency). The hack will probably be OK, and is just a matter of calling Thread.delay(). HTH Quote
JavaLaurence Posted June 1, 2013 at 05:42 PM Posted June 1, 2013 at 05:42 PM (correction) .. make that last API call Thread.sleep(). Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.