Exception Handling - Wiznet / I2C / General

Posted on
  • Hi

    I've been experimenting with Wiznet and I2C, and I've been caught out a couple of times by the lack of exception handling.

    For example, with I2C, if there's something wrong it seems Espruino shows a "Timeout" error and the program aborts. I wanted to write a loop writing to the bus, so I could put a scope on it - and I don't seem to be able to do this at all, because the error is too fatal.

    Anyone else have this problem? Right now I don't particularly want a full exception implementation - just something that allows transient errors to be non-fatal.

    Thanks

    Martin

  • Yeah - honestly, I know we aren't going to get real exception handling, but I'd like to be able to have an option for "Do not remove offending callback when error occurs while running it".

  • Yeah - I'd really like to have an option for "Do not remove offending callback when error occurs while running it".

    I'm fine with this being a global setting, or even one that required flashing a different firmware for, or peek/poke, etc, as it's an advanced functionality.

  • DrAzzy

    My problem was even simpler, just writing this in the IDE window:

    while(true)
    {

     I2C1.writeTo(0x26,1);
    

    }

    failed if the I2C was disconnected - the program stops with something that looks like a syntax error.

    This isn't right, IMHO - a runtime communications failure should return an error code, not a system-stop!

  • I agree!

  • Are you actually using 1v62? If I do it, I get:

    >I2C1.writeTo(0x26,1);console.log("Hello­");
    WARNING: I2C device not responding
    Hello
    

    So it doesn't stop execution. I know 1v61 did and it was a pain, but it should be fixed now...

    The plan is to add exceptions in the long term, but as I understand it's a bit of a minefield. While I could implement something very workable quite easily, I think to get a standards compliant implementation is quite hard.

    Having said that, standards compliance is probably not such a big issue with that. If you're using exceptions for anything other than error handling, you probably deserve everything you get :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Exception Handling - Wiznet / I2C / General

Posted by Avatar for mgg1010 @mgg1010

Actions