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