|16 Jun 2010 06:04:10 pm by bsl
|The standard file handles STDIN, STDOUT, and STDERR, are already open on the TI-Nspire .
It was a matter of a little detective work finding them.
All 3 are directed to RS232 however.
The attachment has a hand coded CAS and NONCAS proof of concept program for these handles.
The result you should get on the emulator console is:
TERMINAL> Is fgets working ? // I entered "Is fgets working ?" and hit return
You entered:Is fgets working ?
The equivalent C program should look like this(pseudo code):
/* terminal.c (noncas version) */
stdin = (FILE *) 0x105bb5f0;
stdout = (FILE *) 0x105bb63c;
stderr = (FILE *) 0x105bb688;
printf("TERMINAL> "); // terminal prompt
fgets(buffer,32,stdin); // get user input
printf("You entered:%s\nTERMINAL> ",buffer);
IDEA: Include a while loop above to make a real terminal program that processes strings for commands.
printf is usefull for debugging messages to the console.
fgets used in this way can be used in development to change execution of a program during development.
The attachment also contains CAS NONCAS handle definitions and fgets definition for os.h
|16 Jun 2010 08:16:26 pm by bwang