• Hi! In some cases, inline c can be called a bit more 'directly' - eg setWatch(..., {irq:true}).

    However for NFC and Bluetooth stuff it's not really possible - they are designed around a message queue, which pushes data from interrupt-land down to the message loop. By the time you're in the message loop and have seen that you're calling inline c, it's too late.

    Judging by your other posts about NFC/Inline C, I think you're at the point where you really want to be looking at compiling your own firmware to implement what you want - it's really not hard at all.

    is it possible to output to the console from inline c at all?

    In theory, yes. You have access to these functions: https://github.com/gfwilliams/EspruinoCo­mpiler/blob/master/src/utils.js#L74

    So you could do something like:

    var c = E.compiledC(`
    // int test(int)
    int test(int n){
      JsVar *p = jspGetNamedVariable("print");
      JsVar *s = jsvNewFromString("Hello world");
      jsvUnLock(jspeFunctionCall(p,0,0,false,1­,&s));
      jsvUnLock(s);
      jsvUnLock(p);
    }
    `);
    
    c.test(20);
    // prints 'Hello World'
    

    In a way it might be nice to have a bit of a standard library of functions (eg digitaWrite/etc) that can be called from Inline C

  • Hi! In some cases, inline c can be called a bit more 'directly' - eg setWatch(..., {irq:true}).

    However for NFC and Bluetooth stuff it's not really possible - they are designed around a message queue, which pushes data from interrupt-land down to the message loop. By the time you're in the message loop and have seen that you're calling inline c, it's too late.

    Would it be at all possible to call NRF.nfcSend or the native equivalent function from compiledC?

    I could be wrong, but it seems if hal_nfc_send, and hal_nfc_send_rsp were exported for web compilation that it could work purely from C without even another command once it jumps back to javascript

    I hope I'm not being too annoying with all these questions... just trying to figure out a way to write a fast script that doesn't require a custom firmware

    In a way it might be nice to have a bit of a standard library of functions (eg digitaWrite/etc) that can be called from Inline C

    Yes it would be...

About

Avatar for Gordon @Gordon started