ioctl done

This commit is contained in:
2025-02-24 17:45:02 +00:00
parent 3681dbfaac
commit 8a8b8cf56a
5 changed files with 250 additions and 0 deletions

35
ioctl/ioctl_app.c Normal file
View 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;
}