Mac: Terminating USB Hub Communication?

  • Hey there guys, I've been writing some stuff for Arduino that I'm not so sure how to debug.

    Basically, the goal of one of the functions is: if the computer crashes (serial communication stops) then start reading data from the onboard memory rather than from the computer.

    While I'm fairly comfortable with how my code looks, I really don't know how to debug it.

    Is there a way to forcibly stop communication to the Arduino? If so, upon how can I be sure that my variable positions have been filled with the correct integers since "re-entering the arduino environment" would theoretically re-connect it to communication?

    I've been digging around and can't seem to find anything on the Arduino forums.

  • re knowing what happens, I've seen code that write to an internal stored log that you could then inspect after the fact, don't have a link, but it should be easy to find on the arduino forums.

    re forcibly stopp communication, you mean like unplug the USB?

  • HA.

    I guess this is what happens to me when I am thinking of too many things at once. I guess I could just unplug the Arduino and see if it sends signals to my DMX fixtures.

    Is there any other way to achieve the same effect though? Is there a difference between unplugging the arduino, and having the computer crash?

  • you can make a for loop with the condition that serial communication is available...

    then within that loop have another conditional loop that run the same code until a specific ascii message is received

    and then once again have a for loop that will exit once another message is received

  • sooo like this

    not connected to computer = onboard loop
    connected to computer before receiving ascii message 1 = onboard loop
    connected to computer after receiving ascii message 1 = computer loop
    connected to computer after receiving ascii message 2 = onboard loop

  • @alphanerd.

    Not sure if thats the same effect I'm looking for? I'm trying to see if my code will keep running even if the computer spontaneously crashes, which is necessary for the real-world application of the device.

    I don't think I would be able to send a conditional message to start reading from memory if the computer is down and out.

  • also fwiw... I don't think that the arduino does anything differently when connected to a computer... it can only notice when there is a message in the buffer through


    it returns the number of bytes in the buffer at any given time... it is your only method of telling if you are connected to the computer. But if you are connected and nothing is being sent, then you will get the same message connected or disconnected.

    I could very well be mistaken... but I believe that is how it works

  • I guess what you could do... is have you computer send serial messages at a given rate always... so every 10 ms you could have a message sent from the computer to the arduino... if there has been no change since the last message the message will be a placeholder

    then the arduino could have a timer function that could essentially tell if it has been so long since the last time I received a message go to onboard functions... once it receives messages again it will go back to original function