Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Main loop still not working !!!


Question

Posted

Hi all

I tried to use main loop (I know it does not work very well) but nothing has changed. I just want to request an external card. Here is my code. It works well but crash after a few time !!!

Please login or register to see this code.

When I run the debug mode, here is the error message !!

Please login or register to see this code.

Line 4 is empty and it work during some hours so I don't understand why it crashed suddenly !!!

I have a proposition for fibaro team. A fine way to manage main loop could be to have same parameters as for a Unix cron.

Because main loop is execute each 3 seconds by default, we need to add sleep command to control duration !!! I think it is the reason of the crash

So according to me, a best way would be to add same parameters as a Unix cron

What do you think ??

Thanks

David

6 answers to this question

Recommended Posts

  • 0
Posted

It is a problem with json libray,

Put your code in a button, and call it for main loop.

  • 0
Posted

Shad, not with json library but with data what it's get, you should never send nill to parse, every code with crash on that

  • 0
  • Inquirer
  • Posted

    What do you mean with a problem with the json !!!!

    I would like to avoid to use button. It is the workaround I used before.. I used a scene triggered each 10 s calling a button in which I set global variable but I wanted to drop this solution

    [ Added: 2014-05-23, 11:04 ]

    Shad, not with json library but with data what it's get, you should never send nill to parse, every code with crash on that

    Socha : What do you mean ? what can I do to avoid that ?

    What do you think about my proposition to configure main loop ?

    Thanks

    David

    • 0
    Posted

    after that line check status and errorCode and later for sure check is response is not nill then it will work

    Please login or register to see this code.

    all must be before that line

    Please login or register to see this code.

    • 0
    Posted

    Your device on the other end fails to send the requested json, so hc2 receives an empty response, when you try to parse it, it fails as you can't parse an empty string.

    What you could try is something like this:

    Please login or register to see this code.

    That way, it won't try to parse an empty string.

    I think the HC2 lacks proper error handling as ther is no onError function to keep your loop going. It will simply crash if it runs into an error. So in case you have a big code and it runs into a small hickup, it will just terminate the entire code and that is an issue if your scene is supposed to stop a water pump or turn off an electric heater for instance. So proper error handling would be really nice.

    • 0
  • Inquirer
  • Posted

    ok thanks for all the answers....

    MAybe the error message is not very appropriate regarding my error...

    I will try that..

    Thanks

    David

    [ Added: 2014-05-26, 22:13 ]

    It doesn't works even when I take into account all your remarks

    About a few minutes or hours, "status" is empty. I don't receive any return code from "HC2:GET" function !!!

    I just need to save the device and it restart !!!

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...