Rhapsody TechBlog

BLOG about IBM Rhapsody. Contains technical information as well as more private travel stories.

Page 13 of 16

State-chart

USA

Screen Shot 2017-10-22 at 13.35.47

Table of states visited

My first visit to the US was in november 1999. I had to be in Salt Lake City for work and took the opportunity to visit my friend Arno, who lived in Philadelphia back then. He worked in DC and I flew there to drive with him to Philly.
From there I went to Utah but  on the way back l took a small stop in New York to complete a real cool trip with a visit to already a number of states.

Cancelled flight

From that moment on I flew to the US almost once a year on average. And kept on visiting states. In 2004 I was on the way to Las Vegas together with Andreas Willert for the I-Logix Kick-Off Event. We booked the flight from Amsterdam via Minneapolis. We travelled a few days before the conference and wanted to drive around Las Vegas to see some of the Parks there. I already booked a hotel for the first night in Vegas and we planned on driving around and find ourselves places to stay on the go.
Unfortunately, KLM/North-West were not able to produce a working plane on the day we were supposed to fly so we had a forced night out in Amsterdam.
I phoned the hotel in LV to shift our stay for one day, just to find out that the next night was “Superbowl night” and the hotel price would not be $49,- but $249,-…
So I told the to shove their room somewhere dark and let KLM deal with it. It was their fault. (But my problem……as I found out later)
Luckily a have a friend who lives in “020”(As we from Rotterdam call our Capital, it’s the telephone area code) guided us through the city and after some beers (and some more) the next day we stood, slighty hangovered, before the KLM desk to get a room in LV for the next night.
They could not help us, this would have to be sorted out in Minneapolis they said.
So we first flew to Minnesota and went to the KLM desk over there to find out how they planned to get us in LV. It turned out to be a quite late flight that would arrive in LV on 00:30. They also told us to sort the hotel thing out when we arrived in Las Vegas.
This is where I intervened and said: no way I fly to LV without a hotel room.
So after some negotiations KLM booked us a room in Minneapolis and we rented a car to drive to LV because: What’s the difference? We wanted to drive around in LV and now we were driving around in the USA. No difference?

A small difference…

As it turned out, there was a small difference. We landed in Minneapolis, we noticed that it was snowing there. What we first noticed after we rented a car and went to five (5!) sliding doors to pick up our rental car. After each door the temperature dropped for more than 10ºC….
It was cold there. And I mean really cold. On the way to the hotel we were overtaken by a snowmobile. That was the first time I saw a sno-bolie in my entire life….
In the hotel we watched television just to find out that the USA was in something they called “The Blizzard of the Century”….
So the driving thing turned out to be a co-called “Bad Idea”
( “Bad Idea” is a trademark of  Microsoft Corporation )
So we decided to drive south as soon as possible to find better weather and to avoid going through the Rocky Mountains where this would certainly be worse.
So we did 3500 kilometers USA with at least 95% of that through the snow. Even on the Grand Canyon there was 50cm of snow. We have seen more crashed trucks and cars than in the rest of my life.
But we arrived in LV where is was nice and warm. And we passed about 12 states on the go.

State Count

As you can see in the state-chart, my current state count is 33, I hope that the next trip will bring me at least 2 more.

State-machines

OK, now a little about UML and Rhapsody. State-charts or state-machines are an important part of UML but certainly of Rhapsody. This, of course, stems from the fact that Mr. State-machine, David Harel, is the founder of I-Logix, and one of the fathers of Rhapsody and Statemate, it’s predecessor.
Although it is said that David Harel invented state-machines, this is not true, he merely described them thoroughly for the first time. His definition was take into the UML.
There are many more implementations and definitions of state-machines.

State-machines are excellent when you implement behavior that has discrete logic. For Control loops, it may look tempting to use a state-chart but that is a mistake. There are far better mechanisms to model continuous behavior.

Example

Picture: You have a new job at the software department of “El Cheapo” a manufacturer of computer LCD monitors, know for it’s really good value for money displays.
Your new boss gives you the assignment to make the software for a new monitor that El Cheapo will release soon. The monitor is aimed at the lower end of the market so it has only 4 buttons: one for on/off, one for switching between brightness and contrast and 2 to control whatever you have selected (plus and minus)
You remember from your last job that you had a UML Training with Rhapsody (from some Dutch guy…) and decide to use that for your new job.
After 2 hours of thinking you have your first version ready:

