Avatar for jgrizou_email_login


Member since Apr 2021 • Last active Nov 2022
  • 0 conversations

Most recent activity

  • in JavaScript
    Avatar for jgrizou_email_login

    @Abhigkar thanks for asking, I just exported and uploaded them at https://github.com/jgrizou/phonebot/tree­/main/stl

    You can find the original design on OnShape at https://cad.onshape.com/documents/858420­b45d74a6c130741a27/w/ccd74c6c91d1447417f­fa0b3/e/e34cca09c53379cb87889070?renderM­ode=0&uiState=62501d0795faa529ca2ae411

    You should be able to copy this and make modification as needed.

    I hope this helps!

  • in JavaScript
    Avatar for jgrizou_email_login

    Thanks for the feedback!

    As I understand it, UART.write/eval will create a connection (internally) and will then use that - so if you're writing to just a single device then that's all you need. You're prompted on the first call and after that it 'just works'.

    Yes. My only issue is that I want to explicitly connect to the device before sending commands, to be sure the robot is ready and two way communication is established before starting the control loops.

    I guess a work around is to trigger a connect by sending an empty UART.write('\n') and then use isConnected and getConnection. I will try and let you know how it goes!

  • in JavaScript
    Avatar for jgrizou_email_login

    Hi, I have tried to work on this a bit and got confused by the use of connections in uart.js.

    I would like to use the nice utility functions UART.write() and UART.eval() but do not want them to trigger their own connect event (that is showing up the select a port screen). I would like to connect only once when the user decides to and be able to all operations from there.

    But using the connection.on("data", cb) pattern and the write() and eval() helper function from UART seems incompatible as the UART.write() and UART.eval() are using their own separate internal connection variable.

    It feels not optimal to have to duplicate that part of the code: https://github.com/espruino/EspruinoWebT­ools/blob/13032d0e862d9976ed5eed33b42f07­e93e6c25c3/uart.js#L403-L500 entirely to replicate the UART functionalities from a connection that I would open using the method described in https://www.espruino.com/Web+Bluetooth#t­wo-way-communications

    This is actually commented in the code by saying that the UART.connect function output a connection different from the one used by write() and eval(), see image attached.

    I guess my questions are:

    • Is there a way to do both these things at once? For example adding a custom connection.on("data", cb) on the same connection used by UART.write() and UART.eval().
    • If not, because this would interfere with each others, is there a way to connect to two connections at the same time? So I could develop a tool that can use both functionalities but the user would only see one connection screen.

    If that does not work, I guess I will have to reimplement something similar to write and eval functionality but with the connection.on("data", cb) working somehow on the with it.

    I am guessing I am a bit confused with how connection works under the hood but I hope that makes some sense :)

    Thanks in advance for any guidance on that!