Giter VIP home page Giter VIP logo

Comments (3)

FabrizioRomanoGenovese avatar FabrizioRomanoGenovese commented on June 8, 2024

By the way, I ran some tests using sizeOf. A state should occupy 32 bytes, while a transition occupies 40. Given this, at the moment my states occupy 2400 bytes, while my transitions occupy 8040 bytes, for a total of 10440. My chip should have ~90KiB of memory for instructions, so I should be well within that limit.
Moreover, I checked https://github.com/jonblack/arduino-fsm/ to which this library is inspired: In https://github.com/jonblack/arduino-fsm/blob/master/Fsm.cpp the way to add transitions is incremental (it doesn't recurse over an array, but adds transitions one by one at user request). In particular, immediately before adding a transition, memory is reallocated by giving:

 m_transitions = (Transition*) realloc(m_transitions, (m_num_transitions + 1) * sizeof(Transition));

I tried to do the same in the function I defined in the comment above, adding the line:

transitions = (Transition*) realloc(transitions, (num_standard + size) * sizeof(Transition));

just before the for cycle. This has the only effect of putting my chip in a cycle of crashes.

from simplefsm.

FabrizioRomanoGenovese avatar FabrizioRomanoGenovese commented on June 8, 2024

Ok, solved it. Created a pull request in case someone is interested: #7

from simplefsm.

LennartHennigs avatar LennartHennigs commented on June 8, 2024

Hey Fabrizio,
thank you for your issue report and for your pull request!
Will review your code and merge it.
🙇

from simplefsm.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.