hi,dear all:
if I want to get some input in the "hello" example, what should I do? I simply use "scanf()", but it does not work! my main.c is as below:
#include <l4/sys/types.h> #include <l4/sys/syscalls.h> #include <l4/sys/ipc.h>
#include <stdio.h>
int main(int argc, char **argv) { l4_threadid_t th; l4_msgdope_t result; l4_umword_t d1, d2; int choice;
printf("Hello World\n");
th = l4_myself();
for (;;) { printf("hello: My thread-id is %x.%x\n", th.id.task, th.id.lthread);
scanf("%d",&choice); if(choice==0) return 0; } }
On Fri Aug 10, 2007 at 17:15:58 +0800, huang wrote:
if I want to get some input in the "hello" example, what should I do? I simply use "scanf()", but it does not work! my main.c is as below:
scanf does not work at this stage. Usually, in such an environment, getting input to work requires you to write a driver for the device you want to interact with (e.g. the keyboard). The same actually goes for output too, so to get something on your screen you would need to have the device memory mapped and write the proper values to the proper locations to see something on the screen. As you see, the printf works without doing this because the kernel provides such a function as part of its debugging facilities. And it also offers a possibility for programs to receive from the keyboard: include <l4/sys/kdebug.h> and use l4kd_inchar() to receive input from the keyboard. This function is non-blocking and returns -1 if no character could be read.
Adam
l4-hackers@os.inf.tu-dresden.de