A Linux user space program that communicates with the ebbchar.c LKM. It passes a string to the LKM and reads the response from the LKM. For this example to work the device must be called /dev/ebbchar.
More...
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
A Linux user space program that communicates with the ebbchar.c LKM. It passes a string to the LKM and reads the response from the LKM. For this example to work the device must be called /dev/ebbchar.
- Author
- Derek Molloy
- Date
- 7 April 2015
- Version
- 0.1
- See also
- http://www.derekmolloy.ie/ for a full description and follow-up descriptions.
#define BUFFER_LENGTH 256 |
The buffer length (crude but fine)
23 printf(
"Starting device test code example...\n");
24 fd = open(
"/dev/ebbchar", O_RDWR);
26 perror(
"Failed to open the device...");
29 printf(
"Type in a short string to send to the kernel module:\n");
30 scanf(
"%[^\n]%*c", stringToSend);
31 printf(
"Writing message to the device [%s].\n", stringToSend);
32 ret = write(fd, stringToSend, strlen(stringToSend));
34 perror(
"Failed to write the message to the device.");
38 printf(
"Press ENTER to read back from the device...\n");
41 printf(
"Reading from the device...\n");
44 perror(
"Failed to read the message from the device.");
47 printf(
"The received message is: [%s]\n",
receive);
48 printf(
"End of the program\n");
#define BUFFER_LENGTH
The buffer length (crude but fine)
Definition: testebbchar.c:17
static char receive[BUFFER_LENGTH]
The receive buffer from the LKM.
Definition: testebbchar.c:18
The receive buffer from the LKM.