A Character device driver needs a major number and a minor number. The devices are registered in the Kernel and it lies either in the /dev/ or in the /proc folder. The following example uses a char device driver with major number 222 and a minor number 0. The name of the device driver namely “ new_device ” It uses the following things Open or register a device close or unregister the device Reading from the device (Kernel to the userspace) Writing to the device (userlevel to the kernel space) There are three files, Copy the following or download all the three files here /* new_dev.c*/ #include<linux/module.h> #include<linux/init.h> #include "new_dev.h" MODULE_AUTHOR("PRADEEPKUMAR"); MODULE_DESCRIPTION("A simple char device"); static int r_init(void); static void r_cleanup(void); module_init(r_init); module_exit(r_cleanup); static int r_init(void) { printk("<1>hi\n"); if(register_chrdev(222,"new_device",...
Its all about Network Simulations (NS2, NS3), Internet of Things, Sensor Networks, Programming, Embedded Systems, Cyber Physical Systems, etc