Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Related Pages  

version.c

00001 
00006 #include <stdlib.h>
00007 #include <stdio.h>
00008 #include <string.h>
00009 #include <sys/ioctl.h>
00010 #include <unistd.h>
00011 #include <sys/types.h>
00012 #include <asm/types.h>
00013 #include <sys/stat.h>
00014 #include <fcntl.h>
00015 #include <signal.h>
00016 #include <sched.h>
00017 #include <sys/resource.h>
00018 #include <sys/io.h>
00019 #include <E12user.h>
00020 #include <packet.h>
00021 #include <coprocessor.h>
00022 
00023 
00024 
00025 #define ARGCHECK(num){if(argc!=num){printf("invalid number of arguements\n");help();return -1;}}
00026 
00027 #define OPENDEV(filed,dev){if((filed = open(dev, O_RDWR))<=0){printf("couldn't open %s\n",dev);return -1;}}
00028 
00029 static int help(void)
00030 {
00031 const char *help_table = "**********************************************
00032 *version                                     *
00033 *Nathan Z. Gustavson                         *
00034 *Emac.inc                                    * 
00035 *"__DATE__"                                 *   
00036 *usage:                                      *   
00037 *version device                              *
00038 *ex:                                         *
00039 *version /dev/37e12                          *
00040 *Gets the firmware version                   *
00041 *of /dev/37e12                               *
00042 **********************************************\n";
00043 printf("%s",help_table);
00044 return 0;
00045 }
00046 
00047 #define VERSIONMASK BITMASK(VERSIONINFO)
00048 
00049 int main(int argc, char **argv)
00050 {
00051 int fd,rxnum;
00052 VersionInfo *version;
00053 __u8 buffer[100];
00054 Cop_Data *CopRouter;
00055 __u32 typemask;
00056 
00057 ARGCHECK(2);
00058 OPENDEV(fd,argv[1]);
00059 
00060 CopRouter = CopDeviceCreate(0);
00061 version = &CopRouter->version;
00062 
00063 e12packetout(fd,VERSIONINFO,0,NULL);
00064 rxnum = read(fd,buffer,sizeof(buffer));
00065 typemask = E12_Packet_Route(CopRouter,buffer, rxnum);
00066 
00067 if(typemask&VERSIONMASK)
00068   {
00069  printf("version %u.%u -- %s\n",version->version>>4,version->version&0x0F,version->date);
00070   }
00071 
00072 close(fd);
00073 
00074 return 0;
00075 
00076   }
00077 
00078 

Generated on Thu Jan 8 09:51:00 2004 for PCM-37e12 by doxygen1.2.15