
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>



main()
{
   int fd;
   int ret;
   int count;
   unsigned char buf[512*512+1];
   
   fprintf(stderr,"ctest start\n");
   
   fd = open( "/dev/cortex" , O_RDWR );
   if ( fd < 0 )
   {
      fprintf(stderr,"ctest open failed with %d \n",fd);
      exit(1);
   }
   fprintf(stderr,"ctest opened device \n");

   count = 486*512;
   ret=read(fd, buf, count);
   fprintf(stderr,"ctest read %d bytes (%d requested)\n",ret,count);

   close(fd);
   fprintf(stderr,"ctest closed device \n");

   printf("P2\n512 486\n255\n");
   for( count =0 ; count < 486*512 ; count ++ )
   {
      printf("%03d ",buf[count]);
      if ( (count%20) == 0 ) printf("\n");
   }
   printf("\n");

   fprintf(stderr,"ctest done\n");
   exit(0);
}
