- From: Arno Stienen <a.h.a.stienen_at_utwente.nl>
- Date: Tue, 22 May 2007 07:28:13 +0200
Hi Roberto,
I must say that having followed your (wonderful) RTAI-Lab tutorial now
on both Slackware as Ubuntu systems, the Comedilib .h-files are
installed under /usr/local/include/, and not, as seems to be inferred by
the tutorial (pag 9, par 2.8, step 7&8), in /usr/include/. Only when I
change the steps from:
7. cp include/linux/comedi.h /usr/include/
cp include/linux/comedilib.h /usr/include/
8. ln -s /usr/include/comedi.h /usr/include/linux/comedi.h
ln -s /usr/include/comedilib.h /usr/include/linux/comedilib.h
ln -s /usr/include/linux /usr/local/include/linux
to:
7. cp include/linux/comedi.h /usr/local/include/
cp include/linux/comedilib.h /usr/local/include/
8. ln -s /usr/include/local/comedi.h /usr/include/local/linux/comedi.h
ln -s /usr/include/local/comedilib.h \
/usr/include/local/linux/comedilib.h
# (no longer needed)
# ln -s /usr/include/linux /usr/local/include/linux
do I overwrite the two Comedilib .h-files with the two Comedi .h-files.
The original steps in the tutorial would have left me with a double set
of .h-files, one stored in /usr/include, the other in
/usr/local/include, which makes the including order an important parameter.
But I could be missing some basic reasoning here! Please inform me. :)
Bye,
Arno.
Roberto Bucher wrote:
> Please check that the comedi includes under /usr/local/include are the files
> provided by comedi and not the files from comedilib (which cause some
> compilation errors).
>
> Roberto
>
> On Monday 21 May 2007 19:09, L.C. Karssen wrote:
>> On Mon, 2007-05-21 at 16:30 +0000, L.C. Karssen wrote:
>>> On Mon, 2007-05-21 at 19:52 +0200, Paolo Mantegazza wrote:
>>>> L.C. Karssen wrote:
>>>>> On Mon, 2007-05-21 at 09:42 +0000, L.C. Karssen wrote:
>>>>>> On Sun, 2007-05-13 at 23:37 +0200, Paolo Mantegazza wrote:
>>>>>>> L.C. Karssen writes:
>>> Furthermore, I looked at rtai_comedi_dioout.c from RTAILab and found
>>> that it includes rtai_comedi.h. I have the following RTAI and comedi
>>> related includes:
>>> #include "/usr/local/include/comedilib.h"
>>> #include <rtai_lxrt.h>
>>>
>>> I included rtai_comedi.h but that resulted in a lot of errors because of
>>> overshadowed definitions (because of comedilib.h).
>> An example of such an error:
>>
>> In file included from daqwrite.c:25:
>> /usr/realtime/include/rtai_comedi.h:123: error: conflicting types for
>> 'comedi_open'
>> /usr/local/include/comedilib.h:68: error: previous declaration of
>> 'comedi_open' was here
>>
>>
>> In comedilib.h:68:
>> comedi_t *comedi_open(const char *fn);
>>
>> In rtai_comedi.h:123:
>> RTAI_PROTO(void *, comedi_open,(const char *filename))
>> {
>> char lfilename[COMEDI_NAMELEN];
>> struct { char *minor; } arg = { lfilename };
>> strncpy(lfilename, filename, COMEDI_NAMELEN - 1);
>> return rtai_lxrt(FUN_COMEDI_LXRT_INDX, COMEDI_LXRT_SIZARG,
>> _KCOMEDI_OPEN, &arg).v[LOW];
>> }
>>
>>> When only including
>>> rtai_comedi.h I get a lot of syntax errors. I'm going to check why that
>>> happens.
>> When not including /usr/local/comedilib.h I get errors because of
>> missing definitions of e.g. comedi_t, comedi_range and comedi_dev. The
>> typedefs of these are in comedilib.h.
>> I need those to initialise my comedi device, as in the following code
>> for example:
>> comedi_t *comedi_dev;
>> comedi_dev = comedi_open(comedi_devname);
>>
>>
>> Lennart
>>
>>> Thanks,
>>>
>>> Lennart
>>>
>>>> Paolo
>>>>
>>>>>> Any help is appreciated!
>>>>>>
>>>>>>
>>>>>> Lennart.
>>>>>>
>>>>>>
>>>>>> int do_comedi(struct data_struct *options)
>>>>>> {
>>>>>> comedi_t *comedi_dev = options->device;
>>>>>> unsigned int ao_subdev = options->AO_subdevice; // Analog
>>>>>> Output unsigned int dio_subdev = options-> DIO_subdevice; // Digital
>>>>>> IO int range=0; // AO has only one range: 10V -> -10V
>>>>>> comedi_insn insn;
>>>>>> lsampl_t data;
>>>>>> unsigned int dio_bits;
>>>>>> int aref = AREF_GROUND;
>>>>>> unsigned int dio_mask = 0xFFFFFFFF; // Tells which DIO bits are
>>>>>> to be flipped (all).
>>>>>>
>>>>>> int period;
>>>>>> struct bits *data_arr = options->bitsarr;
>>>>>>
>>>>>> RT_TASK* task;
>>>>>> int priority=0;
>>>>>> int stack_size=4096;
>>>>>> int msg_size=0;
>>>>>>
>>>>>> int i;
>>>>>>
>>>>>> /* Prepare the AO instruction as much as possible. Later, in real
>>>>>> time
>>>>>> * we'll only fill in the data sample. */
>>>>>> insn.insn = INSN_WRITE;
>>>>>> insn.n = 1;
>>>>>> insn.subdev = ao_subdev;
>>>>>>
>>>>>> /* A better scheduler than linux' one */
>>>>>> struct sched_param mysched;
>>>>>>
>>>>>> /* We don't want to be swapped out the mem */
>>>>>> mlockall (MCL_CURRENT | MCL_FUTURE);
>>>>>> /* Allow nonroot users hard realtime access */
>>>>>> rt_allow_nonroot_hrt();
>>>>>>
>>>>>> /* Initialise Scheduler as SCHED_FIFO. Greatly improves
>>>>>> scheduler! */
>>>>>> mysched.sched_priority = sched_get_priority_max(SCHED_FIFO) - 1;
>>>>>> if( sched_setscheduler( 0, SCHED_FIFO, &mysched ) == -1 )
>>>>>> {
>>>>>> fprintf(stderr, "Error in setting the Scheduler!\n");
>>>>>> exit(1);
>>>>>> }
>>>>>>
>>>>>> /* Register this thread as a RT task. As long as it's
>>>>>> not switched to hard_real_time, it's still a normal process
>>>>>> and can do all normal things */
>>>>>> task = rt_task_init(nam2num("do_comedi"), priority, stack_size,
>>>>>> msg_size);
>>>>>>
>>>>>> // Set mode to periodic. Other option is 'oneshot'
>>>>>> rt_set_periodic_mode();
>>>>>> period = (int) nano2count((RTIME)options->period*1000);
>>>>>>
>>>>>> start_rt_timer(period);
>>>>>>
>>>>>> // Switch to hard realtime mode
>>>>>> rt_make_hard_real_time();
>>>>>>
>>>>>> // Start scheduler
>>>>>> rt_task_make_periodic(task, rt_get_time() + period, period);
>>>>>>
>>>>>>
>>>>>> for (i=0; i<options->n_rows; i++)
>>>>>> {
>>>>>>
>>>>>> /* Prepare and write digital data. */
>>>>>> dio_bits = data_arr[i].DIO;
>>>>>> comedi_dio_bitfield(comedi_dev, dio_subdev, dio_mask, &dio_bits);
>>>>>>
>>>>>> /* Prepare and write AO data */
>>>>>> data = data_arr[i].AO0;
>>>>>> insn.data = &data;
>>>>>> insn.chanspec = CR_PACK(0, range, aref);
>>>>>> if(comedi_do_insn(comedi_dev, &insn)<0)
>>>>>> {
>>>>>> comedi_perror("/dev/comedi0");
>>>>>> exit(1);
>>>>>> }
>>>>>>
>>>>>> data = data_arr[i].AO1;
>>>>>> insn.data = &data;
>>>>>> insn.chanspec = CR_PACK(1, range, aref);
>>>>>> if(comedi_do_insn(comedi_dev, &insn)<0)
>>>>>> {
>>>>>> comedi_perror("/dev/comedi0");
>>>>>> exit(1);
>>>>>> }
>>>>>> rt_task_wait_period();
>>>>>> }
>>>>>>
>>>>>> rt_make_soft_real_time();
>>>>>>
>>>>>> #ifdef DEBUG
>>>>>> printf("We're back in soft realtime.\n");
>>>>>> #endif
>>>>>>
>>>>>> // Stop timer
>>>>>> stop_rt_timer();
>>>>>>
>>>>>> // Unregister RT task
>>>>>> rt_task_delete(task);
>>>>>>
>>>>>> // Unlock mem
>>>>>> munlockall();
>>>>>>
>>>>>> return 0;
>>>>>> }
>>>>>>
>>>>>>> Paolo.
>>>>>>>
>>>>>>>> Lennart.
>>>>>>>> --
>>>>>>>> *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
>>>>>>>> L.C. Karssen
>>>>>>>> Department of Physics and Astronomy
>>>>>>>> Faculty of Science
>>>>>>>> Utrecht University
>>>>>>>> Princetonplein 1
>>>>>>>> 3584 CC Utrecht
>>>>>>>> The Netherlands
>>>>>>>>
>>>>>>>> tel.: +31 (0)30-253-2208
>>>>>>>> fax.: +31 (0)30-253-7468
>>>>>>>> e-mail: L.C.Karssen_at_phys.uu.nl
>>>>>>>> www: http://www1.phys.uu.nl/wwwaoud
>>>>>>>> -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> RTAI mailing list
>>>>>>>> RTAI_at_rtai.org
>>>>>>>> https://mail.rtai.org/cgi-bin/mailman/listinfo/rtai
>
--
____
/ |_| <<< IR. ARNO H.A. STIENEN >>>
|_ O | Biomechanical Engineering | http://www.bw.ctw.utwente.nl
|_|__/ a.h.a.stienen_at_utwente.nl | +31-(0)53-489-4778
UTwente
"Try the new Windows Vista simulator; turn on all the flashy crap
in XP, change the background image, take some memory out of your
computer and clock down the CPU. Then break Media player."
Received on 2007-05-22Z04:28:13