/*************************************************************************** divider.c - description ------------------- begin : Tue Jan 6 2004 copyright : (C) 2004 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. * * * ***************************************************************************/ #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 = "*************************************************** *divider * *Nathan Z. Gustavson * *EMAC.Inc * *"__DATE__" * *usage: * *divider device in out divide * *ex: * *divider /dev/37e12 0 1 100 * *divides the input of digital 0 by 100 on digital1* ***************************************************\n"; printf("%s",help_table); return 0; } int main(int argc, char **argv) { int fd; int in, out, divide; unsigned char mask; int data; Cop_Data *Cop; ARGCHECK(5); OPENDEV(fd,argv[1]); in = strtoul(argv[2],NULL,0); out = strtoul(argv[3],NULL,0); divide = strtoul(argv[4],NULL,0); mask = 1<