Skip to content

Instantly share code, notes, and snippets.

@sandeepbhuyan
Forked from itrobotics/chrdev_test.c
Created June 7, 2018 16:36
Show Gist options
  • Save sandeepbhuyan/837140fd8696026cbf9c74bb8a69b48e to your computer and use it in GitHub Desktop.
Save sandeepbhuyan/837140fd8696026cbf9c74bb8a69b48e to your computer and use it in GitHub Desktop.
a simple file to test the module : chrdev.c
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include<fcntl.h>
#include<time.h>
int main(int argc,char *argv[]){
int dev_0 = open("/dev/mydev_0",O_RDWR);
char buff[100];
write(dev_0,"TEST DEV\n",10);
int ret = read(dev_0 ,buff,32);
printf("ret:%d\n", ret);
printf("READ:%s\n", buff);
close(dev_0);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment