Download Conejo User's Manual
Transcript
Host/Target Communications
Note the use of manipulators, such as bold and normal, to force formatting of the text string as it is streamed to the host.
TermIo features many such manipulators to perform functions such as setting text color (setcolor), clearing to end-of-line
(clreol), clearing the screen (cls) and so forth. Other manipulators are available to format numeric values as they are streamed
to the host. For example, the phrase
cio << "Hello" << hex << showbase << 4660 << dec;
displays the string "Hello 0x1234" on the console display, converting the integer value 4660 as a hexadecimal number on the
target, prior to streaming it to the host. Other manipulators are available providing extensive control over the display of
floating point numbers as well as integer values.
It is also frequently necessary to obtain input from an operator during the run-time execution of a target application. For
example, it may be necessary to prompt for a sample rate at which analog I/O is to be streamed. The code fragment below
illustrates the necessary technique
// Prompt the user
cio << " Enter a float: " << flush;
float x2;
// Eat user input
cio >> x2;
The stream manipulator >> is overloaded to allow streaming directly into floating point, integer and string variables directly
from UniTerminal.
To perform file input and output from within target applications, first instantiate a TermFile object, as below
TermFile File;
Then, use the TermFile Open method to open the file for access on the host using the desired open attributes
if (!File.Open("wave.bin", "w+b"))
{
cio << "nOutput file open error - Program terminating!" << endl;
cio.monitor();
}
This method returns a Boolean indicating success if the file open is successful. To store data into the file or retrieve data from
the file, use the Write or Read methods, respectively. For example
transferred = File.Write((char*)&Buffer[0], 10000);
writes 10000 bytes of Buffer into the disk file. When disk operations have been completed, the file should be closed using the
TermFile::Close method.
Conejo User's Manual
73