#include <stdio.h>
#include <fcntl.h>
#include <rciext/rciioctl.h>
#include <sys/signal.h>



static void sbsexit()
{
  fprintf(stderr, "Unable to access PT-SBS915.\n");
  fprintf(stderr, "Check cable, VME chassis power, etc.\n");
  exit(2);
}



main()
{
  int fd, i;
  char buf[12];

/*  (void) signal(SIGBUS,sbsexit); */

  fprintf(stderr,"opening...\n");
  if ((fd = open("/dev/pti_clk", O_WRONLY)) == -1) {
    perror("unable to open /dev/pti_clk");
    exit(-1);
  }

  fprintf(stderr,"Turning debug on.\n");
  i = 1;
  if (ioctl(fd, RCIIOC_SETCLKDEBUG, &i)) {
    perror("ioctl RCIIOC_SETCLKDEBUG");
    exit(-1);
  }


  sleep(10);

  fprintf(stderr,"Turning clock off.\n");
  if (ioctl(fd, RCIIOC_CLKDISABLE, NULL)) {
    perror("ioctl RCIIOC_CLKDISABLE");
    exit(-1);
  }

  sleep(5);

  fprintf(stderr,"Turning clock on.\n");
  if (ioctl(fd, RCIIOC_CLKENABLE, NULL)) {
    perror("ioctl RCIIOC_CLKENABLE");
    exit(-1);
  }

  sleep(5);

  fprintf(stderr,"closing...\n");
  close(fd);
}

  


