#include <console.h>
Public Methods | |
| Console (char *readFile, char *writeFile, VoidFunctionPtr readAvail, VoidFunctionPtr writeDone, int callArg) | |
| ~Console () | |
| void | PutChar (char ch) |
| char | GetChar () |
| void | WriteDone () |
| void | CheckCharAvail () |
Private Attributes | |
| int | readFileNo |
| int | writeFileNo |
| VoidFunctionPtr | writeHandler |
| VoidFunctionPtr | readHandler |
| int | handlerArg |
| bool | putBusy |
| char | incoming |
|
||||||||||||||||||||||||
|
Definition at line 39 of file console.cc. References ConsoleReadInt, ConsoleReadPoll, ConsoleTime, FALSE, handlerArg, incoming, NULL, OpenForReadWrite, OpenForWrite, putBusy, readFileNo, readHandler, TRUE, VoidFunctionPtr, writeFileNo, and writeHandler.
00041 {
00042 if (readFile == NULL)
00043 readFileNo = 0; // keyboard = stdin
00044 else
00045 readFileNo = OpenForReadWrite(readFile, TRUE); // should be read-only
00046 if (writeFile == NULL)
00047 writeFileNo = 1; // display = stdout
00048 else
00049 writeFileNo = OpenForWrite(writeFile);
00050
00051 // set up the stuff to emulate asynchronous interrupts
00052 writeHandler = writeDone;
00053 readHandler = readAvail;
00054 handlerArg = callArg;
00055 putBusy = FALSE;
00056 incoming = EOF;
00057
00058 // start polling for incoming packets
00059 interrupt->Schedule(ConsoleReadPoll, (int)this, ConsoleTime, ConsoleReadInt);
00060 }
|
|
|
Definition at line 67 of file console.cc. References Close, readFileNo, and writeFileNo.
00068 {
00069 if (readFileNo != 0)
00070 Close(readFileNo);
00071 if (writeFileNo != 1)
00072 Close(writeFileNo);
00073 }
|
|
|
Definition at line 87 of file console.cc. References ConsoleReadInt, ConsoleReadPoll, ConsoleTime, incoming, PollFile, Read, and readFileNo. Referenced by ConsoleReadPoll.
00088 {
00089 char c;
00090
00091 // schedule the next time to poll for a packet
00092 interrupt->Schedule(ConsoleReadPoll, (int)this, ConsoleTime,
00093 ConsoleReadInt);
00094
00095 // do nothing if character is already buffered, or none to be read
00096 if ((incoming != EOF) || !PollFile(readFileNo))
00097 return;
00098
00099 // otherwise, read character and tell user about it
00100 Read(readFileNo, &c, sizeof(char));
00101 incoming = c ;
00102 stats->numConsoleCharsRead++;
00103 (*readHandler)(handlerArg);
00104 }
|
|
|
Definition at line 128 of file console.cc. References incoming. Referenced by ConsoleTest, and SynchConsole::ReadLine.
|
|
|
Definition at line 143 of file console.cc. References ASSERT, ConsoleTime, ConsoleWriteDone, ConsoleWriteInt, FALSE, putBusy, TRUE, WriteFile, and writeFileNo. Referenced by ConsoleTest, and SynchConsole::WriteLine.
00144 {
00145 ASSERT(putBusy == FALSE);
00146 WriteFile(writeFileNo, &ch, sizeof(char));
00147 putBusy = TRUE;
00148 interrupt->Schedule(ConsoleWriteDone, (int)this, ConsoleTime,
00149 ConsoleWriteInt);
00150 }
|
|
|
Definition at line 114 of file console.cc. References FALSE, and putBusy. Referenced by ConsoleWriteDone.
|
|
|
Definition at line 66 of file console.h. Referenced by Console. |
|
|
Definition at line 70 of file console.h. Referenced by CheckCharAvail, Console, and GetChar. |
|
|
|
|
|
Definition at line 60 of file console.h. Referenced by CheckCharAvail, Console, and ~Console. |
|
|
Definition at line 64 of file console.h. Referenced by Console. |
|
|
|
|
|
Definition at line 62 of file console.h. Referenced by Console. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002