Go to the documentation of this file.00001 #include <stdio.h>
00002 #include <signal.h>
00003 #include <sys/types.h>
00004 #include <sys/stat.h>
00005 #include <sys/ioctl.h>
00006 #include <fcntl.h>
00007 #include <errno.h>
00008 #include <stdlib.h>
00009 #include <unistd.h>
00010
00011 #include "driver/urbtc.h"
00012
00013
00014 int main(int argc, char** argv)
00015 {
00016 int fd;
00017 int vendor, product;
00018 int status;
00019
00020 if((fd = open("/dev/urbtc0", O_RDWR)) == -1){
00021 perror("device open error\n");
00022 exit(1);
00023 }
00024
00025 if(ioctl(fd, URBTC_GET_VENDOR, &vendor) == -1){
00026 perror("ioctl error\n");
00027 exit(1);
00028 }
00029 printf("Vendor %x\n", vendor);
00030
00031 if(ioctl(fd, URBTC_GET_PRODUCT, &product) == -1){
00032 perror("ioctl error\n");
00033 exit(1);
00034 }
00035 printf("Product %x\n", product);
00036
00037
00038
00039 if(ioctl(fd, URBTC_REQUEST_READ) == -1){
00040 perror("ioctl error\n");
00041 exit(1);
00042 }
00043
00044 if(ioctl(fd, URBTC_GET_READ_STATUS, &status) == -1){
00045 perror("ioctl error\n");
00046 exit(1);
00047 }
00048 printf("read status %d\n", status);
00049
00050
00051
00052
00053 if(ioctl(fd, URBTC_CONTINUOUS_READ) == -1){
00054 perror("ioctl error\n");
00055 exit(1);
00056 }
00057
00058 if(ioctl(fd, URBTC_GET_READ_STATUS, &status) == -1){
00059 perror("ioctl error\n");
00060 exit(1);
00061 }
00062 printf("read status %d\n", status);
00063
00064
00065
00066
00067 if(ioctl(fd, URBTC_COUNTER_SET) == -1){
00068 perror("ioctl error\n");
00069 exit(1);
00070 }
00071
00072 if(ioctl(fd, URBTC_GET_WRITE_STATUS, &status) == -1){
00073 perror("ioctl error\n");
00074 exit(1);
00075 }
00076 printf("write status %d\n", status);
00077
00078
00079
00080 if(ioctl(fd, URBTC_DESIRE_SET) == -1){
00081 perror("ioctl error\n");
00082 exit(1);
00083 }
00084
00085 if(ioctl(fd, URBTC_GET_WRITE_STATUS, &status) == -1){
00086 perror("ioctl error\n");
00087 exit(1);
00088 }
00089 printf("write status %d\n", status);
00090
00091 close(fd);
00092
00093 return 0;
00094 }