CANopen diagnosis with CANOpen-MessageFormatter-PlugIn Efficient combination between CANopen diagnosis and microcontroller debugging Lauta, January 2006 - For verification of microcontroller software and for diagnosis of CAN bus to date usually two different tools are used featuring two separate communication devices for CAN bus and debug interface to the microcontroller - running often on two diverse PCs. A solution for this dilemma is the integration of a CAN recorder in the microcontroller debugger including a flexible message formatting mechanism for CANopen and other protocols. This approach allows a significant increase of efficiency compared to traditional solutions based on separated tools.
Since only layer 1 and 2 are defined as transport media in the underlying CAN bus it is necessary to use an application layer protocol (layer 7) to describe the data exchange. For this CANopen is a widely used standard. A CAN message is structured at the lower layers via an identifier and up to 64 bits of data. A standard identifier (CAN base frame) contains 11 bits and an extended identifier (CAN extended frame) 29 bits. So single bus nodes respectively bus node functions are addressable respectively observable. The content of the message is included in the 64 bits of data.
The importance of the single message ID for the standard identifier range (0-7FFh) is defined in CANopen as shown in figure on the right side. For the transport of data there are of interest the service data objects (SDO) and process data objects. Whereas the SDOs are designed reading and writing of configuration and status data the PDOs are used for the actual application data. The CANopen standard provides a scheme for using the program data objects via so called device profiles.
In CANopen the device configurations files (DCF) are of particular importance. These are readable ASCII- text files and they are used for describing the characteristics and interfaces of the CAN nodes. Included are among others the names of the nodes, the used CAN IDs, and the usage of the PDOs. Thereby the names and types of parameters are defined that are included in the transmitted 64 bits of a PDO. The type of a parameter describes the size and location of the bit array dedicated to the parameter.
Basis of the concept realized by pls is a simple CAN recorder that is available as an add-in for a microcontroller debugging environment. It is able to lossless record all CAN massages and monitor symbolic names for the identifier. Filtering the identifiers and sending messages is also possible. The CAN interface for recording of messages is realized via the debugging communication device. This includes beside CAN a variety of interfaces like JTAG bus and serial interfaces for debug access to the microcontroller. The communication device itself features a powerful 32-bit microcontroller and a JTAG controller realized in hardware in a FPGA. This combination enables the continuous recording of all messages on the CAN bus even if the device is used primarily for the debug communication with a microcontroller system. The link to the CAN bus takes place via a D-Sub connector. The pin assignment is according to standard CiA 303-1. The device features a high speed interface driver according to ISO-11898-2.
The extension of the CAN recorder for interpreting the recorded data at the CAN bus is shown on right hand. It is made up of a general CANopen interpreter, the message formatter, and a DFC converter. The CANopen interpreter generates plain text output for every message types defined in the standard. This includes network management master messages (NMT), heartbeat, SDO protocol, sycn message, time stamp, and emergency message. If there is no more exact specification due to a message format file a text output is generated for the ID range given by the standard.
The message formatter allows monitoring such message content as edited text taken from this description file. The description file is able to contain blank lines and comment lines. The comment lines must start with a hash sign (#) as first printable character. The proper definition lines are made up syntactically as follows: <definition line> := <message ID> , "<format string>" [, <parameter list>] The format string is made up of the printf function that is known from the standard C library. The integration of values from the parameter list is possible with % placeholders. The organization of the optional parameter list is as follows: <parameter list> := <keyword> [, <keyword> …] For keywords might be used <keyword> := <MSGID()> | <STDMSGID()> | >TIMESTAMP()> | <BITVALUE(start,end)> MSGID() creates the numerical value of the ID for the message that has to be formatted; STDMSGID() is equivalent to the chain of characters of the message that would be created by the CANopen interpreter; TIMESTAMP() generates the numerical value of the time stamp to run from the CAN recorder and BITVALUE(start, end) finally creates the numerical value of the specified bit array that is defined by the parameters "start" and "end". The last keyword allows extracting bit arrays of any size from the 64 bits of a CAN message. Due to the syntax elements it is possible to realize for every anticipated CAN message an easier to use plain text output compared to numerical values. Figure on right side shows an example file.
Since a device configuration file features all necessary indications for useful monitoring CAN messages it allows creating from itself a description file for the message formatter. This task is done by the DCF converter that automatically generates such a description file from the indications of one or multiple device configuration files. The DCF converter is intentionally not directly integrated in the CAN recorder but operates on a temporary file. This has the advantage that the functionality of the message formatter is usable even when there are no device configuration files available. This happens for example in the early stage of development or if you work with proprietary CAN protocols instead of CANopen.
The microcontroller debugging environment that acts as host application for the extended CAN recorder is made up modular with COM components and extendable via add-in interface. Parts of the program that are specific for the architecture or the target are encapsulated into modules and can be changed when a new microcontroller is used. Add-ins beside the CAN recorder are for example flash programming or support for real time operation systems.
The user interface of the integrated CAN recorder consists of a debugger window featuring a list with selectable layout. For monitoring the following columns are selectable: - MessageIndex - for consecutive numbering of the recorded CAN messages.
- MessageID - for displaying the CAN identifier numerically or symbolically. In addition to the mentioned complex interpretation of the message you can use a simple mapping table between CAN identifiers and freely selectable text strings that are then displayed in this column.
- Timestamp - for displaying the time in milliseconds that runs between start of recording and receiving the appropriate message.
- Extended ID Flag - monitors whether the actual identifier uses the extended format. Identifiers from the standard ID range are not able to recognize the extended format from the plain numerical value.
- Message Direction - monitors whether a message was sent or received or it is a remote frame.
- Number of Bytes - shows the amount of data bytes in the recorded message.
- Message Lost Flag - displays if there was an overflow of the receive buffer of the recorders CAN hardware or whether there was a timeout by sending a message.
- Message Data - monitors the data bytes of a CAN message in numerical format
- Message formatter - allows the definition of a column for interpreted display of a CAN message in consideration of identifier and data bytes with a message formatter as mentioned; Figure below shows the display of formatted messages.
Furthermore the used baud rate and used identifier format are adjustable. For special applications it is also possible to directly program the CAN bit timing registers that are located in the 32-bit TriCore microcontroller used in the debugging communication device. This enables an alignment to any baud rate and values for the sample point. This allows the usage of the CAN interface in the communication device over the total baud rate up to 1 MBit/s as well as basic and extended identifier format (CAN base frame and CAN extended frame). The message masks of the CAN module in the TriCore microcontroller are also adjustable via a dialog page. Therefore filtering of the record is possible via the hardware. Additionally the storage of a file record for subsequent processing with other programs is also possible.
To date debuggers are used only for troubleshooting and test of microcontroller applications. The integration of CAN/CANopen diagnosis into the Universal Debug Engine from pls a well known programming environment for design engineers results in a significant improved efficiency. Particularly the use of only one communication device is to be emphasized to access the target for debugging and CAN monitoring. Additionally the CAN recorder add-in and the microcontroller debugger as host environment provides an automation interface. This interface enables control of the functionality from extern for example by scripts. This allows the interaction between debugger and CAN recorder resulting in a significant improvement of the performance of the integrated tools. For example a debug event like a break point enables to start and stop the CAN recording or to send a CAN message.
TrademarksTriCore is a registered trademark of Infineon Technologies AG. CANopen is a registered trademark of CAN in Automation (CiA). Editors contactpls Programmierbare Logik & Systeme GmbH Heiko Riessland Technologiepark D-02991 Lauta Phone: +49 35722 / 384 - 0 Fax: +49 35722 / 384 - 69 Email:
This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
Internet: http://www.pls-mc.com |