PBMaster:pbmon
From PBMasterWiki
Contents |
[edit] Bus Analyzer and Monitor
Applications in industry often demand for tracking problems on the fieldbus. The problems can be diagnosed and localized by listening to and analyzing communication on the bus. By analyzing the captured data, it is possible to detect problems like frames with errors (often caused by signal reflection), station inactivity, address collisions, too short Slot Times of the Master stations, even bad timing of stations.
This section introduces a graphical analyzer and monitoring program. The program, named pbmon (PBMaster Monitor), was developed in QT (cute), a cross-platform application framework. Using QT, one can develop applications and user interfaces once, and deploy them across many desktop and embedded operating systems without rewriting the source code. QT was originally developed by TrollTech but recently was sold to Nokia Corporation. QT is widely used in the open-source world because of its free license and high quality software as well as documentation support. QT is most notably used in KDE, Opera, Google Earth, Skype, Qtopia, Adobe Photoshop, mobile phones, navigation systems and many others.
After an overview and description of the internal implementation we will introduce the program's functions. Differences of each feature will be described in detail later in this section.
[edit] Overview
The program pbmon-qt, as with other components of the project, was designed to be fast, reliable and modular. Thanks to its modularity, it will be more simple to integrate new features to the program so it could become a versatile industrial bus control and monitoring program. The current version supports Profibus Frame analyzer and UART Bit/Byte analyzer.
The main window contains menus, tool bars, side bar, debug window and tabs with specific functions. The global buttons like Start Capture, Refresh View, Timestamp settings affect only the visible tab. The debug window is collective for all tabs. The side bar shows information about the nodes.
The current version provides three types of tab implementing functions of the Frame analyzer and UART Bit/Byte analyzer. Several tabs of the same type can be present at the same time. The analyzer offers other interesting features like online view during capture, offline view of saved files and timestamp display in five formats. Timestamp can be in absolute time, time difference between data, time from the start of capture, bit time difference between data and bit time from the start of capture. Capture trigger, view filter and statistics of captured data will be implemented in the next version.
[edit] Implementation
In contrast to other software developed in the project, pbmon-qt is written in C++ instead of the standard C language. The program consists of about 20 classes. In this section, we will focus on the implementation of important classes, on which pbmon-qt is built. The other classes are GUI related or auxiliary and will not be described here.
[edit] Recorder
This class starts with establishing a connection to the resource, from which the data is read, and then opens a file, to which the data is written. A source can be either a local file or a remote server. The recorder is in fact a thread running on demand.
All addresses are specified using the URL mechanism (Uniform Resource Locator). A URL identifier could be pbm://server.pbmaster.org:11000/0, file:///dev/pbmaster0 or simply /dev/pbmaster0. The first URL refers to a device number 0 on remote server using port number 11000, the latter two refer to a local file.
Data is recorded always in blocks of fixed size (e.g. 4096 bytes). The first block stores status data of the device. The status data always starts with a header containing information about the header's version, header length, flags, type of the status data following the header, protocol family and length of the following status data.
+---------+---------------+-------+------+----------+---------------+ ! Version ! Header Length ! Flags ! Type ! Protocol ! Status Length ! +---------+---------------+-------+------+----------+---------------+
Status data follows after the status header. It depends on the type of device. Status data of a Master contains for example information about its baud rate, station number, FIFO size and other Profibus related parameters. Status data of an Analyzer node holds information about the baud rate, FIFO length and a description about the captured data like the length of timestamps, frame sequence, error indication etc. For more information please refer to the source code of the driver. The format of captured data was designed to be small and easy to process. The following figures illustrate the data format of the Frame and Bit/Byte analyzers.
+----------+-----------+--------+--------------+---------------------+ ! Sequence ! Timestamp ! Errors ! Frame Length ! Captured Frame .... ! +----------+-----------+--------+--------------+---------------------+ +----------+-----------+-------------------+ ! Sequence ! Timestamp ! Captured Byte/Bit ! +----------+-----------+-------------------+
[edit] Data Reader
The Reader Class was taken from the project lfhex (Large File Hex Editor) developed and maintained by Salem Ganzhorn. The implementation of this class is simple but very efficient. It is capable of reading very large files with very small memory requirements and an almost instant load time. This allows the analyzer to work with hundreds of millions of frames and even more.
The class Reader is used by another class named Data Reader for seeking captured data in the file by its sequence number as well as converting timestamps into required formats.
[edit] Data Listing
Displaying too much data at once would be very slow and very memory consuming. In order for fast listing with constant display times, the data list is implemented as a table with an invariable number of rows, typically around 50. Data indexing is done using a vertical scroll bar. The range of the scroll bar dynamically changes depending on the amount of captured data.
[edit] Data Plotter
This class carries out data drawing. The horizontal axis represents the time line; the vertical data, value. Data displaying on the plotter conforms to data in the data list described previously. Using the data plotter it is possible to detect problems caused by bad timing.
[edit] Data Parser
In order to display data in an understandable form for users, the data is parsed by this class. How the data is represented depends on the protocol. The class constructs appropriate string representations of the captured data, which are sequentially displayed.
[edit] Profibus Analyzer
The Profibus Analyzer is a tool for analyzing and optimizing communication on the Profibus network. It is suited for continuous network monitoring, detecting hidden errors, error telegrams, configuration errors, repeats etc. As mentioned before, the design of this analyzer makes it possible for continuously monitoring the network for a very long time limited only by the hard disk capacity.
Data is captured as frames. It means every frame has its own sequence number, timestamp, etc. The analyzer displays frames in two forms, in data list and detailed frame information for a selected frame. The data list displays general and frequently used information like timestamp, frame type, station addresses and carried data. Error frames are highlighted and their types are listed in the error column. The detailed view in addition shows all information of the frame divided into groups for each communication layer.
[edit] Byte Analyzer
This function can be used for analyzing any communication based on the UART. It offers a useful tool to detect problems like bad timing or error data. The current version supports data listing. Captured data is listed in a table with information about sequence number, timestamp and their values.
The data plotter is not implemented yet but the idea is to use the plotter to display data in the timing diagram. It will be more simple for a user to compare data in the diagram than in numbers.
[edit] Bit Analyzer
Similar to the Byte analyzer, Bit analyzer is a tool for diagnostics based on the UART. Unlike the previous two tools, it needs hardware support described earlier in the chapter about hardware. Data is listed in a table like the Byte analyzer. In addition, this tools implements a graphical representation of the captured data. In fact this is a single channel logic analyzer, of course with many limitations like slow sample rates, no possibility of setting the compare level, etc. The data graph can be stretched and scrolled in horizontal and vertical axes using control knobs. The Bit analyzer is a very useful tool to detect problems related with bad timing.
[edit] PBMaster Monitor
This function will be soon implemented. The idea is to create a tool offering a simple way for manipulating the drivers, like loading and unloading modules, setting a node's parameters, viewing bus topology, sending requests and receiving responses from the stations, etc.




