bitlash: Can't save user functions to startup?

I hope I am getting it wrong, but after trying many times, I could define a new user function and fire it, but I could not set the system to fire it on startup, no matter what .

So in Arduino :

addBitlashFunction("ran", (bitlash_function) ran);

and the function

numvar ran(void) {


//also print not working .
 digitalWrite(13, HIGH);   // delay only for this matter
  delay(1000);                
  digitalWrite(13, LOW);     
  delay(1000);  

}

When you try to run it , it works, but if you try to

function startup { ran; } // here you get back “saved”

you get on boot the error - “unexpected number” , no matter what you do in this function.

I hope I am doing it wrong, otherwise whats the benefit of user functions ?

Thanks anyway!

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 27 (4 by maintainers)

Most upvoted comments

Curnelius:

May I offer a couple of points to close out the thread?

  1. I appreciate your apology. You have noted earlier in the thread that this project isn’t getting a lot of time. Threads like this are part of the reason. I’m in this for the fun, and it is simply no fun to provide help when someone takes an attitude. I hope you will think about how you might approach future requests for help with more light and less heat. If it isn’t fun, we’re not doing it right.
  2. When asked for a sketch, please provide actual working code copied from your text editor. There were two compiler errors in the code you sent which were easy to fix but which make it harder to help you because of the uncertainty about exactly what you were running there.
  3. It turns out your problem is easily resolved. You have found an old Bitlash bug, for which there is a simple workaround. As you discovered, a user function cannot be run directly from the startup function. However, user functions can be run from eeprom functions without problems at any time other than startup, which is sort of special. So the workaround is to add a ‘trampoline function’ for your startup function to call, something like this, where “myfunction” is the name of your user function:

function runit { myfunction; } function startup { runit; }

Since the user-defined function is not run directly from the startup function, the bug is avoided. This works here with the code you sent, amended to compile. I’d be happy to know whether or not this sorts out your problem, and good luck with your project!

  1. Tip of the hat to Tim: Yeah, I was out of pocket. Good eye.

Back to coding, everyone. And be careful out there.

-br