I have a long code written in Arduino101 that works fine. I use a prepared function (connected to a library) in my code that I have not written it. My input to this function is an array. In 99.9999..% of the time, the function works great. However, it might stops due to an unknown reason, maybe because of my wrong input. This causes the program to stop. My question is: how to bypass this function if it fails for any reason? Something like 'on error' function in normal programming.

Thanks a lot in advance,

  • 1
    If it is because of your input being bad, then you need to check and validate that input. – Majenko Feb 24 '19 at 16:40
  • 1
    Please add more info to your question, mention that this is a follow-up of: arduino.stackexchange.com/questions/61867/… – Jot Feb 24 '19 at 16:46
  • Thanks, friends. I will focus on my code to find the root cause. – Mehrdad Feb 24 '19 at 20:07

If your function is crashing then there is no way to recover. Arduinos are unprotected real mode devices. If your code does something invalid, your program crashes and the device will likely either hang or restart.

You need to debug your function, or find the invalid data you are passing into it.

|improve this answer|||||
  • Thanks for your comment, Duncan. I will do so. – Mehrdad Feb 24 '19 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.