RPCFunction lock up ?

03 Feb 2011

Hi, I'm repeatedly calling an RPCFunction from javascript in a web page, once per second. After a few minutes I find that my http server stops running and I have to reset the MBED to get it back. My code is basically the same as "RPCDemo" but calling an RPCFunction instead of reading an analog input. If I read the analog input it runs forever ! My RPCFunction is as simple as possible - all it does is write a string to the output. Please see my code posted in the comments on the "Interfacing with javascript" cookbook page. Has anybody else tried repeatedly calling an RPCFunction ?

Thanks - Pete.

03 Feb 2011

Hello Pete,

i ran into a bug with same results. The max lenght of the RPC String is defined in RPCFunction.h to 64 chars.

#define STR_LEN 64

Check the length of your string and change the define.

Peter

03 Feb 2011

I have replicated the RPCFunction lock up that Pete described (using his test program). After about 8 minutes the program crashes.

I don't think the problem is related to the STR_LEN, as Peter D suggests. The strings being passed back and forth are only a few bytes. Just to be sure, however, I changed STR_LEN to 1024. It had no effect on the problem.

It smells like a memory leak in the code that handles the rpc function request.

04 Feb 2011

I believe I have found a solution. There is a modified version of the RPCInterface library in my notebook, http://mbed.org/users/hexley/libraries/RPCInterface/lm1vb4. It adds a "delete" statement to one of the modules to prevent memory leakage.

Using this version of the library, the program doesn't crash after about 530 passes, as it did before.

BTW, in the course of playing with this, I also modified the web page javascript to take out the setInterval call of tick(), and to re-cast the contents of tick as a while(1){} endless loop. I was concerned that tick() period might have been shorter rate than the interval needed for the three rpc calls to complete.

04 Feb 2011

Well done Hexley ! That seems to make sense - I will try it over the weekend.

Pete.

04 Feb 2011

Hi

Great work finding and fixing that problem. I've added your fix to my version of that library so updating the library in the compiler will also give you the fixed code. Thanks Michael

04 Feb 2011

Thanks for picking up the update, Michael. I'll plan to remove the trial library from my notebook shortly, since you have incorporated the fix in the main library.

05 Feb 2011

Hi,

I have been trying to replicate Pete's work discussed in this topic but have not been able to get the RPCFunction to work, i.e. I do not see the "Hello" and "Bye" appear on the web page. I have imported Pete's HTTPServer program from http://mbed.org/users/pbaston/programs/HTTPServer/lm267o and copied the web page from his comments on the "Interfacing with JavaScript" cookbook page at http://mbed.org/cookbook/Interfacing-with-JavaScript. I have the JavaScript mbedRPC Library. I have updated the libraries. If I substitute Michael's original analog read function then I see the result update every second so I think that I am basically on the right track.

Any ideas on where I may have gone astray?

Thanks, Peter

05 Feb 2011

Peter Ampt wrote:

I have been trying to replicate Pete's work discussed in this topic but have not been able to get the RPCFunction to work, i.e. I do not see the "Hello" and "Bye" appear on the web page. I have imported Pete's HTTPServer program from http://mbed.org/users/pbaston/programs/HTTPServer/lm267o and copied the web page from his comments on the "Interfacing with JavaScript" cookbook page at http://mbed.org/cookbook/Interfacing-with-JavaScript. I have the JavaScript mbedRPC Library. I have updated the libraries. If I substitute Michael's original analog read function then I see the result update every second so I think that I am basically on the right track.

Hi Peter, you may need to update your mbedRPC.js file. There was a problem in the RPCFunction section near the bottom, which has now been fixed. Somebody points this out in the comments on the "Interfacing with javascript" page. Pete.

06 Feb 2011

Hi Pete,

Thanks for pointing out

Pete Baston wrote:

Peter Ampt wrote:

I have been trying to replicate Pete's work discussed in this topic but have not been able to get the RPCFunction to work, i.e. I do not see the "Hello" and "Bye" appear on the web page.

Hi Peter, you may need to update your mbedRPC.js file. There was a problem in the RPCFunction section near the bottom, which has now been fixed. Somebody points this out in the comments on the "Interfacing with javascript" page. Pete.

Hi Pete,

Thanks for the pointer to the mbedRPC.js file fix; I should have looked harder. All now works as it should. Thanks very much for your help.

Peter