San José
The second part of this USA trip brings me to San José in California. I am joining the 10th AUTOSAR Conference there. The meeting is held in the Computer Museum in San Jose.
I think that’s pretty cool. Also in the neighborhood are Apple, Google, Tesla, the famous garage of Jobs&the Woz and the HP garage. When there’s time I will take pictures. But we will fly to Detroit very early on Thursday.. so there is only limited time.
San José is nice but very, very expensive. Hotels cost a fortune, the hotels that are affordable are really low-class. The weather is nice, about 20ºC .
Introduction
People ask me a lot of times: “Why don’t you write something for “beginners”?”
OK, good point. Let’s do something for beginners.
First: what are we going to do, what are we going to use.
- Board: Infineon XMC2Go Board
ARM Cortex M0 – XMC1100, 64k ROM, 16k RAM - Keil µVision IDE
When installed without a license, this acts like an eval version with a 32k size limit: we can live with that! The Willert Frameworks are really small, a Blinky is only a few KiloBytes without optimisation. If optimising it’s just over 1 KiloByte. - Keil CMSIS2 RTOS
Embedded RTOS that implements the CMSIS standard - Rhapsody 8.2.1, the latest version
We use the ‘C’ or the ‘C++’ version. We will cover both languages. - Willert RXF for C or C++
The “general” version of the award-winning Rhapsody Framework.
includes the UML Target Debugger - CygWin/Visual Studio/Eclipse
Some C/C++ compiler running on a PC, preferably a free one.
Second: The sequence of installing:
- C/C++-Compiler
- Keil
- Rhapsody
- Willert RXF
See Installing Rhapsody for more info.
Third: What are we going to make?
That’s easy, there is a Hello World equivalent in the embedded world. It’s called Blinky. We let an LED blink on the board, that is about the smallest complete program you can make that still has user interaction.
Getting Started
Now we have installed it all, we can start using the environment to create a project.
First we start Rhapsody. I always like to make a shortcut on the Desktop to have Rhapsody accessible always. In Windows 10 you can pin it to they taskbar. As you can read a in the Installing Rhapsody part, you can influence the version of Rhapsody that is started by adding command line options.
So the version we need to start is Rhapsody Developer in C++. You can start Rhapsody Developer in C if you like, i will describe the differences between these versions.
People that just start with Rhapsody often ask: Why do I have to choose a language when I start a new model? Why can’t I do that later. Well that is because Rhapsody not only generates code, it also accepts your own code that you type in. You can do that in operations that are in classes but also in state-charts and activity diagram actions.
So changing the language after a while would implicate that you would have to change your own code as well. Can be done, but is much work. Also there are differences in the language versions. Rhapsody in C cannot generate code for inheritance (only from Interfaces) and there are mode differences.
Luckily you never switch the programming language that often, where I worked we always decided which one we’d use upfront and stayed with it…
Now that looks pretty empty
Yes, it does. That’s why it’s now time to create a new model. Rhapsody works with models. Models as in representations of the real world not the models from the middle pages of certain magazines… We can open an existing model but for now we will create a complete new one. Can be done in multiple ways;
I don’t use the mouse often so I usually press CTRL-N. Yes, I like the keyboard…. I’m old enough. And now we are outing ourselves anyway: Yes I like VI…. But feel free to use the mouse if you like. You’ll become a small window that asks you to enter 4 things.
- Name, the name of the model. You’ll notice that Rhapsody adds the name of the model to the path. So it will create a new directory for every model you create.
- Path, where the model is stored. Non-existing parts of the path will be created (after asking…. after all this is Windows!) only if you create a new directory in the root directory, this cannot be created. It’s not Rhapsody, it’s a Windows relict from the past. Have I already mentioned that I hate Windows?
- Project type, here you can select a profile to be loaded with the new model. The profiles have to be stored in a Rhapsody directory (and preferably have an accompanying text file with the same name that contains a description)
- Project settings, almost the same as project type but adds a settings file
You should create a directory that you can find easy, preferably c:\work or something similar. This is the directory to filled in after “Path”. As Project Name you take “Blinky”, as project Type you click on select, then scroll down to the directory “WST_RXF_V7”, in there choose “RXF_CPP_V7”. In the Settings Tab, go to the same directory and choose WSTProfile
If you have filled in everything a new model is created.
OK… Now what?
You see an empty model [picture of Rhapsody GUI]
There are a few area’s on the screen.
- Menu
- Browser
- Diagram area
- Output Area
- Drawing Menu
The menu is a partly straightforward, the stuff that visual studio gives you for free, but parts are Rhapsody specific. You can create and open diagrams and do a lot more.
What is the Browser? It is the view to your model. It contains all element of your UML or SysML model. You can select what you see in the browser by using queries, you can from the browser, create and delete model elements. Your Browser View will not be empty, it will contain some default elements and the profiles you have selected when creating the model.
The Diagram Area is logically the view on your diagram. Per default Rhapsody will create and open a diagram for you: An object Model Diagram named “Model1”.
The Output Area is empty until you start doing things like generating, compiling or executing code. Then the output is shown here, beware, it has multiple tabs.
The drawing menu is on the right and contains the elements that can be used on the currently open diagram type. Rhapsody has possibilities to add items to it or to limit the items on the drawing menu.
Repository
Or, as we call it, the browser. When a new model is just created, it contains a few folders.
- Components, contain what you are actually creating with Rhapsody. Per default it contains a single component: “DefaultComponent”. If you double-click that’s window will open, the Features Window. All Elements in Rhapsody have a feature window, a double-click will open it. Even diagrams have features, only they are not opened with a double click but with a right-click and selecting “Features”. A double click on a diagram will of course open that diagram. The first tab contains the name and type (library, executable or other”.The second has a “Scope” that lets you select what other UML elements are part of this component.
Under a component there is at least one “Configuration” (Default: DefaultConfiguration” . This contains the information about the target environment. - Object Model Diagrams, normally all diagrams are located under a package, like all other UML elements. But to make a model better accessible for others we need diagrams on the top-level to assure an entry in the model. You can (Actually you should…) add navigation info to allow for traversing the model from there.
- Packages, the base of your UML Model. Packages are nothing more than folders, however they have influence on the generated code, some elements will be generated inside .c (or .cpp) and .h. You can organize your work by dividing it in packages and sub-packages. And sub-sub-packages, and sub-sub-sub-packages, and… you get it I guess.
- Profiles, these are the profiles that were loaded when we selected our project type. It is, of course possible to load more profiles after you have created the model. Just use “File”, “Add Profile to Model”. Profiles are used to transfer a lot of properties in one go but also to include certain information in the model.
- Settings, about the same as profiles, technically there is no difference. Then why? Beats me….
C or C++?
What is the difference between Rhapsody in C and in C++? There are a few differences which I will explain but there is also a lot that is the same. You can draw exactly the same elements, the generated code will differ. Also the code that you enter must be equal to the chosen language otherwise nothing will work.
‘C++’ is of course closer to the UML. It already has classes, OO, inheritance and a lot more. But Rhapsody in ‘C’ also offers OO. Here you see the same class code, in ‘C’ and in ‘C++’.
- ClassC.c
- UML Class
- ClassC.h
- ClassCPP.cpp
- ClassCPP.h
The Object orientation in C is done by using a struct to mimic a class. (Private members are not really private there, unfortunately.But in Rhapsody, the get and set methods are used to implement private, public and (only in ‘C++) protected.
Functions have the name of the class as prefix to prevent linking problems when 2 classes have the same functions. Private functions have only the name of the function and are “static” which makes them really private.
All functions have a “class * me” as first parameter to have access to the objects attributes.
Calling a function in C++: object->function();
Calling the same in C: class_function(object);
So. That was the start. Happy modeling with Rhapsody and see you in part 2!
Walter van der Heiden (wvdheiden@willert.de)
Hello there, I discovered your website by the use of Google while searching for a comparable matter,
your site came up, it seems great. I’ve bookmarked it in my google bookmarks.
Hello there, simply was alert to your blog thru Google, and located that it’s really informative.
I’m gonna watch out for brussels. I will be grateful if you continue this in future.
Numerous people will likely be benefited from your writing.
Cheers!
Is there a Part 2 of this article?