Skip to content

SMlib does not run the next Head() #4594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dangu opened this issue Feb 19, 2016 · 3 comments
Closed

SMlib does not run the next Head() #4594

dangu opened this issue Feb 19, 2016 · 3 comments

Comments

@dangu
Copy link

dangu commented Feb 19, 2016

I downloaded the SMlib from here: http://playground.arduino.cc/Code/SMlib

When running some tests I noticed strange behaviour when a Set() was run inside the current state. The next Head() state was then not run, instead it continued on to the next Body(). Maybe this is best explained by an example:

SM MainSM(S1_head, S1_base);

State S1_head(){//Do something}

State S1_base()
{
MainSM.Set(test_one); // Here the next state is set to test_one
}

State test_one()
{
    MainSM.Set(S1_head, S1_base); // Here S1_head should be run the next exec BUT it never will,
                                      // as if(!Finished) Exec = &SM::Run; will overwrite FRun (in SM.h)
}

I could not find any github-codebase nor a maintainer to this library. Should I upload my own version to GitHub or how could this be fixed?

My suggested patch looks like this:

 SM.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/SM.h b/SM.h
index 9513399..89f7ff2 100644
--- a/SM.h
+++ b/SM.h
@@ -31,8 +31,8 @@ typedef void(SM::*PRun)();//defines runstate pointer
     };//Run()
     void FRun(){//runstate entry
       Mark = millis();//reset timer on entry
-      Head();//call head state function
       if(!Finished) Exec = &SM::Run;//set runstate to running
+      Head();//call head state function
     };//FRun()
     void Idle();//runstate finished
     unsigned long Mark;//timer mark
@per1234
Copy link
Collaborator

per1234 commented Feb 19, 2016

If you look at the history for that playground page you can see the author's arduino.cc user name is nilton61. There was another issue with this library of the examples not compiling with Arduino IDE 1.6.6+ reported recently #4537 and I sent the author a PM on arduino.cc notifying them of the required changes but I haven't heard back yet and their last forum post indicates they may no longer be using Arduino. Regular users are no longer allowed to upload files to the Playground but the webmaster did offer to add the updated file if requested. A GitHub repository would be much better because then we could just submit pull requests or issues to it.

@dangu
Copy link
Author

dangu commented Feb 19, 2016

Ok. Now I put my code here: https://github.com/dangu/SMlib
If nilton61 wants to, I would be happy to transfer the ownership of this repo.

@dangu
Copy link
Author

dangu commented Feb 22, 2016

The fix is now released as v1.3 and I have updated the page with links to this version here: http://playground.arduino.cc/Code/SMlib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants