【文件属性】:
文件名称:字符驱动测试程序-卷积神经网络的数学推导
文件大小:8.6MB
文件格式:PDF
更新时间:2024-06-29 07:17:43
周立功 嵌入式 Linux
程序清单 2.18 字符驱动测试程序
1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7
8 #define DEV_NAME "/dev/char_cdev"
9
10 int main(int argc, char *argv[])
11 {
12 int i;
13 int fd = 0;
14 int dat = 0;
15
16 fd = open (DEV_NAME, O_RDWR);
17 if (fd < 0) {
18 perror("Open "DEV_NAME" Failed!\n");
19 exit(1);
20 }
21
22 i = read(fd, &dat, 1);
23 if (!i) {
24 perror("read "DEV_NAME" Failed!\n");
25 exit(1);
26 }
27
28 dat = 0;
29 i = write(fd, &dat, 1);
30 if (!i) {
31 perror("write "DEV_NAME" Failed!\n");
32 exit(1);
33 }
34
35 i = ioctl(fd, NULL, NULL);
36 if (!!i) {
37 perror("ioctl "DEV_NAME" Failed!\n");
38 exit(1);
39 }
40