mirror of
https://github.com/Hizenberg469/Driver-tutorial.git
synced 2026-04-20 00:42:25 +03:00
ioctl done
This commit is contained in:
35
ioctl/ioctl_app.c
Normal file
35
ioctl/ioctl_app.c
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "ioctl_const.h"
|
||||
|
||||
int main(){
|
||||
|
||||
int fd;
|
||||
int32_t value , number;
|
||||
|
||||
printf("\nOpening Driver\n");
|
||||
fd = open("/dev/demo_ioctl_device", O_RDWR);
|
||||
if( fd < 0 ){
|
||||
printf("Cannot open device file...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("Enter the Value to send\n");
|
||||
scanf("%d", &number);
|
||||
printf("Writing Value to Driver\n");
|
||||
ioctl(fd, WR_VALUE, (int32_t*) &number);
|
||||
|
||||
printf("Reading Value from Driver\n");
|
||||
ioctl(fd, RD_VALUE, (int32_t*) &value);
|
||||
printf("Value is %d\n", value);
|
||||
|
||||
printf("Closing Driver\n");
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user