- From: Markus Dostal <dostal_at_syscon2000.de>
- Date: Wed, 13 Nov 2002 15:22:04 +0100
I want load a firmware code with comedi_config, but I use the "opt1" and
"opt2" options for the bus and slot indices (comedi_config [OPTIONS]
<device file> [<driver> <opt1>,<opt2>,...]).
In the first place the comedi_config function write the "opt1" and "opt2"
options to the
"it.options[0]" and "it.options[1]". When the -i option is used the
"it.options[0]" and
"it.options[1]" are overwritten from the "init_data" pointer address and the
"init_size". What can I do to use both: "driver initialization data" and
"bus/slot indices".
I have an example for the solution (lock at the "<----- added" and "<-----
changed" marker):
// if we are attaching or detaching a device
if((argc-optind) > 1 || ((argc-optind) == 1 && remove))
{
if(argc - optind > 1)
driver=argv[optind+1];
else
driver = "none";
strncpy(it.board_name,driver,COMEDI_NAMELEN-1);
for(i=0;i<COMEDI_NDEVCONFOPTS;i++)it.options[i]=0;
if((argc-optind)==3){
opts=argv[optind+2];
i=0;
while(*opts){
if((*opts)==','){
i++;
opts++;
if(i>=COMEDI_NDEVCONFOPTS)
do_help(1);
continue;
}
if(sscanf(opts,"%i%n",&num,&k)>0){
optnum=i;
<------ added
it.options[optnum]=num; <------
changed
opts+=k;
continue;
}
do_help(1);
}
}
ret=stat(fn,&statbuf);
if(ret<0){
perror(fn);
exit(1);
}
#if 0
/* this appears to be broken */
if( !(S_ISCHR(statbuf.st_mode)) ||
major(statbuf.st_dev)!=COMEDI_MAJOR){
if(!quiet)
fprintf(stderr,"warning: %s might not be a comedi
device\n",fn);
}
#endif
if(init_file){
struct stat buf;
init_fd = open(init_file,O_RDONLY);
if(init_fd<0){
perror(init_file);
exit(1);
}
fstat(init_fd,&buf);
init_size = buf.st_size;
init_data = malloc(init_size);
if(init_data==NULL){
perror(_("allocating initialization data\n"));
exit(1);
}
ret = read(init_fd,init_data,init_size);
if(ret<0){
perror(_("reading initialization data\n"));
exit(1);
}
optnum++; <------ added
it.options[optnum]=(int)init_data; <------ changed
optnum++; <------ added
it.options[optnum]=init_size; <------ changed
}
Is this solution good for all boards or have you a other solution?
Markus Dostal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
syscon regelungs- & systemtechnik
johannes-jung-str. 7
D 88239 Wangen
t 0049 (0)7522.9749-15
f 0049 (0)7522.9749-49
http://www.syscon2000.de
email: dostal_at_syscon2000.de
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Received on 2002-11-13Z14:22:04