Monitor Statechart

Not bad for a new guy, you think and you are on your way to your boss to tell him about your success.

Your boss is impressed until he starts asking you about the “evMode”, “evDown” and “evUp”. “Where are these events coming from?” he asks.
“Easy”, you say, “The hardware guys have to send these events from the button interrupts when they program the hardware drivers”.
Your new boss starts rolling his eyes and drops backwards back in his chair. “INTERRUPTS???” he shouts! “No interrupts allowed over here!”. “Do you have any idea how dangerous interrupts are??”.
You ask: “But how do you detect that buttons are pressed then?”. “The safe way”, your boss replies, “by polling all inputs every 100 milliseconds”. “Sigh”, you think.
But no matter how you try to explain that this is so wrong, you are eventually forced to curb your enthusiasm and go back to the drawing board.

But… you never give up without a fight and you come back with another plan. You have learned in your Rhapsody Training (from that vague Dutch guy…) that you can tweak the generated code from Rhapsody using properties (see Properties. Stairway to heaven, highway to hell….) and you start tweaking the state-chart. You ignore the Framework (see Real-Time Framework, the robust base for your embedded applications. ) and you come up with this solution:

Monitor Statechart 2

All events are replaced by guards. The state-chart code is now tweaked so that the generated function (rootstate_dispatchevent() ) can be called by the 100mS loop.
Some quick tests prove that this also works and now without interrupts.

Really???

Is the second state-chart really a functional copy of the first?

NO!!! it is not. In this example nobody would notice because 100mS is fast enough to fool humans. But suppose you press both the “mode” and the “up” button within the 100mS time frame. Which one is pressed first?
You can never know since you were not looking. The first state-chart knows while that uses interrupts and the framework. Events are stored in the queue and processed according to the FIFO principle.

You have to choose which of the variables “mode”, “up”, and “down” has the highest priority. And react too that. So the state-machine should actually look like this:
That is the big difference between these methods.

You have to take the priority into account and then create the state-chart like this:

Monitor Statechart 3

If I show this state-chart during training, people tell me: “Walter… you always told us to use state-charts because they make it easier to understand your application.”, “This is not understandable”.
And they are right… this is not what I call a good and understandable state-chart. It’s a chaos. I checked it multiple times but I’m still not convinced that it is really 100% OK…

An easier way!

What!!?!! there is an easier way? Yes, there is… This is actually the state-chart that does the exact same as the one above here.

Monitor Statechart 4

Does that state-chart remind you of something? Another diagram maybe?

It should… It is an activity diagram. Or flow chart (As the activity diagram of an operation is called in Rhapsody). Check it out here:

activityDiagram

An activity diagram…. does the exact same that the state-chart does. And.. If you compare the LOC (Lines Of Code) you will see that the real state-chart (the first example with the events) uses more code then the activity diagram but it is more correct. The other examples (And certainly the incomprehensible one) use way more code and are much slower!

Conclusion

Use state-charts when you have discrete logic. For continuous logic or polling solutions: use activity diagrams or flow charts. Or use Matlab Simulink for control loops.

That’s it for today, happy modeling with Rhapsody

Walter van der Heiden (wvdheiden@willert.de)

 

USA II – The Falls.

And…. back…

Well not completely. Just sitting at the Delta Terminal in Detroit and waiting for the flight back to Schiphol Airport.
It has been a busy week with many customer visits, conf-calls and our Engineering@Scale event at the GM Heritage center.
Thanks for everyone that was there, it was cool. I think I have sent my presentation to everybody, if not… it is here: Pres – UML Modeling vs Coding E@S TD Detroit
The Willert Software Tools Movie that explains the use of tools in an Automotive field is here: Seamless Model-Based Development Process for Embedded Software Engineering

AUTOSAR

I had a cool demo with me, we (or actually Clemens….) managed to bring a first prototype of the RXF ArcCore RTE Connection. Still some “WorkToDo” but we have already a good working example where we can base the rest on. We are working in parallel on reading ARXML and extracting the relevant UML elements like ports, interfaces, variables, defines, types, runnable names, software components, so we can automate the process of using UML for the embedded automotive engineers. We are working to implement at least 2 use cases for the use of Rhapsody in Automotive environments:

