Getting a driver, dt9812 to be exact

29 views
Skip to first unread message

Zuks

unread,
Jul 1, 2009, 10:29:35 AM7/1/09
to Comedi: Linux Control and Measurement Device Interface
I am working on the Acer Aspire A110 and the operating system I am
running on it is Ubuntu UNR

I want to use the machine to communicate with the DT9812 USB Data
Acquisition Module.

Now in trying to get comedi set up in this machine to help me do this
I followed the recommended steps:
1. Got the latest comedi zip file from the comedi sight: www.comedi.org
1.2. Unpacked with "tar xzvf comedi.tar.gz".
1.3. "cd comedi-0.7.76/"
1.4. for CVS checkouts: "sh autogen.sh"
1.5. "./configure"
1.6. "make"
1.7. "sudo -s"
1.8. "make install"
1.9. "depmod -a"

2. Got the latest comedilib zip file from the comedi sight
2.1. Unpacked with "tar xzvf comedilib.tar.gz"
2.2. "cd comedilib-0.8.1/"
2.3. If you've downloaded from the cvs make sure the "libtool",
"automake", "byacc", "bison", "flex" (etc) packages are installed and
then type: "sh autogen.sh"
2.4. "./configure --with-udev-hotplug=/lib --sysconfdir=/etc"
2.5. "make"
2.6. "sudo -s"
2.7. "make install"

It seemed like it installed without any errors but when I tried to see
if the DT9812 card works by following an example which gave me these
steps:

In comedilib there's a directory which is called "demo":
./cmd (reads 1 sec of data)
./insn (reads 10 values from input 0)
./outp -s 1 2000 (outputs 1000 to the output 0)
./ao_waveform (10 Hz sine wave at output 0)

I got the following message:
/dev/comedi0: No such file or directory

I was told by someone who was trying to help me that this means that
the driver for the module I am working with is not installed and that
is why it gave this message.
I tried to search for the driver in the web. The best I came across
was some c files which I tried to compile but they gave me some
problems.

So does anyone have any direction that I can take at this point to
solve this problem. Any assistance would be appreciated.
Thank you.

Ian Abbott

unread,
Jul 1, 2009, 10:54:22 AM7/1/09
to comed...@googlegroups.com

Does this succeed?:

sudo modprobe dt9812

And if it succeeds, does this work?:

sudo comedi_config /dev/comedi0 dt9812

The first command should load the kernel modules if they're not already
loaded. The second command maps /dev/comedi0 to a dt9812 device if the
driver has detected one.

(There is some new auto-configuration stuff in comedi that should make
the comedi_config command unneccessary in the future, but it hasn't been
implemented yet for the dt9812 driver.)

If the modprobe never succeeded, it may be because the drivers never
built properly. Check the output of 'make' for the 'comedi' package.
It's a little confusing because the Makefile is currently set up to
ignore compilation errors!

In fact, you are unlikely to get comedi-0.7.76 to build on a recent
kernel version, so you will be better off trying the CVS version.

You should also be able to find Debian or possibly Ubuntu packages, but
I'm not sure if they work.

--
-=( Ian Abbott @ MEV Ltd. E-mail: <abb...@mev.co.uk> )=-
-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-

fredfox

unread,
Jul 1, 2009, 11:24:51 AM7/1/09
to comed...@googlegroups.com
Yes, I can verify that you need to use the CVS copy. Release 0.7.76 will
not build on Ubuntu (jaunty) and the version available in Ubuntu Jaunty
(the standard Ubuntu repositories) will not install due to a dependency
version conflict with libtool which is at version 2.2.3 or some such and
comedi_source is still set to require less than or equal to 2.0

Comedi_lib installed fine from the repositories so I used it and did not
build it.

So yes, build from the current CVS version using the instructions found
here: http://www.comedi.org/wiki/Installation_on_Ubuntu

I had to add a UDEV rule to get a PCMCIA card to be properly loaded, but
I don't think you will need to do so for a USB device.

