Guest video: 5 Design and Coding Tips for QP-based Firmware

Поделиться
HTML-код
  • Опубликовано: 26 окт 2024

Комментарии • 7

  • @fredo514
    @fredo514 День назад

    About tip #2, does it really matter to reserve a range? I’m thinking that as long as the next group is keyed off the max of the previous one, you’ll be able to add and remove entries and just push around what comes after.

    • @mattheweshleman2323
      @mattheweshleman2323 13 часов назад +1

      Either way will help the project avoid human error.
      One possible issue with "keying off the max of the previous" is that it means that private signals will be exposed too, since that final private signal would have to be exposed to allow the next AO starting value.
      If we define ranges only, then it is up to each active object to define the signals within that range, and other AOs can avoid any knowledge of the other AOs. Mixed with a sprinkling of static_assert(...), the build will help protect from overflowing assigned ranges too.
      These concerns probably mainly apply to large projects where I want to avoid human error and also want to avoid too many inter-dependent modules from a compile time point of view.
      To some extent, just defining all the signals in a single header would take care of this too. But I just like the idea of: printf("sig: %d
      ", event->sig); having some clarity/directly by just visually looking at the value of the signal.

  • @jamebounes
    @jamebounes 2 дня назад

    Should the entire program be managed as a state machine or should the program be organized as a combination of multiple state machines?

    • @StateMachineCOM
      @StateMachineCOM  День назад +3

      It depends on what your program is supposed to do. Simpler programs can indeed be organized as a single state machine. However, a single-state machine can be in only one state at a time, which might not fit your problem. For example, communication software often must handle several communication channels, where each channel can be in a different state, so most naturally each channel should have its own state machine.
      Another limitation of a single state machine is the run-to-completion (RTC) processing. So, once it starts with an event, it must finish before processing another event. If this processing takes long, other events might not be serviced fast enough to meet your real-time constraints. The solution is to use different state machines running at different priority levels so the long-running RTC steps of low-priority state machines can be preempted by the high-priority state machines. All this means that in practice, you typically structure your programs as multiple state machines and have to deal with concurrency among those state machines. And here is precisely where the Active Object pattern and active object frameworks like QP come in.

    • @mattheweshleman2323
      @mattheweshleman2323 День назад

      I'll just re-iterate what @StateMachineCOM noted. Real world programs based on QP tend to involve dozens of active objects. Each active object has its own state machine.
      See the section Tip #3 - Define a Basic Software Architecture, where I discuss the top level executor and the N services. Each of those has its own state machine. Some of them might be very simple. Some complex. The drivers may (or may not) also consist of state machines.

  • @theangelofspace155
    @theangelofspace155 День назад

    It would be good to add QP definition to the title so people know what is the video about. I tuned because I love the channel's content, but I have not clue ehqt the video was about, or what you were talking about when you said "QP". If the video is aimed to a specific audience I guess it is ok.

    • @StateMachineCOM
      @StateMachineCOM  День назад

      Could you perhaps suggest a title that would be more informative?