UseCase 1 – Architecture

If you want to do your architectural work with Rhapsody, we want to offer a way to export stereotyped UML/SysML elements to an ARXML file. We’re currently not completely sure what we want to export, if you have ideas: SEND THEM!!

UseCase 2 – Behavior

You already have an architecture, you have defined SWC’s (or Runnables) and you want to implement (some of) them in Rhapsody. This is the UseCase that we are pursuing first (Because it is easier, we more or less know what to do, we have done it already for an older version of Rhapsody and an older version of AUTOSAR)

Niagara Falls

So. A brief overview of what we are working on. In 3 weeks I am back in the USA for more visits, AUTOSAR Conference and the IBM ICE Meeting.
This weekend we did a “round Lake Erie”. That takes you through Canada, Niagara Falls, Buffalo, Cleveland and back to Detroit. That was pretty cool, here are some pictures.

That’s it! Happy modeling with Rhapsody!
Walter van der Heiden (wvdheiden@willert.de)

 

USA II – The Falls.

And…. back…

Well not completely. Just sitting at the Delta Terminal in Detroit and waiting for the flight back to Schiphol Airport.
It has been a busy week with many customer visits, conf-calls and our Engineering@Scale event at the GM Heritage center.
Thanks for everyone that was there, it was cool. I think I have sent my presentation to everybody, if not… it is here: Pres – UML Modeling vs Coding E@S TD Detroit
The Willert Software Tools Movie that explains the use of tools in an Automotive field is here: Seamless Model-Based Development Process for Embedded Software Engineering

AUTOSAR

I had a cool demo with me, we (or actually Clemens….) managed to bring a first prototype of the RXF ArcCore RTE Connection. Still some “WorkToDo” but we have already a good working example where we can base the rest on. We are working in parallel on reading ARXML and extracting the relevant UML elements like ports, interfaces, variables, defines, types, runnable names, software components, so we can automate the process of using UML for the embedded automotive engineers. We are working to implement at least 2 use cases for the use of Rhapsody in Automotive environments:

UseCase 1 – Architecture

If you want to do your architectural work with Rhapsody, we want to offer a way to export stereotyped UML/SysML elements to an ARXML file. We’re currently not completely sure what we want to export, if you have ideas: SEND THEM!!

UseCase 2 – Behavior

You already have an architecture, you have defined SWC’s (or Runnables) and you want to implement (some of) them in Rhapsody. This is the UseCase that we are pursuing first (Because it is easier, we more or less know what to do, we have done it already for an older version of Rhapsody and an older version of AUTOSAR)

Niagara Falls

So. A brief overview of what we are working on. In 3 weeks I am back in the USA for more visits, AUTOSAR Conference and the IBM ICE Meeting.
This weekend we did a “round Lake Erie”. That takes you through Canada, Niagara Falls, Buffalo, Cleveland and back to Detroit. That was pretty cool, here are some pictures.

That’s it! Happy modeling with Rhapsody!
Walter van der Heiden (wvdheiden@willert.de)

 

USA

Travel fun

This week I’m in the US, Detroit to be precise. Flew in last week on Friday. First to Fort Myers of course, my good friend Arno lives there and I always visit him when I’m in the US.

I always say: Florida is Paradise. Nothing better than drive around in a convertible in South-West Florida. Weather is always good (Well… if there is no hurricane….) and the life is generally good there.

But on sunday afternoon, we (Me and my son Robbert) had to leave paradise to go to Motown.

That was easier said then done, Delta had an airplane ready but apparently some important piece was missing and it was not allowed to fly without it. (They refered to the part as “cover” which sounded pretty innocent to me…) So they had to get a new part, it turned out they had one in Fort Lauderdale. Close enough (100 miles, 160km through the air) but somehow they could not really get an airplane ready to fly it over. They’d also sent a car and that finally arrived 4 hours after the original time of start….

Fixing the plane took 2 minutes and then we could board. We had planned to arrive in Detroit at 19h but it became 23:30. Not cool. The hotel was also almost 50km from the airport so after checking in and unpacking it was 1 o’clock. The alarm was set to 6… short night.

What are we going to do in Motown? Well… as usual I cannot give any names but I’m visiting a couple of automotive companies (Now that is a tough guess….) and on Thursday we have our engineering@scale Tech Day. In the GM Heritage center, that’s going to be fun.

