Logic Machine Forum
Javascript write to bus doesn't work - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Javascript write to bus doesn't work (/showthread.php?tid=2681)



Javascript write to bus doesn't work - jmir - 10.06.2020

Hi,

I've been trying to write an address to the bus using this javascript code:

$(function(){
  grp.write('2/5/1',true); 
});


Inside the browser console it appears this error:



Do you know what's happening? I'm pretty sure that I'd been using it before and it worked...

Thanks.


RE: Javascript write to bus doesn't work - Daniel - 10.06.2020

Do you have any object on this page?


RE: Javascript write to bus doesn't work - admin - 10.06.2020

Another possibility is that websocket is not connected yet. Try running the same grp.write call from browser console.


RE: Javascript write to bus doesn't work - jmir - 10.06.2020

(10.06.2020, 08:15)Daniel. Wrote: Do you have any object on this page?

Not in this sample. But I've tried adding an object and appears the same error...

(10.06.2020, 08:16)admin Wrote: Another possibility is that websocket is not connected yet. Try running the same grp.write call from browser console.

From browser console it works.


RE: Javascript write to bus doesn't work - jmir - 10.06.2020

How can we solve it?


RE: Javascript write to bus doesn't work - Daniel - 10.06.2020

As admin mention add a delay before sending

Code:
$(function() {   
  setTimeout(() => { grp.write('2/5/1',true) }, 2000); 
});



RE: Javascript write to bus doesn't work - jmir - 11.06.2020

Ok, Thanks!