--
Fred Fox, Agricultural Engineer
USDA-ARS Wind Erosion Research Unit
1515 College Avenue
Manhattan, KS 66502
E-mail: fred...@ars.usda.gov
phone: (785)537-5540
fax: (785)537-5507
Web: http://www.ars.usda.gov/npa/gmprc/weru

Zuks

unread,
Jul 2, 2009, 10:43:12 AM7/2/09
to Comedi: Linux Control and Measurement Device Interface
The installation seemed to had worked.

I did the following:
1: I downloaded the comedi and the comedilib compressed files for cvs
and followed the instructions to load them into the system.

-Then I typed this command:
sudo modprobe dt9812
It did not show any message nor complain as it did before so I took
it to had worked.

-But when I typed this command:
"sudo comedi_config /dev/comedi0 dt9812" t gave me a message
complaining about a missing file:
/dev/comedi0: No such file or directory

Is /dev/comedi0 supposed to be automatically generated when I install
comedi and comedilib or am I still missing something?

Ian Abbott

unread,
Jul 2, 2009, 11:00:14 AM7/2/09
to comed...@googlegroups.com

I think this is due to the auto-configuration feature that was added to
comedi recently, but hasn't been implemented for the dt9812 driver yet.
You'll need to pass some parameters to the comedi module when it is
being loaded. The easiest way to do this is to create the file
/etc/modprobe.d/comedi and add one of the following lines:

options comedi comedi_autoconfig=0

-or-

options comedi num_legacy_minors=4


The first variant disables comedi's auto-configuration feature
completely. The second variant reserves the first 4 devices
/dev/comedi0 through /dev/comedi3 for "legacy" devices, i.e. those
devices whose drivers don't support auto-configuration. Any
auto-configured devices would start at /dev/comedi4 in this case. The
number '4' can be changed to anything from 0 to 48 to reserve that many
legacy devices.

Zuks

unread,
Jul 8, 2009, 10:41:18 AM7/8/09
to Comedi: Linux Control and Measurement Device Interface
The cvs version of Comedi seems to have worked.

I am now following the steps in the comedi site about writing your own
comedi programs to see if I can now begin to communicate with the
dt9812 card using c/c++ code.

I copied this code:

#include <stdio.h> /* for printf() */
#include <comedilib.h>

int subdev = 0; /* change this to your input subdevice */
int chan = 0; /* change this to your channel */
int range = 0; /* more on this later */
int aref = AREF_GROUND; /* more on this later */

int main(int argc,char *argv[])
{
comedi_t *it;
lsampl_t data;

it=comedi_open("/dev/comedi0");

comedi_data_read(it,subdev,chan,range,aref, & data);

printf("%d\n",data);

return 0;
}

I saved it into a file called "test1.c"

I used the "gcc" compiler like this "gcc test1.c -lcomedi -o test1"

Then I got the following error message:
/usr/local/lib/libcomedi.so: undefined reference to `floor'
/usr/local/lib/libcomedi.so: undefined reference to `nearbyint'
collect2: ld returned 1 exit status

Then when I used the "g++" compiler it seemed to compile but when I
executed the executable file "./test1" I got this message:
./test1: error while loading shared libraries: libcomedi.so.0: cannot
open shared object file: No such file or directory

Am I missing something?
> -=( Ian Abbott @ MEV Ltd.    E-mail: <abbo...@mev.co.uk>        )=-

Zuks

unread,
Jul 8, 2009, 10:48:26 AM7/8/09
to Comedi: Linux Control and Measurement Device Interface
Also when I go to the directory "/comedilib/demo/" and try out the
executables there these are the responses that I get:
for "./cmd":
comedi_get_cmd_generic_timed failed
command before testing:
subdevice: 0
start: unknown(0x00000000) 0
scan_begin: unknown(0x00000000) 0
convert: unknown(0x00000000) 0
scan_end: unknown(0x00000000) 0
stop: unknown(0x00000000) 0
comedi_command_test: Command not supported
Ummm... this subdevice doesn't support commands

for "./inp":
1 (if the card is attached) or 0 (if the card is not attached)

