diff -r c0042fa5433b -r 7b722739e329 me8100_test_dio/wtest.c --- a/me8100_test_dio/wtest.c Thu Jan 24 18:53:47 2002 +0100 +++ b/me8100_test_dio/wtest.c Fri Jan 25 16:55:00 2002 +0100 @@ -20,12 +20,14 @@ #include #include #include - +#include #include "me8100.h" #define USE_WRITE -int main(void){ +const char* DEVICE = "/dev/me8100_0a"; + +int main(int argc, char** argv) { int err = 0; static int file_handle = -1; @@ -34,15 +36,16 @@ #endif unsigned short value_a; - printf("Write test, PID: %d\n", getpid()); + if (argc > 1) DEVICE = argv[1]; + printf("Write test, to %s PID: %d\n", DEVICE, getpid()); #ifdef USE_WRITE printf("Using write()\n"); #endif - file_handle = open("/dev/me8100_0a", O_WRONLY, 0); + - if(file_handle < 0){ - printf("Cannot open path !\n"); - return 1; + if (-1 == (file_handle = open(DEVICE, O_WRONLY, 0))) { + fprintf(stderr, "Can't open %s: %m\n", DEVICE); + exit(EXIT_FAILURE); } #ifndef USE_WRITE @@ -54,6 +57,10 @@ } #endif + value_a = 0xffff; + write(file_handle, &value_a, sizeof(value_a)); + exit(EXIT_SUCCESS); + for (value_a = 0x01; value_a < 0xffff; ++value_a) { #ifdef USE_WRITE write(file_handle, &value_a, sizeof(value_a)); @@ -61,7 +68,7 @@ ioctl(file_handle, ME8100_WRITE_DO_A, &value_a); #endif printf("Wrote %04x\n", value_a); - sleep(3); + sleep(1); } err = close(file_handle);