Hello
Quote:
Generally you will store keyboard events in some kind of (ring?) buffer in the driver. The call to scanf may, for example, tell the keyboard driver that a particular process is expecting keyboard input and the system call may release the buffer once it hits a LF/CR/CRLF.
I already have something like this. It is a kscanf function, which puts the characters in a buffer and then copies the buffer to the target buffer. It works just fine in kernel space. But when i use it in the read system call, it doesn't work.
Code:
static int sys_read(int fd, char *buf, size_t len) {
kscanf("%s", buf);
return 0;
}
This is what i use inside the kscanf:
Code:
int scanning(char *newBuffer, int size) {
clearBuffer(newBuffer);
clearBuffer(buffer);
bufferNum = 0;
isScanEnabled = 1;
char tempChar;
while (isScanEnabled == 1) {
tempChar = getChar();
if (tempChar == '\n') {
isScanEnabled = 0;
return 1;
}
else {
if (addToBuffer(newBuffer, size, tempChar) == 0) return 0;
monPut(tempChar);
}
}
return 0;
}
Thanks