Avatar for ConorONeill

ConorONeill

Member since May 2017 • Last active Jul 2017
  • 2 conversations
  • 16 comments

Most recent activity

  • in Puck.js
    Avatar for ConorONeill

    Yup, that worked perfectly. Even with

    Puck.write(puckCommand);Puck.eval('new Date().toString()',function(x) { console.log(x); })
    

    Thanks!

  • in Puck.js
    Avatar for ConorONeill

    The final working code was:

    <html>
     <head>
     </head>
     <body>
      <script src="https://www.puck-js.com/puck.js"></­script>
      <script>
          var d = new Date();
          var n = Math.round(d.getTime()/1000);
          var puckCommand = String.fromCharCode(16)+"setTime(" + n + ")\n";
      </script>
       <button onclick="Puck.write(puckCommand);">Set The Time</button>
       <button onclick="Puck.eval('new Date().toString()',function(x) { console.log(x); })">Get The Time</button>
       </body>
    </html>
    

    I never got \x10 working in the code. As you said, there must be some HTML escaping going on somewhere.

  • in Puck.js
    Avatar for ConorONeill

    So the bad news is that \x10 or even \\x10 doesn't work (I've tried so many variations around that). The good news is that changing \n to \n in puckCommand solves the overall problem and eval() happily runs now after write(). Thanks for all the help!

  • in Puck.js
    Avatar for ConorONeill

    So I can replicate the write/eval error in devtools console when \x10 is excluded. But when I include it, it works, as you predicted. So I'm clueless as to why it's not working in the code on the page.

  • in Puck.js
    Avatar for ConorONeill

    Hmm. Typing that in the devtools console works for me too. I must be missing something very obvious.

    Code is on: https://conorpuckjs.now.sh/web_bluetooth­_set_time.html

  • in Puck.js
    Avatar for ConorONeill

    Still no joy. Same error which is very weird.

  • in Puck.js
    Avatar for ConorONeill

    What does the char code do? Disable echo?

    I'm getting a different error now:

    Uncaught SyntaxError: Got '\' expected EOF
    
  • in Puck.js
    Avatar for ConorONeill

    I've hit that problem a few times. e.g. right now one of my Puck.write() calls is working but when I follow it with a Puck.eval(), it throws a JSON error which turns out to be due to trying to parse

    Bluetooth.println(JSON.stringify(new Date().toString()))
    

    Still trying to figure out what interaction of write() and eval() is causing that to appear as the response to eval(). Doing two eval() in a row is fine. And if I do write(), eval(), eval(), the second eval() is fine so write() is causing some issue.

    <html>
     <head>
     </head>
     <body>
      <script src="https://www.puck-js.com/puck.js"></­script>
      <script>
          var d = new Date();
          var n = Math.round(d.getTime()/1000);
          var puckCommand = "setTime(" + n + ")\\n";
          console.log(puckCommand);
      </script>
      <button onclick="Puck.write(puckCommand);">Set The Time</button>
      <button onclick="Puck.eval('new Date().toString()',function(x) { console.log(x); })">Get The Time</button>
       </body>
    </html>
    
    
  • in Puck.js
    Avatar for ConorONeill

    Not sure what the best way to report that back to users is.

Actions