#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

/* writes to i-bus */
/* to compile: cc and run the a.out */

int main(int argc, char **argv)
{
  int fd;
  int arg;
  int count;

  fd = open("/dev/ibus0",
O_RDWR);
  if(fd == -1) {
    fprintf(stderr, "Error: could not open /dev/ibus0 for reading.\n");
    exit(1);
  }

  do {
    printf("Enter a number: ");
    scanf("%d",&arg);
    write(fd, &arg, 1);
//  }while (arg>=0);  // enter negative number to exit
  }while (1);

  close(fd);
  return 0;
}

