00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00024 #include <stdlib.h>
00025 #include <stdio.h>
00026 #include <string.h>
00027 #include <sys/ioctl.h>
00028 #include <unistd.h>
00029 #include <sys/types.h>
00030 #include <asm/types.h>
00031 #include <sys/stat.h>
00032 #include <fcntl.h>
00033 #include <signal.h>
00034 #include <sched.h>
00035 #include <sys/resource.h>
00036 #include <sys/io.h>
00037 #include <E12user.h>
00038 #include <packet.h>
00039 #include <coprocessor.h>
00040
00041 #define ARGCHECK(num){if(argc<=num){printf("invalid number of arguements\n");help();return -1;}}
00042 #define OPENDEV(filed,dev){if((filed = open(dev, O_RDWR))<=0){printf("couldn't open %s\n",dev);return -1;}}
00043
00044 static int help(void)
00045 {
00046 const char *help_table = "**********************************************
00047 *DtoAwrite *
00048 *Nathan Z. Gustavson *
00049 *Emac.inc *
00050 *"__DATE__" *
00051 *usage: *
00052 *DtoAwrite device channel value *
00053 *ex *
00054 *DtoAwrite /dev/37e12 0 0xff *
00055 *writes 0xff to DtoA channel 0 *
00056 **********************************************\n";
00057 printf("%s",help_table);
00058 return 0;
00059 }
00060
00061 int main(int argc, char **argv)
00062 {
00063 int fd,channel,data;
00064 ARGCHECK(3);
00065 channel = strtoul(argv[2],NULL,0);
00066 data = strtoul(argv[3],NULL,0);
00067 OPENDEV(fd,argv[1]);
00068 E12_DtoA_Write(fd, channel,data);
00069 close(fd);
00070 return 0;
00071 }
00072