On May 28, 8:27 am, [EMAIL PROTECTED] wrote:
> Hey all,
>
> A small question, I'm using java's serial communication
> (gnu.io.SerialPort) from Javascript, I have succesfully made a serial
> connection but I would like to add an event listener to it, and have
> it execute a javascript function when data becomes available in the
> serial port. One of the things I've tried is the following code, but
> this does not work. Does anyone here have experience with such a
> thing? Any help would be greatly appreciated!
>
> (javascript)
>
> port.notifyOnDataAvailable = true;
> port.addEventListener(function() {
>
> print("Data is here");
>
> });
>
> Kind Regards,
> Thijs.
Looking up this class, I see that gnu.io.SerialPort.addEventListener
expects a gnu.io.SerialPortEventListener. So you need an object of
that class. Rhino supports implementing Java interfaces using
JavaScript objects. I think the following should work (I haven't tried
it):
port.addEventListener(new
gnu.io.SerialPortEventListener( { serialEvent: function
(serialPortEvent ) { ... } ) );
--Norris
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino