Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Programming Software IT Technology

Software Diagramming In Embedded Systems? 52

afd100 writes "I work for a medium-sized company building embedded systems using C. As of yet, we do not have a great design methodology, but it is something we're working on. For the last 7 years now, we've been documenting our embedded software in an IEEE'esque Software Detailed Design, and using a very cryptic block diagram to explain our software. What does the embedded software community at large currently use to graphical represent their software or do they even try this? Since the programming is functionally decomposed, is UML the right way to go?"
This discussion has been archived. No new comments can be posted.

Software Diagramming In Embedded Systems?

Comments Filter:
  • Real Time UML (Score:3, Interesting)

    by H0p313ss ( 811249 ) on Wednesday June 25, 2008 @04:15PM (#23940149)
    There are a number of commercial UML solutions for embedded and real-time systems. e.g. Rhapsody [telelogic.com] which with IBM's acquisition of telelogic becomes the natural upgrade path for system development with UML.
  • Since the programming is functionally decomposed, is UML the right way to go?

    UML is what everybody uses (in my environment at least). A lot of aspects of UML assume object-oriented programming, but nobody stops you from cherry-picking whatever is in UML.

    Of course you can think of objects as structs in C, and you can go a long way. However, I found that thinking in objects requires exercise. At first, you'll have people on your hands that will think of your regular C API as an object -- which is not alwa

  • by JCSoRocks ( 1142053 ) on Wednesday June 25, 2008 @04:20PM (#23940245)
    Personally, I just refer to this diagram [xkcd.com]. It's the 42 of diagrams. You don't need any others.
  • by dissipative_struct ( 312023 ) on Wednesday June 25, 2008 @04:34PM (#23940515)

    If you've got a reasonably small code base you might want to keep the documentation style you've got. I'm not sure what a "very cryptic block diagram" looks like, but a simple drawing showing the functional blocks of your software may be good enough. For smaller embedded projects I've done in C or assembly (2-4 people on the team, 10K lines of code, minimal use of 3rd party code other than maybe the C std lib) this is the design/documentation style I've used:

    1) Create an architectural design. Identify the main functional blocks of software in a drawing, include a one-paragraph explanation of what each block does.
    2) Define the external interfaces, from the physical level on up. Define any internal interfaces necessary to support development, but don't go crazy, internal interface documentation is hard to maintain.
    3) Code to the design. The "detailed documentation" is the comments you put in the code. Every file, function and most globals should have a brief comment describing what it contains or what it's for.

    For a simple embedded system I've found this is a good approach. Things that will require a higher level of documentation: large code size, library-type code that will be heavily reused in the future, a large number of developers. Embedded systems are often a very different animal than applications, and some embedded software is inherently not reusable.

    The real question you should ask yourself is "What extra help am I getting from my new documentation format, and does it justify the extra time I'm going to be putting into it?".

    • I've been building embedded systems for a very long time now and find that pen + paper or whiteboard diagramming is often the best. Big paper: A1 (American D). If you want to write it up in a document then photograph it and put the picture in the document.

      This approach has given the best bang for bucks that I have seen.

      • by bhima ( 46039 ) *

        I've been doing it for a while now, too. I use post-it notes and highlighters. You'd be amazed how many sizes and colors people are selling post-it note in.

  • by Cyberax ( 705495 ) on Wednesday June 25, 2008 @04:39PM (#23940591)

    Ditch your diagrams. They're far too often used to:
    1) As a thing to show boss that you're working.
    2) Unnecessary cruft which no one uses.

    About the only case where diagrams are helpful are FSM diagrams.

    • Re: (Score:3, Informative)

      by H0p313ss ( 811249 )

      About the only case where diagrams are helpful are FSM diagrams.

      UML includes state machines, real-time UML is all about state machines.
    • The only time I've ever had diagrams help me is when I am designing complicated data structures, particularly self-balancing trees and the like. Other than that, they're pretty useless.

    • Re: (Score:3, Insightful)

      by ericlj ( 81729 )

      In my experience, the only time diagrams are worthwhile (unless required to get paid) are if you manage to find a tool that will generate usable code from the diagrams. Otherwise, the diagram and the code will always disagree in any system complex enough to be useful.

      • Like this one, though I suppose I should get the bloody installer working if I'm going to slashdot myself: http://www.statesharp.net/ [statesharp.net]

        FSM diagram tool that generates code.

        I wrote it because if your diagram doesn't generate your code, or vice versa, then they *will* get out of sync, and the only thing worse than no documentation is *wrong* documentation.

    • Re: (Score:2, Redundant)

      2) Unnecessary cruft which no one uses.

      I disagree completely. If you have ever walked blindly into a system with nothing but code and diagrams to help you through, you'd know that those diagrams are invaluable. Unless you want to waste man power by having another architect hand-hold your way through the system for hours/days/weeks until you've got a firm grasp on it, there's just no substitute for well-made design docs.

      I think the notion of "diagrams are useless" spawns from system architects who don't have the foresight to realize that diag

      • Re: (Score:3, Informative)

        by Cyberax ( 705495 )

        I did this many times. UML class, use-case and sequence diagrams were NEVER helpful - it's just much easier to explore code with a good IDE.

        The argument that a new architect will have to spend days familiarizing with the code is moot. Architects are arguably THE main people in a project - their mistakes can cost A LOT. So I'd rather let him/her spend some time and get acquainted with the code and code 'style' then let him/her rush into drawing more diagrams.

        Also, diagrams have a very nasty habit to fall out

        • I did this many times. UML class, use-case and sequence diagrams were NEVER helpful - it's just much easier to explore code with a good IDE.

          The argument that a new architect will have to spend days familiarizing with the code is moot.

          I disagree. I've found that whenever I join a project where they have UML diagrams, it's much easier for me to understand the code - specially if it's a big project.
          • by jythie ( 914043 )

            Might have something to do with learning style. Some people seem to benefit from the way UML lays things out, other people find them more frustrating then just looking over the headers or example code.

      • Seconded, regardless of whether the project is embedded ASM, JEE, Ada, or whatever. I've walked into a number of projects, either late-in-the-game when the project needs saved, or well afterwards when changes need made, and invariably the code is badly commented, buggy, and may or may not do what was intended. In situations like this, people go into ass-covering mode, so information is hard to get anyway... You just don't have time to sift through thousands of lines of code, figure the intent, find the bugs

      • As someone who has stepped into an extremely large project with no diagrams - I can say that I really, really wished there had been some. Instead, what I got were really awesome hand-drawn scribblings on my whiteboard and notepads by senior developers. Better than nothing, but not nearly as useful as a comprehensive diagram of the whole system.

        I now make it a habit to write documentation and use diagrams to help others in my group as well as anyone coming after me. I think we all know we won't be working a
      • by jythie ( 914043 )

        I don't know, as a 'someone else' I find diagrams pretty useless for understanding a system. A good API document, spec, or header file directory does wonders.

    • by lysse ( 516445 )

      And then, presumably, only to those who have been Touched by His Noodly Appendage...

    • by raddan ( 519638 ) on Wednesday June 25, 2008 @07:02PM (#23942439)
      Since I am currently in the middle of drawing one (and yes, I'm kinda spacing out, reading /.), I would also argue that ER diagrams [wikipedia.org] are useful. Just the drawing of them makes you think through some things that might never have occurred to you if you just started creating tables in a database.
    • by jgrahn ( 181062 ) on Wednesday June 25, 2008 @07:56PM (#23943091)

      Ditch your diagrams. They're far too often used to: 1) As a thing to show boss that you're working. 2) Unnecessary cruft which no one uses.

      And/or 3) something everyone except the boss knows is out-of-date and dangerous to refer to for anything important.

      It's strange that the question explicitly asked for diagrams. What if this particular system is better described in plain text -- should there still be diagrams instead?

      Apart from that I only have three pieces of advice:

      • Any documentation which isn't under revision control together with the software is doomed to fail. That means among other things it has to be inside the source code, or in separate plain text files (so your changes can be merged with my changes, and so they can be reviewed alongside the source code).
      • Spend a day or two with doxygen. Make sure you enable its graph-rendering capabilities, and then play with different settings. You can get quite a lot of overview and insight from its output, and it supports plain C.
      • Doxygen cannot capture the architectural decisions and rules. Those that change rarely should, I think, be written down in plain text by someone who knows a lot about the system and who can write readable technical documentation. But for the volatile details, I'd rather trust the source code (and the views of the source code which doxygen, emacs, various IDEs ... can offer).
    • About the only case where diagrams are helpful are FSM diagrams.

      Flying Spaghetti Monster Diagrams?

      His noodly appendages don't take kindly to being diagrammed you insensitive clod.

    • by Zet ( 178940 )

      > Ditch your diagrams.

      This is simply wrong. A good diagram will clearly
      reflect your actual design. And the exercise of
      creating one will often highlight problems in what
      you are doing. Not only that, it will show, in a
      non-code representation, what your intent is, and
      this allows others to verify it (and makes sure they
      are thinking what you are thinking).

      Documentation is a fundamental part of good design.
      Skipping it is evidence of weak engineering
      discipline.

  • by Keick ( 252453 ) on Wednesday June 25, 2008 @04:44PM (#23940697)

    I too work in embedded systems, more specifically aircraft controls. In most of our design documents we tend to keep the design to the interface level of each software component (CSC), and the interaction between them. Drawing this is usually down using more simple drawing elements than that of UML. Draw a couple of boxes to show your major components, and label the interfaces of those. In subsequent sections, show only one of the components at a time, with a drawing of its sub-components if applicable. Only go about 3 levels deep if at all possible here. The attention span of most reviews will get lost after that. Besides, your requirements already specify WHAT has to happen, your only job here is to specify WHERE those requirements happen.

    While UML is nice, I have found that most of the reviewers of these types of documents are not UML savvy. The one drawing mechanism of UML that I do find invaluable in this line of work is the sequence diagrams. Large amounts of requirements can often be shown more precisely by a sequence diagram, detailing the interactions between a handful of component interfaces at a time.

  • by Shade of Pyrrhus ( 992978 ) on Wednesday June 25, 2008 @05:18PM (#23941087)
    Take it a step up and evaluate some modeling languages and tools, such as AADL and OSATE.

    http://www.aadl.info/ [aadl.info]

    This stuff is MADE for real-time, embedded systems. The ultimate goal is to use it through design and analysis, and then go ahead and generate code. It does take some getting used to, and there is a lot to it so keep that in mind.

    It's not perfect, and still under development, but very cool. So give it a try, see if you can pick it up. I'm generally a supporter of UML, but after being introduced to AADL and OSATE in an architecture course I was eventually convinced that it could be better than UML for this field.
  • Statecharts (Score:5, Informative)

    by Dr.Who ( 146770 ) on Wednesday June 25, 2008 @05:27PM (#23941205) Homepage

    Most times when people think about using flowcharts, they really should create state transition diagrams http://en.wikipedia.org/wiki/State_diagram/ [wikipedia.org] to discuss, describe, and document behavior. Statecharts are an improvement on earlier state transition diagrams and are included in the latest UML specification.

    Some Statechart references:

    1. Samek, Miro; Montgomery, Paul: State-Oriented Programming. Embedded.com. 2000-08. http://www.embedded.com/2000/0008/0008feat1.htm/ [embedded.com]
    2. Samek, Miro: Practical Statecharts in C/C++: Quantum Programming for Embedded Systems. CMP Books. 2002-07. http://www.amazon.com/exec/obidos/tg/detail/-/1578201101/002-2659023-9156009/ [amazon.com]
    • by DrEasy ( 559739 )

      I'd say the opposite is true too: most times when people draw a state transition diagram, they're really drawing a flowchart.

      State transition diagram are exactly that: to show the transitions between states in a system. You first need to determine what are the events that your system responds to, and then, for EACH state in the system, determine what happens in response to such events. "What happens" can be, but isn't always, a transition to another state. The benefit of such a diagram is that you make sure

  • You might also want to look into SysML, which is a lot like UML with a few extra diagrams for modeling systems.
  • UML can be helpful at times. The tricky part is keeping the design in sync with the current state of code. You may design a system a certain way initially, but as you fix bugs and improve functionality, the original design documents become stale. I find the javadoc and doxygen (http://doxygen.org/) way of API documentation to be very helpful. Even Visual C# has integrated helpful API documentation techniques into the environment. This allows you to keep the documentation with the code, and it allows you to
  • by Bruce Powel Douglass explains how to use UML to model real-time embedded systems. I picked it up when i needed to come up with graphical designs for my senior thesis a couple of years ago. I had never once worked on a real-time system but this book helped me a lot in that it stresses the importance of the state and sequence diagrams (as many previous posters are also). Douglass does a good job of showing how to use the state diagram and nested states for multi-threading which helped me on my specific pro
  • Use well commented clear code. On top of it use technical notes to explain the design and implementation of the system at a moment in time along with the requirements at that moment in time. Concerning UML, there was a recent thread on slashdot: Is UML Really Dead, Or Only Cataleptic? [slashdot.org]
  • by Anonymous Coward

    My background is close to 20 years in embedded software in the aerospace environment. Most of the time, the process by which we got to SDR, including prior SSR and PDR, was dictated by higher management (read: pointy haired types), often based on a MIL2167A-like scheme, and generally ignored after CDR.

    What you need is:

    1) Written system requirements that are formally controlled, precise, unambiguous and testable. The precise format doesn't matter much as long as it's consistent inside the project and there i

  • If you are thinking of using the diagram as a means to share your design concepts and inner workings of the system for review then State Diagrams [wikipedia.org] are the way to go. They are conceptually simple, so it is easy to explain them even to users. They are very close to the reality of the environment and machine, and when you begin to model the design on events then you get (IMHO) a minimized, stable, and functional design.

  • Yes, I know, another fanboy touting how great Agile/Lean is... But seriously, I am an embedded developer for Flight Management Systems. I have been doing a lot of soul searching in this area. I have to tell everyone that the principle of Lean and Agile really do make sense, in particular for design documents. For the development we do, we are bound by DO-178B so we have to have some design "documentation" because there are objectives defined that require proof of compliance. The rub is that out of the 6
    • For the development we do, we are bound by DO-178B so we have to have some design "documentation" because there are objectives defined that require proof of compliance. The rub is that out of the 60+ objectives defined only 3 pertain to "design" (40 are for verification).

      I am genuinely curious how your Agile methodology satisfies the independence criteria for design and verification for DO-178B - I believe it can be done, but it seems very tricky (And I understand if you are not able to talk about it). Thi

      • by s31523 ( 926314 )
        First I will say that my current situation does not embrace all the Agile techniques I suggest. I have been party to organizations that have.

        Without going into all the dirty details here are some general answers.

        With respect to independence the only area where independence is required is for verification activities. Independence can be achieved by using a different person OR tool. Nothing prevents one from calling out a process in an SDP that uses a throw away prototype lifecycle model for an arch
        • Thank you very much! Sometimes, I get myself confused by the words "verification", "review", and "validation" - I think I understand now what you mean by verification. It's a very compelling argument - I had not considered working out the details of the design generation in the SDP.
          • by s31523 ( 926314 )

            I had not considered working out the details of the design generation in the SDP.

            Many people don't! They write a SDP that is generic and simply regurgitate DO-178B, i.e. use DO178B as a plan rather than guidance for coming up with a plan.
            You should check out the Yahoo group on DO178B. I started that a few years back when I was toiling with DO178b and seeking ways to do things "faster, better, cheaper" while still meeting the objectives. The group never took off as much as I wanted, but there is still hope.

  • Straight-up UML seems to be a bad match for most embedded systems - embedded systems tend to be built on procedural design principles, and matching them to object-oriented principles is often an exercise in frustration. Bruce Powell Douglas ( Doing Hard Time [amazon.com], Real Time UML [amazon.com]) seems to have the best handle on which core diagram types make sense for most of the embedded systems out there - I can't recommend his work highly enough.

    There is no definitive diagram standard for the embedded systems industry - th

  • As a windows developer, I'd like to run my software on Apple hardware. I am trying to get my services established and being able to run on Apple would be such a boon. Is there a concise set of instructions that I can follow to configure WINE for OS X? Ideally I would be able to do "agile" installation with my Apple friend to guide him through the process. Assuming that is successful, what is the process for copying my software over to OS X to test if it runs? (please don't flame me, I come in peace)
  • I use diagrams. Usually two per subsystem. However when I do it, I do pretty much everything in a way, opposite to what diagram-lovers are accustomed to.

    The principles are:

    1. Diagram is an illustration. It does not represent the code because any diagram properly representing any kind of real-life code would be too complex to be readable. It only makes sense to use diagrams to illustrate documentation where some part of it are more readable in a graphical form.

    2. Diagram should be very clear about what it ac

"Protozoa are small, and bacteria are small, but viruses are smaller than the both put together."

Working...