// pxlc driver // flip bits on and off #include #include #include #include #include #include #include #include "pxlc_if.h" main(int argc, char *argv[]) { int fd, len, wlen; int i; uint32_t buf[2]; unsigned char bytes[PXLC_BYTE_COUNT]; int bitval; int bitnum; if (argc != 3) { printf("Usage: flip bitnum bitval\n"); exit(0); } bitnum = atoi(argv[1]); bitval = atoi(argv[2]); printf("Flipping bit %d to %d\n", bitnum, bitval); fd = open("/dev/pxlc", O_RDWR); if (fd == -1) { perror("open"); exit(0); } wlen = 8; if (bitval) { buf[0] = PXLC_OP_SETBIT; } else { buf[0] = PXLC_OP_CLRBIT; } buf[1] = bitnum; len = write(fd, buf, wlen); if (len == -1 ) { perror("setbit write error"); exit(1); } close(fd); }