BoneScript keyboard input from a web page

I need a push in the right direction.

My project requires keyboard input from a web page. Each keypress requires the BBB to send a serial code to an Arduino. I was hoping to accomplish this using Bonescript and the http interface already served by Node.js.

I can see how to submit BoneScript code to Node.js from a web page… the example pages that come with the Debian image are quite helpful. But I’m stuck on two things:

  1. The BoneScript serial functions require an open, and subsequent serialWrite commands. Is it possible to open the serial connection with one call to demoRun and then do the serialWrite commands in separate calls? Or is the session not preserved? Would I need to do the open and write in one call?

  2. I know how to get keyboard input from the browser side javascript interpreter. But I’m not clear on how to get that over to the Node.js side. I suppose my browser side keydown event would just execute a demoRun call?

I’m new to Node.js and BoneScript. I have a feeling these questions should be obvious to me. Pointers to documentation that might help is appreciated.

I need a push in the right direction.

My project requires keyboard input from a web page. Each keypress
requires the BBB to send a serial code to an Arduino. I was hoping to
accomplish this using Bonescript and the http interface already served by
Node.js.

I can see how to submit BoneScript code to Node.js from a web page... the
example pages that come with the Debian image are quite helpful. But I'm
stuck on two things:

1. The BoneScript serial functions require an open, and subsequent
serialWrite commands. Is it possible to open the serial connection with
one call to demoRun and then do the serialWrite commands in separate
calls? Or is the session not preserved? Would I need to do the open and
write in one call?

You have to maintain a handle. You can use the active window to share the
handle globally. Your other code will need to have some ability to poll the
global object.

2. I know how to get keyboard input from the browser side javascript
interpreter. But I'm not clear on how to get that over to the Node.js
side. I suppose my browser side keydown event would just execute a demoRun
call?

If you use the BoneScript in-browser remote-procedure calls, that'd be
handled for you. Otherwise, I suggest you look at socket.io which is what
BoneScript uses for remote-procedure calls.

I’ve seen the mentions in the docs that BoneScript uses socket.io. But sometimes those references aren’t enough to let a newb know that’s where to look for info on a specific task.

Reading through the Chat demo on the socket.io site was a real eye-opener! That was exactly what I needed to make sense of the components that I need to tie together. Thanks for the pointer! And I can think of about a half-dozen other things socket.io will be good for as well.

Thanks!