El 28 de septiembre de 2011 12:19, Fernando Herrero Carrón <
[email protected]> escribió:
> 2011/9/28 Julien Delange <[email protected]>
>
>> 2011/9/27 Fernando Herrero Carrón <[email protected]>:
>> > [snip]
>>
>> Dear Fernando,
>>
>> Would it be possible to provide more information about your bug, in
>> particular, the configuration of the board (which is analogy0, ...)
>> and the code you are trying to use ?
>>
>> Also, as Gilles said, please also try the latest rc release, it might
>> solve your issues.
>>
>> Thanks,
>>
>
> Dear Gilles and Julien,
>
> Thanks for your replies. I will try the latest RC and let you know.
>
> These are the details of my setup:
>
> - Dmesg output:
>
> Analogy: MITE: Available NI device IDs: 0x1870 0x70c0
>
> - lspci:
> 01:05.0 Class ff00: National Instruments Device 70c0 (this should be the NI
> 6143) <- used for AO
> 01:06.0 Class ff00: National Instruments PCI-6713 <- used for AI
>
> - analogy-config:
> /usr/xenomai/sbin/analogy_config analogy0 analogy_ni_pcimio 1,5
> /usr/xenomai/sbin/analogy_config analogy1 analogy_ni_pcimio 1,6
>
> - cat /proc/analogy/devices
> -- Analogy devices --
>
> | idx | status | driver
> | 00 | Linked | analogy_ni_pcimio
> | 01 | Linked | analogy_ni_pcimio
> | 02 | Unused | No driver
> [...]
>
> - cat /proc/analogy/00-analogy_ni_pcimio
> -- Subdevices --
>
> | idx | type
> | 00 | Analog input subdevice
> | 01 | Unused subdevice
> | 02 | Digital input/output subdevice
> | 03 | Unused subdevice
> | 04 | Unused subdevice
> | 05 | Calibration subdevice
> | 06 | Memory subdevice
> | 07 | Digital input/output subdevice
> | 08 | Unused subdevice
> | 09 | Serial subdevice
> | 10 | Unused subdevice
> | 11 | Counter subdevice
> | 12 | Counter subdevice
> | 13 | Counter subdevice
>
> - cat /proc/analogy/01-analogy_ni_pcimio
> -- Subdevices --
>
> | idx | type
> | 00 | Unused subdevice
> | 01 | Analog output subdevice
> | 02 | Digital input/output subdevice
> | 03 | Unused subdevice
> | 04 | Unused subdevice
> | 05 | Calibration subdevice
> | 06 | Memory subdevice
> | 07 | Digital input/output subdevice
> | 08 | Unused subdevice
> | 09 | Serial subdevice
> | 10 | Unused subdevice
> | 11 | Counter subdevice
> | 12 | Counter subdevice
> | 13 | Counter subdevice
>
> Thanks,
> Fernando
>
Dear all,
I have followed your advice and just tested with the following
kernel/xenomai versions:
Linux ******** 2.6.38.8-xenomai-2.6rc4 #1 SMP PREEMPT Thu Sep 29 16:17:41
BRT 2011 x86_64 GNU/Linux
Now both "cmd_read" and my own code are running, but "a4l_async_read" reads
either garbage or either value of 0 or 0x8000. In order to make cmd_read
work with my board I had to make the following changes to the code:
--- cmd_read.c.orig 2011-09-29 16:40:50.000000000 -0300
+++ cmd_read.c 2011-09-29 16:41:04.000000000 -0300
@@ -66,8 +66,8 @@
.start_arg = 0,
.scan_begin_src = TRIG_TIMER,
.scan_begin_arg = 8000000, /* in ns */
- .convert_src = TRIG_TIMER,
- .convert_arg = 500000, /* in ns */
+ .convert_src = TRIG_NOW,
+ .convert_arg = 00000, /* in ns */
.scan_end_src = TRIG_COUNT,
.scan_end_arg = 0,
.stop_src = TRIG_COUNT,
otherwise the drive would complain about "the driver cmd_test failed" or
something like that, because my board has 8 parallel ADCs.
If I run my program (see attachment) and call dmesg I can see:
[ 641.237710] Analogy: analogy_ni_pcimio: ni_ai_cmd: start
[ 641.237718] Analogy: analogy_ni_pcimio: ni_ai_cmd:
Interrupt_A_Enable_Register = 0x0031
[ 641.237723] Analogy: analogy_ni_pcimio: ni_ai_cmd: exit
[ 641.238874] Analogy: analogy_ni_pcimio: ni_mio_common: interrupt:
a_status=90b0 ai_mite_status=00200000
[ 641.239872] Analogy: analogy_ni_pcimio: ni_mio_common: interrupt:
a_status=9030 ai_mite_status=00200000
[...]
[ 642.237879] Analogy: analogy_ni_pcimio: ni_mio_common: interrupt:
a_status=9070 ai_mite_status=00200000
[ 642.237881] Analogy: analogy_ni_pcimio: ni_mio_common: SC_TC interrupt
I just checked my setup with our RTAI/comedi code and it is properly
working. The input card is attached to a 3Hz sine wave generator with 1V
peek-to-peek. If I run the attached program, the output looks like this:
Analogy device analogy_ni_pcimio.
Channel 0 has 16 bits and 1 different ranges
32768
32768
32768
32768
32768
[...]
32768
Any help on debugging this would be greatly appreciated.
Sincerely,
Fernando
/**
* Use analogy commands to read an analog device.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/time.h>
#include <signal.h>
#include <pthread.h>
#include <math.h>
#include <analogy/analogy.h>
#include <analogy/command.h>
#include <native/task.h>
#define NICHAN 1
#define INPUT_FREQ 1000
a4l_desc_t dev_input;
a4l_chinfo_t *chaninfos[NICHAN] = {0};
static lsampl_t maxdatai;
int ret = 0;
#define SAMPLE_HISTORY 1000
long unsigned int channel_history[SAMPLE_HISTORY][NICHAN] = {0};
RT_TASK rt_task_desc;
int init_board(void)
{
int result = 0;
result = a4l_open(&dev_input, "analogy0");
printf("Analogy device %s.\n", dev_input.board_name);
if (result){
printf("Unable to open %s.\n", dev_input.board_name);
return 1;
}
dev_input.sbdata = malloc(dev_input.sbsize);
if (dev_input.sbdata == NULL)
{
fprintf (stderr, "Malloc error at %s, line %d.\n", __FILE__, __LINE__);
exit(-1);
}
ret = a4l_fill_desc(&dev_input);
if(ret < 0)
{
fprintf (stderr, "%d at %s, line %d.\n", ret, __FILE__, __LINE__);
exit(-1);
}
return 0;
}
void setup_input_card(a4l_desc_t *dev)
{
unsigned int chanlist[NICHAN] = {0};
a4l_cmd_t cmd;
// Set up command
memset(&cmd, 0, sizeof(cmd));
// Setup chan list
for(int i = 0; i < NICHAN; i++){
chanlist[i] = PACK(i, 0, AREF_COMMON);
}
cmd.idx_subd = 0;
cmd.start_src = TRIG_NOW;
cmd.start_arg = 0;
cmd.flags = TRIG_WAKE_EOS;
cmd.scan_begin_src = TRIG_TIMER;
cmd.scan_begin_arg = 1e9 / INPUT_FREQ;
cmd.convert_src = TRIG_NOW;
cmd.convert_arg = 0;
cmd.chan_descs = chanlist;
cmd.nb_chan = NICHAN;
cmd.scan_end_src = TRIG_COUNT;
cmd.scan_end_arg = NICHAN;
cmd.stop_src = TRIG_COUNT;
cmd.stop_arg = SAMPLE_HISTORY;
for(int i = 0; i < NICHAN; i++)
{
int ret = a4l_get_chinfo(dev, 0, i, &chaninfos[i]);
printf("Channel %d has %d bits and %d different ranges\n", i, chaninfos[i]->nb_bits, chaninfos[i]->nb_rng);
if(ret < 0)
{
fprintf (stderr, "%d at %s, line %d.\n", ret, __FILE__, __LINE__);
break;
}
}
a4l_snd_cancel(dev, 0);
/* Start the command */
ret = a4l_snd_command(dev, &cmd);
if(ret < 0){
fprintf (stderr, "%d at %s, line %d.\n", ret, __FILE__, __LINE__);
exit(1);
}
}
int main(void)
{
unsigned char input_buffer[NICHAN * 10];
mlockall(MCL_CURRENT | MCL_FUTURE);
int ret = rt_task_shadow(&rt_task_desc, NULL, 1, 0);
if (ret < 0) {
fprintf(stderr, "rt_task_shadow failed (ret=%d)\n", ret);
exit(-1);
}
if (init_board()) {;
printf("Board initialization failed.\n");
return 1;
}
setup_input_card(&dev_input);
for(int scan = 0; scan < SAMPLE_HISTORY; scan++)
{
int m = a4l_async_read(&dev_input, input_buffer, NICHAN * a4l_sizeof_chan(chaninfos[0]), A4L_INFINITE);
a4l_rawtoul(chaninfos[0], channel_history[scan], input_buffer, NICHAN);
}
a4l_snd_cancel(&dev_input, 0);
a4l_close(&dev_input);
for (int i = 0; i < SAMPLE_HISTORY; i++) {
for(int j = 0; j < NICHAN; j++)
{
printf("%lu ", channel_history[i][j]);
}
printf("\n");
}
return 0;
}
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help