--------------------
KERNEL Module Control
--------------------
1. LED ON
2. LED OFF
3. EXIT
-------------------
Command: 1
위의 형식으로 뜨게 수정
test app 만 수정
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char **argv) {
int dev = 0;
char buff[1024] = { 0,};
char cmd[40] = { 0,};
dev = open("/dev/my_device2", O_RDWR); //open은 한번만 열면 됨
while(1){
printf("--------------------\nKERNEL Module Control 1.0\n--------------------\n");
printf("1. LED ON\n2. LED OFF\n3. EXIT\n");
printf("-------------------\n");
printf("Command: ");
scanf("%s", cmd);
if(!strcmp(cmd, "1")){
write(dev, cmd, strlen(cmd));
read(dev, buff, strlen(cmd));
printf("read from device : %s\n",buff);
}
else if(!strcmp(cmd, "2")){
//write(dev, cmd, strlen(cmd));
read(dev, buff, strlen(cmd));
printf("read from device : %s\n",buff);
}
else if(!strcmp(cmd, "3")){
//write(dev, cmd, strlen(cmd));
//read(dev, buff, strlen(cmd));
printf("EXIT\n");
close(dev);
exit(0);
}
}
return 0;
}
'임베디드 > KERNEL' 카테고리의 다른 글
GPIO 컨트롤 (0) | 2020.12.24 |
---|---|
test_dev3.c test_app3.c 메뉴띄우기 switch (0) | 2020.12.21 |
디바이스드라이버 LED ON/OFF (0) | 2020.12.18 |
-fstack-protector-strong’ 오류 (0) | 2020.12.18 |
test_app (0) | 2020.12.17 |