Rhapsody Q&A

We had a Rhapsody Q&A Session on monday. In German. There were some interesting questions, I’ll try and copy some of the questions and answers.

Rhapsody Tips ‘n Tricks

Roundtrip?

Rhapsody has some default settings that are chosen, lets say, “unluckily”…. One of them is the setting for showing so-called SourceArtifacts. That is default set to “Hide” which leads to very confusing situations with people who just started using Rhapsody. The best way is to, when you start a new model, immediately select “View”, “Browser Display Options”, “Show Source Artifacts”. This will make your life easier. If you see Source Artifacts in your Browser and you didn’t change anything: Loose them! (Right click, delete from model)

Another good one is to set the “C_Roundtrip::General::RoundtripScheme” Property to “Basic” or “Advanced”. This will prevent Rhapsody to try to include your typing errors in a model. You can still edit the body of your operations and the Enter/Exit code of state-charts/actions. With Advanced you can even add operations and attributes in an editor.

Rhapsody performance

Rhapsody is slow when model are bigger. That was not a question but the actual finding of a user. How can I make Rhapsody faster, especially the loading of “larger” models?

  • You can do load on demand. If you call the “Open” dialog you seen on the far right a few fields that you can tick: “With/Without Subunits”, “restore Last Session” and “Load on Demand”. You can only load the base rpy file and load the rest when you need it (Right click, “Load…” or “Load with subunits”, speaks for itself) When you close the model, “Restore..” will open only the stuff you had already opened and “Load On Demand” should open only the stuff you are using, unfortunately it is not implemented 100% yet. But try it, it will save some time.
  • Using your model from an SSD drive will greatly improve user experience… Using your model on a network drive will drive you nuts.
  • Having many properties seem to slow down the loading also, apparently Rhapsody needs to build the property tree and that takes time when it has a lot of overrules.
  • If you can: divide your model into multiple sub-models that you load “by reference”

Larger Models

Divide your model into multiple models that you can include where needed. If you have a model that has a certain driver in there, you can copy that into another model (Open a new model, do “Add to Model”, locate the .rpy file, click on “As Unit” and “Copy Into Model”. Then select the package you want “Tick “Add Dependencies” as well) This way the model has new GUIDs and there will be no conflicts when you use the package.
Save and and then you can open the original model, ditch the package you just copied and do “Ad To Model” again, this time adding the packag from the new model “As Reference”.

You can no longer edit the package(But you shouldn’t either!!) You can, however, create a Workspace and load all the models you use into it. You can then switch projects without opening and closing Rhapsody. (“File”, “Insert Project”, “Existing Project”)

So. I hope we have enough time this week to explore Detroit (Motown) a ittle bit better. The Skyline at night looks good!

dreamstime_l_10513728

That’s it for now: Happy Modeling with Rhapsody!

Walter van der Heiden (wvdheiden@willert.de)

 

Engineering@Scale Tech Day

Join us for Engineering@Scale Tech Day. Learn how new solutions and technologies are helping to lead the innovation agenda while addressing the complexity challenge in the automotive industry.

This event will focus on engineering systems and software development.  We will feature sessions around industry best practices and the core processes of requirements management, architecture design, collaboration, change and configuration management, test and quality management, product line engineering and variant management. Improve your skills, network and collaborate with industry experts.

What to expect:

  •  Keynote session by the American Center for Mobility
  •  Technical sessions for novices to experts, with topics ranging from:
    •  Scaling Agile to the Automotive Enterprise
    •  Convergence of MBSE and the Product Innovation Platform in Automotive
    •  Connected Product initiatives with Digital Twin and Digital Thread
    •  Improving your processes with Automtoive SPICE
    •  Feature-based Product Line Engineering and Operations for the Automotive Enterprise
    •  Certifiable framework for AUTOSAR
    •  And more
  •  Networking Lunch (no charge)
  •  Plus, tour the spectacular automotive collection at the GM Heritage Center.

 Register today and share wtih a colleague!

General Motors Heritage Center
6400 Center Drive
Sterling Heights, MI 48312

Thursday, October 12, 2017 from 8:00 AM to 4:00 PM (EDT)

Ask the Master.

