-
Hi all,
I'm extending our inhouse agent platform to espruino and it seems that using apply() or call() is causing a very big slowdown. In my testcase it is between 0.5 seconds without and 15 seconds with call or apply. I'm not sure why this should be such a difference.. Can anyone shed some light on this?
My code is on here:
https://github.com/AlexDM0/espruinoEVE
The example file is espruinoCall.js
You can alter line 150 to see the difference.agent[message.content.method].call(agent,message.content.params,callback);
to
agent[message.content.method] (message.content.params,callback);
I tried putting it in a small example to show the problem but I think its due to the size of the objects that it's slowing down. I couldn't succesfully reproduce it in a tiny example.
-
Hi Gordon,
thank you for the reply :). I've sidestepped the issue for now by using a large random number and toString(36) with it. Is it a better practice in general to check if a key exists with "in" instead of "hasOwnProperty"? Is this both the case for normal javascript as well as espruino?
Regards,
Alex
-
Hi All,
My code is using and unique ID for messages that is randomly generated (say: acbdefghijklmnopqrstuvwxyz1234567890). If I put those IDs in an object and run hasOwnProperty on the object to look for the ID, it returns a WARNING: jsvGetString Overflowed.
this example shows the bug:
function foo() { var bar= {"acbdefghijklmnopqrstuvwxyz1234567890":2}; console.log(bar, bar.hasOwnProperty("acbdefghijklmnopqrstuvwxyz1234567890")); } function onInit() { foo(); }
Is this a bug or a limitation of the hardware?
Regards,
Alex
-
-
Hi all,
Suppose I have 25 espruinos communicating over ANT+, one is connected to the computer and gets a new function (or an updated function). What it the best way to send this to the other 25? Assuming I can send messages, should I create a function that does an eval of the function string, saves it as a local variable, uses function.replaceWith or function = to overwrite the existing functions and calls save()? Is there a better way to program my espruino's wirelessly, other than connecting to each individually and using the webide?
Regards,
Alex
EDIT: local variable containing temp function will ofcourse be deleted after overwrite is complete.
-
-
-
Hi Gordon, it seems using the code in your example crashed the espruino. I did find a workaround which will suffice for now but using the bind() function would be much neater. I have branched the bug off on my git, maybe it can help you identify a problem. I'm using the 1.60 firmware.
My Git is here: https://github.com/AlexDM0/espruinoEVE
The branch espruinoBug shows the problem. If you upload the entire code it hangs clearly. The bind command is on line 161. -
Hi Gordon, thanks for the reply! I'm dynamically constructing a function that is passed to an object. That object will then be free to call the function with it's own this. The reason why I dont simply use apply in the object (which will work too ofcourse) is that our current backend binds the this of the object to the function beforehand so the input files are already finalized.
I'll try to see if your example works for me! Thank you so much :) -
-
Hi Sacha, thank you for the explaination. I'll order the book you mentioned. Just to check, the coordinator can run normal code like the rest of the nodes or does it have to be dedicated to coordinating? From the espruino's point of view, would it matter which is the coordinator and which is a normal node?
~Alex -
Hi Sacha,
I'm sorry in advance for this probably stupid question but I've searched high and low but can't find a straight answer. As I understand it the Xbees create a mesh network that requires (at least? or ONLY?) one coordinator. The rest can be either routers or endnodes. My question is, can the coordinator just run normal code like the other nodes or does it have to be dedicated to only being a coordinator?
A few other questions I have are:
- what RSSI values can you get? Is it only from end to router or also from any node to any node?
- is it required to program the xbees on the PC using the usb cable interface or can you do it while connected to the espruino (or arduino) in init code?
Thanks so much for the module :)
- what RSSI values can you get? Is it only from end to router or also from any node to any node?
-
-
Hi Sacha, xBee would indeed be a very good alternative for my situation. I would really like to use the espruino because we are developing an agent platform for javascript. If xBee would be available that would be great! I require some kind of mesh network (or dynamic sets of star networks) that can pass information to every node in the system in under a second and an RSSI indicator for location approximation. Thanks for the great work!
Regards,
Alex
-
Hi Gordon,
Thank you for your response! It seems that pin 34 (orange label) acts as a walkie-talkie switch, when its pushed, the chip listens to AT commands, when released it doesnt and it just communicates with the connected device over serial.
I have also been looking into the nRF24L01+ you mention on your site. I have two of them here and I was wondering if there are any plans to make use of the Gazell Link system from Nordic? Also, I read the module code on git and I can't find any way to get the RSSI from that. Its a shame because it would really be a great option for us. Are there any future plans to incorporate these features? For now I'll stick to serial connecting and RFduino to the espruino.
Regards,
Alex
PS. if the USB cable is connected, bluetooth becomes Serial1, if I solder pins B6 and B7 to use the USART1 TX RX to talk to a RFduino, which Serialx do I use?
-
Hi Gordon,
Thank you for your reply! I have 2 espruinos talking to eachother now :) I would like to switch the master slave connection between 2 slaves and one master. So the master has to disconnect from the first and connect to the second. The problem I'm facing is that once a connection has been made, the AT commands are just sent over as text.. Is there anything I can do about that? I want the master to keep interpreting the AT commands. I've googled this quite a lot but I cant seem to find anything..Regards,
Alex
-
Hi All,
I just got around to playing with two espruino boards with HC-05 Bluetooth modules to see if this platform can be used for a multi agent system. I looked through git and on these forums but I cant find any hint as to if its possible to have two espruinos talking to each other over bluetooth. Can this be set up and can the espruino read out the signal strength?
Regards,
Alex
The timings are for around 10 calls. I'm sure its the same function. I rewrote the code so that apply or call are not required, though when I place them in there it slows down a lot. I'm not sure what you mean with the .foo? I have printed both "this"-es and they are the same with and without. The reason I needed the apply in the first place was that the methods were in a seperate object:
Agent has a number of functions and properties.. not necessarily huge, though shouldnt apply mearly change a pointer to the this object? The callback function contains a reference to the agent as well:
If I empty the callback
the difference in execution speed drops dramatically. Does apply or call copy the arguments including their references somehow?