/*************************************************************************** DtoA.c - description ------------------- begin : Wed Dec 10 2003 copyright : (C) 2003 by NZG email : ngustavson@emacinc.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ /*! @defgroup DtoA DtoA - DtoA.c This module is used to build the DtoAwrite application. DtoA write is used to change the 12 bit value of an external DtoA port. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define ARGCHECK(num){if(argc<=num){printf("invalid number of arguements\n");help();return -1;}} #define OPENDEV(filed,dev){if((filed = open(dev, O_RDWR))<=0){printf("couldn't open %s\n",dev);return -1;}} static int help(void) { const char *help_table = "********************************************** *DtoAwrite * *Nathan Z. Gustavson * *Emac.inc * *"__DATE__" * *usage: * *DtoAwrite device channel value * *ex * *DtoAwrite /dev/37e12 0 0xff * *writes 0xff to DtoA channel 0 * **********************************************\n"; printf("%s",help_table); return 0; } int main(int argc, char **argv) { int fd,channel,data; ARGCHECK(3); channel = strtoul(argv[2],NULL,0); data = strtoul(argv[3],NULL,0); OPENDEV(fd,argv[1]); E12_DtoA_Write(fd, channel,data); close(fd); return 0; }