应该是顺序执行,可为啥重复了两遍啊?
(gdb) list
12 #include <sys/ioctl.h>
13 #include <fcntl.h>
14 #include <unistd.h>
15 #include <signal.h>
16 #include <fcntl.h>
17 #define GET_DATA 0x4800
18
19
20 int main(void)
21 {
(gdb) list
22 int fd,count;
23 int i=10;
24 unsigned long rgdata;
25 rgdata=0xffffffff;
26 printf( "Before open\n ");
27
28 if((fd=open( "/dev/leddrv ",O_RDWR))==-1) {
29 printf( "open error\n ");
30 exit(1);
31 }
(gdb) list
32
33 while(i) {
34 rgdata=~rgdata;
35 printf( "Before write!\n ");
36 if((count=write(fd,(char *)&rgdata,4))!=4)
37 printf( "write error\n ");
38 /*
39 if(ioctl(fd,GET_DATA,spinfo)!=0)
40 perror( "ioctl error ");
41 else
(gdb) list
42 printf( "spinfo=%d\n ",*spinfo);
43 */
44 sleep(1);
45 printf( "OK!\n ");
46 if((--i)==0) {
47 printf( "Set new time(1~100), input 999 to quit:\n ");
48 scanf( "%d ",&i);
49 if(i==999) break;
50 }
51 }
(gdb) list
52 close(fd);
53 return 0;
54 }
(gdb) list
Line number 55 out of &n