I don't know if this is a sign that the card is connected well or if I
am missing something.

Please advise



On Jul 2, 5:00 pm, Ian Abbott <abbo...@mev.co.uk> wrote:
> -=( Ian Abbott @ MEV Ltd.    E-mail: <abbo...@mev.co.uk>        )=-

Ian Abbott

unread,
Jul 8, 2009, 10:50:16 AM7/8/09
to comed...@googlegroups.com

You need to add '-lm' to link with the math library for the 'floor' and
'nearbyint' functions.

> Then when I used the "g++" compiler it seemed to compile but when I
> executed the executable file "./test1" I got this message:
> ./test1: error while loading shared libraries: libcomedi.so.0: cannot
> open shared object file: No such file or directory
>
> Am I missing something?

You need edit the /etc/ld.so.conf file, or edit a <something>.conf file
in the /etc/ld.so.conf.d/ directory. Add the following line:

/usr/local/lib

Then run /sbin/ldconfig to update the binary /etc/ld.so.cache file.
This sets the dynamic linker run-time bindings. See 'man ldconfig' for
more information.


--
-=( Ian Abbott @ MEV Ltd. E-mail: <abb...@mev.co.uk> )=-

Ian Abbott

unread,
Jul 8, 2009, 11:08:27 AM7/8/09
to comed...@googlegroups.com
Zuks wrote:
> Also when I go to the directory "/comedilib/demo/" and try out the
> executables there these are the responses that I get:
> for "./cmd":
> comedi_get_cmd_generic_timed failed
> command before testing:
> subdevice: 0
> start: unknown(0x00000000) 0
> scan_begin: unknown(0x00000000) 0
> convert: unknown(0x00000000) 0
> scan_end: unknown(0x00000000) 0
> stop: unknown(0x00000000) 0
> comedi_command_test: Command not supported
> Ummm... this subdevice doesn't support commands
>
> for "./inp":
> 1 (if the card is attached) or 0 (if the card is not attached)
>
> I don't know if this is a sign that the card is connected well or if I
> am missing something.
>
> Please advise

The comedi_test program is a good one to try. Yes, the driver doesn't
support the comedi_command interface, only the simpler 'insn' interface.

--
-=( Ian Abbott @ MEV Ltd. E-mail: <abb...@mev.co.uk> )=-

Zuks

unread,
Jul 10, 2009, 6:53:33 AM7/10/09
to Comedi: Linux Control and Measurement Device Interface
I was going through the documentation found on the site, section 2.2
to see the details about the subdevices on the board so that I could
understand better how it words.
I saw this command:
demo/info /dev/comedi0

The problem is in the demo directory I don't see the executable file
info, I can see the source file thought (info.c). It seems as though
it was not compiled by the makefile when all the other source files
were compiled and their respective executable files were generated. So
is there a way for me to get the info executable file to be generated
by the source file?

Also there is this problem that I am not sure if it is due to me
having not configured comedi right for the dt9812. When I run the
simple program found in section 3.1 of the site document, which is
suppose to give me a number between 0 and 4095, I end up always
getting a 1 if the board is connected. I get a 0 if it is not
connected.

I am still going through the manual to see if I missed something but
if it is a common known mistake that I am making please do advise.
Thank you.
> -=( Ian Abbott @ MEV Ltd.    E-mail: <abbo...@mev.co.uk>             )=-

Ian Abbott

unread,
Jul 10, 2009, 7:10:18 AM7/10/09
to comed...@googlegroups.com
On 10/07/09 11:53, Zuks wrote:
> I was going through the documentation found on the site, section 2.2
> to see the details about the subdevices on the board so that I could
> understand better how it words.
> I saw this command:
> demo/info /dev/comedi0
>
> The problem is in the demo directory I don't see the executable file
> info, I can see the source file thought (info.c). It seems as though
> it was not compiled by the makefile when all the other source files
> were compiled and their respective executable files were generated. So
> is there a way for me to get the info executable file to be generated
> by the source file?

