Mezurit 2

Development notes

This page has information about debugging, improving, extending, and, last but not least, compiling Mezurit 2. If you simply wish to install it and are running Arch Linux, Ubuntu, or Windows, check out the installation instructions. Feature requests, bug reports, patches, and even forked versions are all welcome: just sent the maintainer(s) an email.

See the changelog and list of known bugs and to-dos for more the latest information.

Getting started

Libraries and their associated documentation:

SoftwareDocumentationPurpose
Comedi "Comedilib handbook" The definitive Linux DAQ driver and library.
Linux-GPIB "Linux-GPIB Documentation" Provides drivers and a NI-compatible API to use GPIB cards.
Python "Extending and Embedding the Python Interpreter" Interprets channel definitions and processes terminal commands.
GTK+ "GTK+ 2 Reference Manual"
"GTK+ 3 Reference Manual"
Library for creating the GUI and processing user input.
VTE "VTE 0.30 Reference Manual" GTK widget for embedding a terminal in an application.

The development packages for all of the above are needed to compile-in all possible features. On Arch Linux, that means comedilib, linux-gpib, python2, gtk2, and vte. On Ubuntu: libcomedi-dev, libgpib0-dev (available here), python2.7-dev (or python2.6-dev), libgtk2.0-dev, and libvte-dev.

Compiling the code

Mezurit 2 is most easily compiled in a Linux environment, although it could probably be done in Cygwin, too. Note: Mezurit 2 does not use autotools. Instead, it includes a hand-coded configure script to generate a makefile. Some functions of this script require perl.

1)wget http://www.ugcs.caltech.edu/~mezurit2/dl/mezurit2-0.91.tar.gz(obtain source package)
2)tar xfz mezurit2-0.91.tar.gz
3)cd mezurit2-0.91/
4)./configure --help(view compile-time options, if desired)
5)./configure(generate Makefile and Makefile.dep)
6)make
 
Targeting Microsoft Windows requires a cross-compiler such as MinGW and the win32 versions of GTK+, Python, and pyreadline. A script called get_win32_libs.sh is included with the source to automatically download and configure these packages (requires WINE). In addition, compiling-in support for DAQ or GPIB cards requires several files copied from a Windows installation of the applicable National Instruments drivers. (If you don't have access to such a machine, you are unfortunately out of luck in that department.) The steps are similar to those above, with a few additions and modifications:
3.1)mkdir $HOME/win32(create a temporary directory for the win32 libraries)
3.2)utils/get_win32_libs.sh $HOME/win32(argument must be an absolute path, may take a few minutes)
3.3)(manually copy additional files from a Windows machine)(see Table of National Instruments files)
5)./configure --mingw --win32path=$HOME/win32(see --driver option to specify NI-DAQmx, etc.)

Linux installation, package generation

7)sudo make install
8)sudo checkinstall(Ubuntu only, generates .deb.)

Windows package generation

The Windows version of Mezurit 2 is distributed in a self-contained directory (including GTK and Python libraries), so package generation is simple:

7)make install_local
8)zip -r Mezurit2-0.91.zip Mezurit2/

Testing (Linux only)

Mezurit 2 can be "installed" to a local directory for easy testing. When invoked it will load resource files from the local install directory rather than /usr/share/mezurit2. However, it will still access (and possibly update) files in the user config directory ~/.config/mezurit2.

7)make install_local
8)mezurit2/mezurit2
 
After editing source files, simply repeat step 7 to recompile. If preprocessor directives, e.g. #include or #ifdef, were modified, it is a good idea to do make clean and ./configure --regen to get an updated copy of Makefile.dep.
 
Memory leaks and other errors can be found using Valgrind. A simple (but overzealous) suppression file is included with Mezurit2 in the utils directory.
9)valgrind --leak-check=full --suppressions=utils/m2.supp mezurit2/mezurit2

Comedi testing

It is possible to connect to a "virtual" comedi device if you have the comedi modules installed using the steps below. Note this is different from the "Dummy" option because Mezurit 2 will think it is connected to a real, physical board. This can be useful for debugging the functions in src/lib/hardware.

1)modprobe comedi comedi_num_legacy_minors=4(force the creation of device nodes)
2)modprobe comedi_test
3)comedi_config /dev/comedi0 comedi_test
4)chmod 660 /dev/comedi0*
5)chgrp iocard /dev/comedi0*(replace iocard with the appropriate group on your system)

Tips

  • All pixmaps used by Mezurit 2 are converted from SVG files residing in the resource/pixmaps directory. To regenerate all the pixmaps, simply run:
    utils/convert_pixmaps.sh resource/pixmaps/ (requires librsvg)
  • Reading raw data generated by an ongoing comedi_cmd from the device's internal buffer, e.g.
    read(comedi_fileno(comedi_dev), &local_buffer[offset], bytes_available)
    can be a bit tricky. The read() function begins where the last invocation left off, and "marks as read" the portion of the internal buffer that was transferred out. When the end of the internal buffer is reached, comedi simply returns to the beginning, overwriting bytes which (hopefully) have already been transferred. The trick is that in this case read() may return prematurely, having read only the data between the "file" pointer and the "end" of the internal buffer. Therefore, Mezurit 2 always calls comedi_get_buffer_contents() before reading, and calls read() a second time if the first does not transfer the promised number of bytes. (See daq_SCAN_read() in src/lib/hardware/daq_scan.c for more information.)