-
I have a native function in the firmware, and I want to call it from typescript. Here are two possible ways I managed to do it.
Or someother ways I don't know. Thank you for your help. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
This are pretty much the only two ways, and you correctly identified the trade-offs. For the 1st one you can implement a Jacdac action, not a property, but it's pretty much the same thing. It is the recommended way for use cases where speed is not critical. Note that similar interpreters, like MicroPython, only have the second option. One thing that we could do to improve the second option, is to allow arbitrary strings to refer to runtime methods and objects. That would mean you wouldn't have to update |
Beta Was this translation helpful? Give feedback.
-
Thank you for taking the time to share your insights. While I understand there are no immediate plans for its implementation, it's an interesting perspective to consider. Once again, thank you for your guidance. Looking forward to further collaboration. |
Beta Was this translation helpful? Give feedback.
-
One idea would be to support an APU similar to what we do for SPI currently: buffer in, buffer out and let the c++ layer listeners handle the packets. This avoid having to design JacDac services for low level primitive and would not have JacDac packet limitation |
Beta Was this translation helpful? Give feedback.
-
Hello, So I had idea to try to make an universal display driver for Devicescript, but I struggle with wiring Devicescript project with the C++ code. It seems reasonable to go the JacDac way, but I found no examples how to write "native function as a characteristic“. I am also not sure how to configure Devicescript project to install C library and compile the native code, so it can be called from the JacDac service. It there something like this implemented already? Thank you for help. |
Beta Was this translation helpful? Give feedback.
This are pretty much the only two ways, and you correctly identified the trade-offs. For the 1st one you can implement a Jacdac action, not a property, but it's pretty much the same thing. It is the recommended way for use cases where speed is not critical.
Note that similar interpreters, like MicroPython, only have the second option.
One thing that we could do to improve the second option, is to allow arbitrary strings to refer to runtime methods and objects. That would mean you wouldn't have to update
bytecode.md
but could instead check for existence of a method/object in normal JavaScript ways and fall back to some other behavior. However, there are no immediate plans to do it and I'm …