December 18, 2018 at 10:09 AMDec 18, 2018 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
December 18, 2018 at 11:02 AMDec 18, 2018 Hi, you may call "enumerate". In addition, you can register a listener that is called when your stack gets disconnected.
December 18, 2018 at 01:33 PMDec 18, 2018 Author 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^^
December 18, 2018 at 02:10 PMDec 18, 2018 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.
December 18, 2018 at 03:24 PMDec 18, 2018 Author 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.
December 18, 2018 at 03:38 PMDec 18, 2018 Author 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); .
December 19, 2018 at 07:55 AMDec 19, 2018 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.
December 22, 2018 at 10:13 AMDec 22, 2018 Author Thanks for your answer - especially regarding #2 I am waiting for some response from TF then...
January 7, 2019 at 10:30 AMJan 7, 2019 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.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.