Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider 19dc797a rédigé par Pierre LINDENBAUM's avatar Pierre LINDENBAUM :speech_balloon:
Parcourir les fichiers

cont

parent 47d48f85
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -18,7 +18,10 @@
#define DEBUG(f_, ...) do { fprintf(stderr,"[DEBUG:%d]\"",__LINE__);fprintf(stderr,(f_), __VA_ARGS__);fprintf(stderr,"\"\n");} while(0);
int subdev = 1; /* change this to your input subdevice */
#define WHERE fprintf(stderr,"[DEBUG:%d]\"",__LINE__)
int subdevr = 0; /* change this to your input subdevice */
int subdevw = 1; /* 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 */
......@@ -30,42 +33,50 @@ int main(int argc, char *argv[])
;
double physical_value;
int retval;
comedi_range *range_info;
lsampl_t maxdata;
comedi_range *range_infor;
lsampl_t maxdatar;
comedi_range *range_infow;
lsampl_t maxdataw;
device = comedi_open(filename);
if (device == NULL) {
comedi_perror(filename);
return 1;
}
range_info = comedi_get_range(device, subdev, chan, range);
maxdata = comedi_get_maxdata(device, subdev, chan);
range_infor = comedi_get_range(device, subdevr, chan, range);
maxdatar = comedi_get_maxdata(device, subdevr, chan);
range_infow = comedi_get_range(device, subdevw, chan, range);
maxdataw = comedi_get_maxdata(device, subdevw, chan);
comedi_set_global_oor_behavior(COMEDI_OOR_NAN);
double userdata=10;
double sign=1;
double shift=0.001;
double max=10;
for(;;)
{
//DEBUG("userdata = %g",userdata);
lsampl_t data = comedi_from_phys(userdata, range_info, maxdata);
//DEBUG("data = %d",data);
retval = comedi_data_write(device, subdev, chan, range, aref,
data);
lsampl_t data;
retval = comedi_data_read(device, subdevr, chan, range, aref,
&data);
if (retval < 0) {
WHERE;
comedi_perror(filename);
return 1;
}
double physical_value = comedi_to_phys(data, range_infor, maxdatar);
physical_value=-physical_value;
userdata +=(sign*shift);
if(userdata > max) {
userdata= max;
sign=-sign;
}
else if(userdata < -max){
userdata= -max;
sign=-sign;
data = comedi_from_phys(physical_value, range_infow, maxdataw);
retval = comedi_data_write(device, subdevw, chan, range, aref,
data);
if (retval < 0) {
WHERE;
comedi_perror(filename);
return 1;
}
}
return 0;
}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter