flodo Geschrieben December 18, 2018 at 10:09 Geschrieben December 18, 2018 at 10:09 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 Zitieren
Equinox Geschrieben December 18, 2018 at 11:02 Geschrieben December 18, 2018 at 11:02 Hi, you may call "enumerate". In addition, you can register a listener that is called when your stack gets disconnected. Zitieren
flodo Geschrieben December 18, 2018 at 13:33 Autor Geschrieben December 18, 2018 at 13:33 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^^ Zitieren
Equinox Geschrieben December 18, 2018 at 14:10 Geschrieben December 18, 2018 at 14:10 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. Zitieren
flodo Geschrieben December 18, 2018 at 15:24 Autor Geschrieben December 18, 2018 at 15:24 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. Zitieren
flodo Geschrieben December 18, 2018 at 15:38 Autor Geschrieben December 18, 2018 at 15:38 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); . Zitieren
Equinox Geschrieben December 19, 2018 at 07:55 Geschrieben December 19, 2018 at 07:55 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. Zitieren
flodo Geschrieben December 22, 2018 at 10:13 Autor Geschrieben December 22, 2018 at 10:13 Thanks for your answer - especially regarding #2 I am waiting for some response from TF then... Zitieren
photron Geschrieben January 7, 2019 at 10:30 Geschrieben January 7, 2019 at 10:30 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. Zitieren
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.