Commit 49cb2f00 authored by Pavel Vaynerman's avatar Pavel Vaynerman

(iotest):

1. Убрал автоконфигурирование при чтении DO,DI 2. Подправил вывод ошибок
parent dd466d53
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <error.h>
#include <errno.h>
#include <comedilib.h> #include <comedilib.h>
#include <getopt.h> #include <getopt.h>
...@@ -195,17 +197,23 @@ int main(int argc, char* argv[]) ...@@ -195,17 +197,23 @@ int main(int argc, char* argv[])
{ {
case cmdDRead: case cmdDRead:
{ {
for( int k=0; chan[k]!=-1; k++ ) if( autoconf )
{ {
if( comedi_dio_config(card, subdev, chan[k],INSN_CONFIG_DIO_INPUT) < 0) for( int k=0; chan[k]!=-1; k++ )
{ {
comedi_perror("can't configure DI channels"); if( comedi_dio_config(card, subdev, chan[k],INSN_CONFIG_DIO_INPUT) < 0)
exret = EXIT_FAILURE; {
comedi_perror("can't configure DI channels");
exret = EXIT_FAILURE;
}
} }
}
for( int k=0; chan[k]!=-1; k++ )
{
if( comedi_dio_read(card, subdev, chan[k],&data) < 0) if( comedi_dio_read(card, subdev, chan[k],&data) < 0)
{ {
fprintf(stderr, "can't read from channel %d\n",chan[k]); fprintf(stderr, "can't read from channel %d (err(%d): %s)\n",chan[k],errno,strerror(errno));
exret = EXIT_FAILURE; exret = EXIT_FAILURE;
} }
...@@ -216,12 +224,15 @@ int main(int argc, char* argv[]) ...@@ -216,12 +224,15 @@ int main(int argc, char* argv[])
case cmdDWrite: case cmdDWrite:
{ {
for( int k=0; chan[k]!=-1; k++ ) if( autoconf )
{ {
if( comedi_dio_config(card, subdev, chan[k],INSN_CONFIG_DIO_OUTPUT) < 0 ) for( int k=0; chan[k]!=-1; k++ )
{ {
comedi_perror("can't configure DO channels"); if( comedi_dio_config(card, subdev, chan[k],INSN_CONFIG_DIO_OUTPUT) < 0 )
exret = EXIT_FAILURE; {
fprintf(stderr,"can't configure DO channels. (%d) %s", errno,strerror(errno));
exret = EXIT_FAILURE;
}
} }
} }
// реализация мигания // реализация мигания
...@@ -234,7 +245,7 @@ int main(int argc, char* argv[]) ...@@ -234,7 +245,7 @@ int main(int argc, char* argv[])
if( comedi_dio_write(card, subdev, chan[k], val) < 0) if( comedi_dio_write(card, subdev, chan[k], val) < 0)
{ {
comedi_perror("can't write 1 to channel\n"); fprintf(stderr,"can't write 1 to channel %d. (%d) %s\n",k,errno,strerror(errno));
exret = EXIT_FAILURE; exret = EXIT_FAILURE;
} }
} }
...@@ -258,7 +269,7 @@ int main(int argc, char* argv[]) ...@@ -258,7 +269,7 @@ int main(int argc, char* argv[])
int ret = comedi_data_read(card, subdev, chan[k], range, aref, &data); int ret = comedi_data_read(card, subdev, chan[k], range, aref, &data);
if( ret < 0) if( ret < 0)
{ {
fprintf(stderr, "can't read from channel %d: (%d) %s\n",chan[k],ret,strerror(ret)); fprintf(stderr, "can't read from channel %d: (%d) %s\n",chan[k],errno,strerror(errno));
exret = EXIT_FAILURE; exret = EXIT_FAILURE;
} }
...@@ -277,7 +288,7 @@ int main(int argc, char* argv[]) ...@@ -277,7 +288,7 @@ int main(int argc, char* argv[])
int ret = comedi_data_write(card, subdev, chan[k], range, aref, val); int ret = comedi_data_write(card, subdev, chan[k], range, aref, val);
if( ret < 0) if( ret < 0)
{ {
fprintf(stderr, "can't write to channel %d: (%d) %s\n",chan[k],ret,strerror(ret)); fprintf(stderr, "can't write to channel %d: (%d) %s\n",chan[k],errno,strerror(errno));
exret = EXIT_FAILURE; exret = EXIT_FAILURE;
} }
} }
...@@ -364,7 +375,7 @@ void insn_subdev_config( comedi_t* card, int subdev, lsampl_t type ) ...@@ -364,7 +375,7 @@ void insn_subdev_config( comedi_t* card, int subdev, lsampl_t type )
if( comedi_do_insn(card,&insn) < 0 ) if( comedi_do_insn(card,&insn) < 0 )
{ {
fprintf(stderr, "can`t configure subdev subdev=%d type=%d",subdev,type); fprintf(stderr, "can`t configure subdev subdev=%d type=%d. Err(%d): %s",subdev,type,errno,strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment