An archive of as of Saturday January 26, 2019.

Weird ERPC issue


I had a nut that worked perfectly with 0.3. I updated to 0.5 and I have the strangest issue; I have a button that makes an erpc call. The Javascript code looks like this:

     // Button override on
     function OverrideOn() {
		 var erpctimeout = 10000;
         erpc("OverrideOn", null, function(result) {
         function(errStr) {
             document.getElementById("placeholder1").innerHTML = errStr;
             document.getElementById("placeholder2").innerHTML = errStr;
         }, erpctimeout);

The Squirrel code looks like this:

// OverrideOn
function OverrideOn()
bAuto = false;
OverrideOn = true;
OverrideOff = false;
// Resets for pump temperature
bReset = false;

Under 0.3 it worked perfectly. Under 0.5 the first time I click the button, it works fine. Every time I click it after that, it returns "Invalid method" in the "errStr" variable.

I debugged both the Javascript using Chrome, and it's doing what it should. I also put a breakpoint in the Squirrel code. The first pass it breaks. After that, nothing.

I have no idea how to proceed. Could it be something in erpc.js?


Which browser, version, and OS are you using?


Ubuntu 14.04 on Chrome 49.0.2623.110 (64-bit). Same thing with Firefox version 45.


It looks like the issue is the line:

OverrideOn = true;

The first time you make the erpc call, the global symbol OverrideOn points to the function. Once the function reaches that line, however, the global symbol OverrideOn changes to point to true, instead of the function. The next time you make the call, OverrideOn is pointing to true, which is indeed not a valid function.

Sounds like it was a bug in EOS 0.3 that got fixed! :bug:

You can solve the issue by changing the name of either your variable or your function.


Zach, thank you!

If when I first coded it months ago it didn't work, and it hadn't been working for months, I probably would have realized what was going on. But since most of the languages I use daily are strongly typed (C++, Java, Scala, etc), it didn't occur to me that after all this time it just "wouldn't work" rather than throwing an error.

Really appreciate it.