op_sim_message()
Abstract
Prints a specified message onto the standard output device or the Simulation Progress dialog box.
Syntax
op_sim_message (line0, line1)
| Argument | Type | Description |
|---|---|---|
line0 |
char* |
message line #0 |
line1 |
char* |
message line #1 |
Return Type
void
No return value.
Example
Excerpt from: example model (models/std/eth_net); process model (eth_mac); function block; function (eth_mac_llc_pk_accept()).
/* llc data larger than the maximum acceptable size will */
/* cause an error and the data to be discarded. */
if (op_pk_total_size_get (llc_pkptr) > MAX_DATA_SIZE)
{
/* compose and display the error message */
sprintf (err_str, "large packet with (%d) bits",
op_pk_total_size_get (llc_pkptr));
op_sim_message ("ethernet mac layer discarding excessively", err_str);
/* throw away the packet and return from invocation. */
op_pk_destroy (llc_pkptr);
FOUT
}
Details
By default, the standard output device for a simulation is the command shell that spawned the simulation process. If the simulation process was spun off by the Project Editor (that is, run from the graphical environment as opposed to a command shell), the standard output device is the command shell that spawned the application process. If the simulation process was spawned from a shell window, the default standard output device will be associated with that window. The standard output can be redirected to a file, using the “>” I/O redirection operator on the simulation command line.
When running a simulation from the Project Editor, only the first of the two specified lines will be displayed in the message window, although all lines will be visible in the output that is simultaneously directed to the shell.
Purpose
Provides a mechanism to print out a simple two-line text message on the terminal (or window) associated with the command shell (if the simulation has been executed from the shell) or in the Simulation Progress dialog box (if the simulation has been executed from the Project Editor). Typically, this KP is used as a substitute for printf(), because it adequately handles the Project Editor situation.
Errors
- Program Abort: Segmentation violation. (due to invalid or malformed message strings)
Reference
- Use the KP op_sim_end() to terminate the simulation and print several message lines to the standard output device
- Use the standard C function printf() to print messages onto the standard output device
- Use the standard C function fprintf() or the standard function write() to write messages (or other data) into an open text or binary file