Closed trylimits closed 9 years ago
I would like to discuss some specifications of the console:
printf
and scanf
@mpe5651 @Blackjack92 Pls provide your opinions asap.
I did some testing on whic ASCII codes are sent if the following keys are sent over uart:
Backspace=127
Key UP=91 followed by 65
Key DOWN=91 followed by 66
Key LEFT=91 followed by 68
Key RIGHT=91 followed by 67
Key DEL=91 followed by 51 followed by 126
Trivial test code:
DeviceManagerRead(consoleDevice, &buf[0], 1);
char temp[10];
sprintf(temp, "[D] %i\r\n", buf[0]);
DeviceManagerWrite(consoleDevice, temp, 10);
The above commit implements a first prototype for a console. Implemented is:
1.) ASCII Logo
2.) Welcome message
3.) Prompt
4.) Command input
Not implemented:
1.) Handling of control keys (cursor, bs, del)
2.) IPC to kernel (command)
3.) ...
Above commits implement the scanf
and printf
override. The console implementation directly uses scanf
to fetch the user input.
Atm. not all input characters are supported, but the set of accepted characters can be easily extended by changing the method acceptChar(..)
in console.c
.
All improvements of the console should be treated in new tickets.
Below code snippet starts the console as a process:
DeviceManagerInit();
device_t uart = DeviceManagerGetDevice("UART0", 5);
ConsoleInit(uart);
SchedulerInit();
SchedulerStartProcess(&ConsoleProcess);
device_t timer = DeviceManagerGetDevice("TIMER2", 6);
DeviceManagerInitDevice(timer);
device_t cpu = DeviceManagerGetDevice("CPU", 3);
DeviceManagerIoctl(cpu, DRIVER_CPU_COMMAND_INTERRUPT_MASTER_IRQ_ENABLE, 0, NULL, 0);
DeviceManagerIoctl(cpu, DRIVER_CPU_COMMAND_INTERRUPT_RESET_AINTC, 0, NULL, 0);
SchedulerStart(timer);
We should implement a console which also overrides the
printf(..)
andscanf(..)
functions. Those should be redirected to the UART0 output.General concept for that is to provide our own functions which should look approx. like this:
where
STREAM
is of typeFILE
.