flodo Posted December 18, 2018 at 10:09 AM Posted December 18, 2018 at 10:09 AM Hi there! Is there any way (without rebooting) to update the list of connected bricklets on a master brick? (I would like to check if the "connection" to the bricklet is still good). Cheers, Flo Quote
Equinox Posted December 18, 2018 at 11:02 AM Posted December 18, 2018 at 11:02 AM Hi, you may call "enumerate". In addition, you can register a listener that is called when your stack gets disconnected. Quote
flodo Posted December 18, 2018 at 01:33 PM Author Posted December 18, 2018 at 01:33 PM thank you for your answer! I am not sure if we understood each other correctly: My problem is, that the Master Brick is not informed when the connection to a bricklet (like the US Distance bricklet) is interrupted. I tried the ipcon_enumerate(&brick_connection); you suggested, I then diconnected the bricklet from the master brick but unfortunately the distance_us_get_distance_value(...) function does still return sucessfully - which is a bit strange I think^^ Quote
Equinox Posted December 18, 2018 at 02:10 PM Posted December 18, 2018 at 02:10 PM Hi, ok, right, it was a misunderstanding. The listener I was talking about is for disconnects of the IP connection. Actually, I don't know whether there's a listener/functionality to get informed about a disconnected bricklet. What happens if you call "enumerate" after you disconnect the bricklet? It should not appear again. What is your use case? I mean, normally, a bricklet shouldn't get disconnected by accident. The cable must actively be removed. Quote
flodo Posted December 18, 2018 at 03:24 PM Author Posted December 18, 2018 at 03:24 PM My use case is the following: I am running a self-test after startup which compares all bricklets defined in a config-file to those which are connected. If one is not connected, then the user sees some kind of error-message, the application waits until the user plugs in the missing device and continues to check the next one. Quote
flodo Posted December 18, 2018 at 03:38 PM Author Posted December 18, 2018 at 03:38 PM Update: If have three problems now: 1) How do I know if all bricklets have already called the callback yet? How long do I have to wait at worst? 2) Do I need mutual exclusion inside the callbacks? (Or is it guaranteed that they are invoked one by one)? 3) Looks like the bricklets-list is not updated anymore after booting up, you can even disconnect a bricklet - the corresponing callback is still invoked when calling ipcon_enumerate(&brick_connection); . Quote
Equinox Posted December 19, 2018 at 07:55 AM Posted December 19, 2018 at 07:55 AM Hi flodo, i.e., you just check at startup time and you don't need to check once the system is up and running? --> Only "periodic" check at startup required until "all" bricklets are checked? Regarding 1) Good question. In my case, I know which bricklets are connected and I wait until all of them have sent a call/event for the enumeration. I think if you wait 100ms per bricklet, that should be enough (if time doesn't matter, I would wait even longer). But maybe that should answer someone from TF. Regarding 2) You don't need mutual exclusion. You will have only one call at a time. Regarding 3) Hmm, right, that's possible :-( As far as I know, the bricklets are not hot-plug capable. That would mean that you cannot detect added or removed bricklets after startup. But I think someone from TF should confirm that. Quote
flodo Posted December 22, 2018 at 10:13 AM Author Posted December 22, 2018 at 10:13 AM Thanks for your answer - especially regarding #2 I am waiting for some response from TF then... Quote
photron Posted January 7, 2019 at 10:30 AM Posted January 7, 2019 at 10:30 AM flodo, what you're trying to do is called hotplug, this is not supported. Therefore, there is no API to detect it. You cannot connect/disconnect Bricklets while a Brick is powered/running. What you can do is check if the required Bricklets are connected using the enumerate mechanism. If some are missing advise the user to disconnect the Brick from power, connect the required Bricklets and the power the Brick again. 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.