It's compiled as 'board_info' now.

> Also there is this problem that I am not sure if it is due to me
> having not configured comedi right for the dt9812. When I run the
> simple program found in section 3.1 of the site document, which is
> suppose to give me a number between 0 and 4095, I end up always
> getting a 1 if the board is connected. I get a 0 if it is not
> connected.

You need to set 'subdev = 2' in the program to match the number of the
AI subdevice on your board.

You should find that comedi_data_read() returns -1 if the board is
disconnected, indicating an error. The error can be retrieved by
calling comedi_errno() and should be ENODEV in this case (defined in
<errno.h>).

--
-=( Ian Abbott @ MEV Ltd. E-mail: <abb...@mev.co.uk> )=-

Zuks

unread,
Jul 10, 2009, 9:20:54 AM7/10/09
to Comedi: Linux Control and Measurement Device Interface
Thank you soo much.

I used the "board_info" command and I saw that, as you stated, I was
suppose to be using sub-device 2, and I also got to see what the other
sub-devices are.

I also noticed that the 2006 dt9812 cards seem to not properly work
with the cvs version of comedi I am using, but when I used the 2005
dt9812 card it is now picking up the input well. It varies from 0 to
4095, with 0 corresponding to the -10v input and 4095 corresponding to
the 10v input.

Once again thank you soo much for your patience and help. I appreciate
it much.
> -=( Ian Abbott @ MEV Ltd.    E-mail: <abbo...@mev.co.uk>        )=-

Zuks

unread,
Jul 22, 2009, 8:12:10 AM7/22/09
to Comedi: Linux Control and Measurement Device Interface
I have come across another problem that is rather proving hard for me
to sort out.

I have been using comedi for the past 2 weeks or so now and it has
been working well with my dt9812 card on my acer aspire one.

I wanted to see if the documentation I have been writing all along
could help someone else to be able to get things running from stretch
thus I started by reinstalling the operating system (Ubuntu UNR).

Everything seemed to be installed, both comedi and comedilib.

When I compile the programs I have written they compile successfully.

But when I run them I get this error:
error while loading shared libraries: libcomedi.so.0: cannot open
shared object file: No such file or directory

I do not know how to fix this problem because it did not appear up
until now.

Ian Abbott

unread,
Jul 22, 2009, 8:33:05 AM7/22/09
to comed...@googlegroups.com
On 22/07/09 13:12, Zuks wrote:
> I have come across another problem that is rather proving hard for me
> to sort out.
>
> I have been using comedi for the past 2 weeks or so now and it has
> been working well with my dt9812 card on my acer aspire one.
>
> I wanted to see if the documentation I have been writing all along
> could help someone else to be able to get things running from stretch
> thus I started by reinstalling the operating system (Ubuntu UNR).
>
> Everything seemed to be installed, both comedi and comedilib.
>
> When I compile the programs I have written they compile successfully.
>
> But when I run them I get this error:
> error while loading shared libraries: libcomedi.so.0: cannot open
> shared object file: No such file or directory
>
> I do not know how to fix this problem because it did not appear up
> until now.

You probably need to add '/usr/local/lib' to your dynamic linker search
path, assuming that's where your 'libcomedi.so.0' is installed. You can
do that by editing the '/etc/ld.so.conf' file, or by adding or editing a
file in the '/etc/ld.so.conf.d/' directory. The format is pretty simple
- just list each directory on a line by itself and use lines beginning
with '#' for comments. You need to run '/sbin/ldconfig' afterwards to
update the binary '/etc/ld.so.cache' file that the dynamic linker
actually uses at runtime.

--
-=( Ian Abbott @ MEV Ltd. E-mail: <abb...@mev.co.uk> )=-

Zuks

unread,
Jul 22, 2009, 9:03:42 AM7/22/09
to Comedi: Linux Control and Measurement Device Interface
Thank you
It worked.
> -=( Ian Abbott @ MEV Ltd.    E-mail: <abbo...@mev.co.uk>        )=-
Reply all
Reply to author
Forward
0 new messages