Or Rhapsody Q&A

A short BLOG entry this time. On Monday, October 9 13:00-14:30 CET, we organize an Ask the Master Webinar. Feel free to join and fire questions about Rhapsody to the Master. (That’ll be me…) Just a small info: It will be in German! (With Dutch accent…)

Ein kurze BLOG heute. Montag 9 Oktober von 13u- 14u30 organizieren wir ein Webinar “Ask the Master”. Meld dich an und werde all deine Fragen über Rhapsody los bei der Guru ( An dem Tag bin ich das…) Es wird in Deutsch sein (Mit Holländischen Akzent)

Ask the Master
Wir laden Sie ein:
Am Montag, den 09.10. /  13.00 – 14.30 zu unserer Websession:
Rhapsody – Questions & Answers
Herr van der Heiden wird Ihnen dieses Mal ganze 1,5 Std zur Verfügung stehen, um Ihre Fragen rund um das Thema Rhapsody zu beantworten und Ihnen Tipps und Tricks verraten.
Die Websession ist kostenlos. Sie müssen sich nur anmelden.
Anmeldung:

Divide and Conquer

Introduction

As I always tell the people who attend my UML Trainings: without using Classes and Objects to split up the work your application must do, it is impossible to handle todays complexity.

Programing used to be easy, in the early days of computers and the early days of embedded. The first boards had small controllers on them that had a few kilobytes of ROM memory and a few bytes of RAM.

Getting these to work from scratch involved a day of reading some stuff and applying power to the board, then your first blinking LED was reality. (and how cool it was..)

