Jan Benda
unread,Jan 30, 2012, 12:25:34 PM1/30/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Comedi: Linux Control and Measurement Device Interface
Hi,
I am having a weired problem with comedi_parse_calibration_file. In a
simple test program that opens a comedi device, calls
comedi_parse_calibration_file() and then prints out some content of
the returned comedi_calibration_t structure, I get the values that are
stored in the calibration file (that was created by
comedi_soft_calibrate).
However, if I construct an QApplication object BEFORE I call
comedi_parse_calibration_file, the values in the comedi_calibration_t
structure are different and wrong. If QApplication is constructed
AFTER comedi_parse_calibration_file, everything is fine.
I am using comedilib from the git repository from today (but that bug
might exist since at least a year), and Qt Version 4.6.3 . It could be
that with older Qt versions this problem might not have occurred. The
simple call of the QApplication constructor should not interfere with
the following comedi_parse_calibration_file!
Any ideas how this could happen and how to solve this problem? Is this
a comedilib, Qt4, yacc/bison or flex problem?
Jan
Here are the details:
***** ai_calibration.cc *******
#include <cstdlib>
#include <iostream>
#include <comedilib.h>
#include <QApplication>
using namespace std;
int main(int argc, char *argv[])
{
comedi_t *dev;
char *calibpath;
comedi_calibration_t *calibration;
char filename[] = "/dev/comedi0";
dev = comedi_open( filename );
if ( dev == NULL ) {
fprintf(stderr, "error opening %s\n", filename);
return -1;
}
QApplication app( argc, argv );
// get calibration:
calibpath = comedi_get_default_calibration_path( dev );
calibration = comedi_parse_calibration_file( calibpath );
// print out:
cerr << "read calibration from file '" << calibpath << '\n';
cerr << " driver: " << calibration->driver_name << '\n';
cerr << " board: " << calibration->board_name << '\n';
cerr << " num: " << calibration->num_settings << '\n';
cerr << " settings[0].subdevice: " << calibration-
>settings[0].subdevice << '\n';
cerr << " settings[0].num_channels: " << calibration-
>settings[0].num_channels << '\n';
cerr << " settings[0].num_ranges: " << calibration-
>settings[0].num_ranges << '\n';
cerr << " settings[0].softcal[0].origin: " << calibration-
>settings[0].soft_calibration.to_phys[0].expansion_origin << '\n';
cerr << " settings[0].softcal[0].c0: " << calibration-
>settings[0].soft_calibration.to_phys[0].coefficients[0] << '\n';
cerr << " settings[0].softcal[0].c1: " << calibration-
>settings[0].soft_calibration.to_phys[0].coefficients[1] << '\n';
free( calibpath );
// cleanup calibration:
if ( calibration != 0 )
comedi_cleanup_calibration( calibration );
calibration = 0;
comedi_close( dev );
return 0;
}
*********
Compiled with
g++ -o ai_calibration ai_calibration.cc -I/usr/include/qt4 -I/usr/
include/qt4/QtGui -I/usr/include/qt4/QtCore -DQT_SHARED -l QtGui -l
QtCore -lcomedi -lm
on a Mint system (debian based).
Out put of the above program:
driver: ni_pcimio
board: pci-6259
num: 15
settings[0].subdevice: 0
settings[0].num_channels: 0
settings[0].num_ranges: 1
settings[0].softcal[0].origin: 3
settings[0].softcal[0].c0: 1
settings[0].softcal[0].c1: 3
If I construct QApplication after comedi_parse_calibration_file:
******
....
// get calibration:
calibpath = comedi_get_default_calibration_path( dev );
calibration = comedi_parse_calibration_file( calibpath );
QApplication app( argc, argv );
// print out:
...
******
I get the right output:
driver: ni_pcimio
board: pci-6259
num: 15
settings[0].subdevice: 0
settings[0].num_channels: 0
settings[0].num_ranges: 1
settings[0].softcal[0].origin: 32767
settings[0].softcal[0].c0: 0.00197151
settings[0].softcal[0].c1: 0.000322424
This is head -n 25 /usr/var/lib/comedi/calibrations/
ni_pcimio_pci-6259_comedi0:
#calibration file generated by comedi_calibrate
#Mon Jan 30 15:21:41 2012
{
driver_name => "ni_pcimio",
board_name => "pci-6259",
calibrations =>
[
{
subdevice => 0,
channels => [],
ranges => [0,],
arefs => [],
caldacs =>
[
],
softcal_to_phys =>
{
expansion_origin =>
3.27670000000000000000e+04,
coefficients =>
[1.97151128925224759791e-03,3.22423522400599625246e-04,-3.90347284338783529878e-13,-1.93886049898568612182e-17,],
},
},
{
subdevice => 0,
channels => [],