first sample

This commit is contained in:
ioacademy-jikim
2015-08-19 19:26:23 +09:00
commit e92d98c6d0
62 changed files with 2573 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS := -fPIE
LOCAL_LDFLAGS := -fPIE -pie
LOCAL_MODULE := myapp
LOCAL_SRC_FILES := rdwr_app.c
include $(BUILD_EXECUTABLE)
+10
View File
@@ -0,0 +1,10 @@
#include <fcntl.h>
int main()
{
int fd;
fd = open( "/sys/devices/virtual/misc/mydev/uevent", O_WRONLY );
write( fd, "add\n", 4 );
close(fd);
return 0;
}
+57
View File
@@ -0,0 +1,57 @@
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
int main()
{
int fd, ret;
char buff[10];
fd = open( "/dev/mydev", O_RDONLY );
ret = read( fd, buff, sizeof buff );
buff[ret] = 0;
printf( "buff[%s], ret=%d\n", buff, ret );
close(fd);
return 0;
}
/*
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
int main()
{
int fd, ret;
int temp;
fd = open( "/dev/mydev", O_RDONLY );
ret = read( fd, &temp, sizeof temp );
printf( "temp=%d, ret=%d\n", temp, ret );
close(fd);
return 0;
}
*/
/*
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
int main()
{
int fd, ret;
char buff[] = "LED_ON";
fd = open( "/dev/mydev", O_WRONLY );
ret = write( fd, buff, strlen(buff) );
printf( "ret=%d\n", ret );
close(fd);
return 0;
}
*/
/*
#include <fcntl.h>
int main()
{
int fd;
int flag=128;
fd = open( "/dev/mydev", O_WRONLY );
write( fd, &flag, sizeof flag );
close(fd);
return 0;
}
*/