Later using 16-bit controllers, still with Kilobytes but now more than a few,  but using ‘C’ in stead of Assembler, this was already complex. Could take a few days to get the first stuff running. (Not to forget that you had to learn ‘C’ as well…

With UML the initial effort increases again, you have to learn UML, ‘C’ (or ‘C++’ ) and you have to install a lot more stuff. But this is also doable and after the initial effort you’ll notice that things go faster.

The complexity, however, is still increasing and the only way to master it will be to re-use existing stuff. This is only possible if we have “designed for re-use”.

 

Modeling or Programming?

That is the question. The difference is not clear to people who use Rhapsody for the first time, it is, however, crucial for the way you use your models and how you do the implementation. So just breaking up in multiple Classes and Objects is no longer sufficient, you need to be able to divide your models in “Components” that can be re-used without having to look deeply into them to understand what they do.

Rhapsody supports a couple of ways to do that in your model. You can use (parts of) other models. In the menu you have “File”, “Add to Model”.

Then a menu pops up that lets you select a Rhapsody model (Or a file in a model, i.e. a Unit like a Package or a Component) You can also select “As unit (with a “copy” tick) or as reference.

  • As Reference, links the selected model element in the open model as a read-only reference. (Same GUIDs) You cannot edit the element in your Rhapsody model, you have to open the original model for that.
  • As Unit, links the selected model element in the open model as a writable reference. (Same GUIDs) You can edit the element in your Rhapsody model and it will then change the original model as well.
  • As Unit (with copy) copies the selected model element in the open model. (New GUIDs) You can change the element in your Rhapsody model but the original element will be left untouched.

GUIDs are the generated 128-bit ID’s that Rhapsody assigns to every Model element. Rhapsody uses the GUID to recognize model elements (It does NOT use the name for that!) So copying renews the GUIDs so there will be no name clashes with existing model elements.

Now try to model as independent as possible by using only unidirectional relations, eventually ports and interfaces. Use private attributes and operations when possible, at least describe the public interface as good as possible so re-use is easier while the re-user does not have to study the inside of your model.

 

Attention points.

  • Paths. If you use referenced model elements, be sure that they are in the right path on all computers of all project members… Otherwise check-in  and -out will be a torture. You have to manually adapt the paths in your model. It helps to use relative paths in your model

    General::Model::ReferenceUnitPath
    General::Model::PathInProjectList
    can be helpful there. You might also use an Environment variable to point to your working directory and sync that with your colleagues. (Like the OMROOT variable that Rhapsody uses to make it independent where your Rhapsody Share directory is)

  • Config Management. If you check in and out models and parts of models, it is easy to fetch a wrong version of a referenced model. Think about your CM structure!
  • Names. Don’t use default names like “default” for th package, etc. Use meaningful names that can be used in their projects without causing collisions.
  • Documentation. Is even more important when your model is re-used inside other models.

Tips and Tricks

  • As long as you make changes in your model _and_ in the referenced model, load both models in a project (Using “File”, “Insert Project”. You have to switch the active project to make changes but it will reduce time. Rhapsody saves the Workspace separately! (You can even edit it if you make changes to your paths)
  • Using Ports and Interfaces greatly improve the way you can use models in models.
  • There are more ways to create Interfaces, see my Techletter about using Interfaces.

 

Dividing up your models.

If you have made a model that represents the hardware you use in multiple projects, you can easily use that model in all projects that use the same hardware. The nice thing is that if you have your version system right (perhaps even with a check in the model..) and really defined your interfaces, then you can use different versions of the hardware without really worrying about you model.
Another advatage is that referenced model load faster.

 

That’s it! Happy modeling with Rhapsody!

Walter van der Heiden (wvdheiden@willert.de)

Liechtenstein – Small is beautiful

Liechtenstein

This week is another traveling week. From home via the office to Liechtenstein, 940 kilometers in one day. Follow the star….
It’s training week, again a couple of developers that want to learn how to model in Rhapsody.
People ask me sometimes, “Don’t you find that boring, telling the same story over and over?” But then I always answer: “Yes, that is boring. But to make it bearable I always tell it to different people!”
No it’s not boring, I like trainings, always. It is nice to help developers learn to model.

Liechtenstein is very nice, beautiful country, squeezed in between Switzerland and Austria. Mountains on one side, the Rhine on the other side.
The country is 160 km² large which is slightly larger than the city I live in… 36000 inhabitants. And rich…. very rich…. Many people have bank accounts here to avoid paying tax in other countries. That is their main income it seems.

So what can you do in Rhapsody to make your code smaller? I assume you are using an RXF from Wilert, otherwise the first you can do is ditch the OXF (or whatever you are using) and start using the RXF from Willert which is much smaller and much faster than other frameworks. The Frameworks with OO-RTX as RTOS are the smallest, they do not have preemptive scheduling but if you don’t need that, this is the RXF to go with.

We don’t do destructor…

An embedded system just works until switched of. And we don not have to care about freeing memory or cleaning up structures. So we can use the properties to prevent Rhapsody from generating them. These properties control that:

CG::Class::GenerateImplicitConstructors
C_CG::Class::GenerateDestructor
C_CG::Class::EnableDynamicAllocation

HighWaterMarks

The RXF knows highwatermarks, they indicate how many memory blocks you have maximally used at the same time. The same for events and timers.
A good way to estimate the optimal use of your static memory is to use the compilers “mapfile” to determine the size of all structures you are dynamically (or semi-dynamically) allocating. Then optimize your memory structures by making your tiny, small, medium, large or huge blocks exactly as large as the structures you use.
Then determine the maximum number of blocks you need from every size. If you do not need 5 different sizes: make the block count 0, then the structures will disappear completely. The same for timers, if you do not use the “tm(xxx) statement in your state-machines, set the TIMERS to 0.

State-machine

Rhapsody uses an int for the state-variable. If you use less than 255 states in a state-machine you can easily use an unsigned character for that. This is the property:

CG::Class::Statechart::FlatStateType

 

Inline

Create inline functions for operations that are not or hardly used. The RXF knows the inline keyword that you can replace with the compilers inline keyword. On some controllers a function call is much more “expensive” than replacing that with the original statement from the called function!

C_CG::Class::IsCompletedOperation
C_CG::Class::IsInOperation

Compiler

Most compilers have excellent optimizations. Switch them on, try all settings and make an overview (Use Excel!) of all the effect you can measure, (Size, speed)

Oktoberfest

This week starts in Munich. Or actually in Münster where I stay in a hotel to prevent having to go up at 4 o’clock. My flight to Munich leaves pretty early here, the Hotel is close to the airport and has a taxi service. Without large check-in luggage the check-in time here is about 10 minutes.

But enough about Münster, I’m on my way to Munich, not my favorite town as you might remember. Luckily I don’t have to drive..

The flight was hard enough to get since this is the time of the “Wies’n” as the Munich people call the “Oktoberfest”. Yes, correct, that is not in October… People from all over the world travel to Munich to have a look at the Oktoberfest. And I am invited by IBM on their IoT (Internet of Things) conference with a visit included.

I personally couldn’t care less, the music they play there is absolute horror, the noise is terrible and the only good thing is the Beer that they serve in large glasses that contain 1 whole liter (Mass), drink a few of them and you won’t notice the rest anymore…

Unfortunately I have a busy week and I’m on a diet so no beer for me. So I have to survive it cold-turkey.

Finding the right place was not easy, we had a description but the Oktoberfest place is huge.

There are positive sides, luckily. I meet with old friends from the pioneer Rhapsody days and that is really cool.

The conference was very good, we spoke with many people from IBM about the tools. Although IBM is breathing “IoT” to the outside world, this conference showed that they are still very much aware that there is no IoT without compelling tools!

There is a lot going on with Rhapsody and all Jazz tools, I will speak more about that later when things are released.

In the meantime: Happy Modeling with Rhapsody!

Walter van der Heiden (wvdheiden@willert.de)

MISRA

Introduction

MISRA -Motor Industry Software Reliability Association. This is a comite that defines rules that ‘C’ (or ‘C++’) programmers need to follow to increase the safety and reliability of their code.
A customer asked me about Rhapsody and MISRA compliance, hence the BLOG entry…
There are multiple MISRA standards, for ‘C’ and ‘C++’. For ‘C’ there is 1998, 2004 and 2012, for ‘C++’ there is the 2008 standard.
Rhapsody has 2 profiles “out-of-the-box”, 1998 for ‘C’ and 2008 for ‘C++’. We (Willert) have created our own profile for MISRA ‘C’ 2004. It is delivered with our RXF Frameworks.

 

Is Rhapsody generated code MISRA compliant?

Yes and No. (In German they have the word: “Jein” which is a combination of Yes (Ja) and No (Nein). Beautiful word.)
First: there is no such thing as 100% MISRA compliant embedded code. It is almost impossible to write all code exactly as MISRA tells you, alone the code you need to control your hardware will violate multiple rules. The code that Rhapsody generates is created in a way that it is more or less compliant with some important rules.
If you load the MISRA profile, the generated code will contain comments to tell your checker tools that a rule is violated and why that is OK. But again: you have to check yourself and the MISRA part only applies to code that Rhapsody has generated by itself. The code that you type in yourself is as MISRA compliant as you want….

Restrictions

Code from relations with * multiplicity are not MISRA compliant, as is dynamic behaviour like instantiation at run-time and dynamic memory allocation.
Code for Ports in Rhapsody in ‘C’ is using recursion, code for interfaces uses pointer arithmetic. Both are not MISRA compliant and very difficult to prove right.

 

It is not compliant so it can not be used?

No, that is not how it works, Let me give you an example that I once learned from Günther Glöe from Tüv.
Suppose that you want to drive a nail into a wall. The only tool you have available is an old hammer that has a failure: the head is pretty loose and can fly of if used.
So… according to popular belief you have to refrain from using the hammer and drive the nail in the wall using your fist. I would personally not do that…. it hurts…
I would use the hammer but take precautions to minimize the risk of injuries and other collateral damage. I would remove objects from the vicinity of the place I want to drive the nail in the wall, warn all people in the neighbourhood to stay away and then carefully use the old hammer.
This is exactly what MISRA says: “Use with care”. If you have to violate a rule, then take care that you prevent this from causing disaster.

 

How To use Rhapsody and MISRA

  • Load the MISRA profile
  • check as soon as possible. If you wait with checking for MISRA, you will be flooded with error messages.
  • distinguish between mandatory and advisory rules. You should comply with the first and try to comply with the latter.
  • Document the violations as defined so that you can do a check run without warnings.
  • create documentation that documents all the decisions you took and the measurements you took to prevent problems

 

How to test for MISRA compliance

You can (and should…) test if your stuff is following the rules of MISRA by using a checker. Some compilers (a.o. Tasking and IAR) have checkers built-in.
We always use PC-Lint because it is pretty good and very cheap. Other static checkers offer a lot more comfort and more but are way more expensive.

PC-Lint
Compiler
Polyspace
Many more check: Wikipedia.

« Older posts Newer posts »

© 2025 Rhapsody TechBlog

Theme by Anders NorenUp ↑