op_sim_message()
摘要
将指定的消息打印到标准输出设备或仿真进度对话框。
语法
op_sim_message (line0, line1)
| 参数 | 类型 | 说明 |
|---|---|---|
line0 |
char* |
消息行 #0 |
line1 |
char* |
消息行 #1 |
返回类型
void
无返回值。
示例
摘自:示例模型(models/std/eth_net);进程模型(eth_mac);函数块;函数 (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
}
详情
默认情况下,仿真的标准输出设备就是启动该仿真进程的命令 shell。如果仿真进程是由 Project Editor 派生的(即从图形环境而非命令 shell 运行),则标准输出设备是启动该应用进程的命令 shell。如果仿真进程是从 shell 窗口派生的,则默认的标准输出设备将与该窗口关联。可以使用仿真命令行上的“>” I/O 重定向运算符将标准输出重定向到文件。
从 Project Editor 运行仿真时,消息窗口中只显示所指定两行中的第一行,尽管所有行都会同时显示在输出到 shell 的内容中。
用途
提供了一种机制,用于在命令 shell 关联的终端(或窗口)上(当仿真从 shell 执行时)或在仿真进度对话框中(当仿真从 Project Editor 执行时)打印一个简单的两行文本消息。通常,该内核过程用作 printf() 的替代,因为它能够妥善处理 Project Editor 情形。
错误
- 程序中止:段违例。(由于无效或格式错误的消息字符串)
参考
- 使用内核过程 op_sim_end() 终止仿真并向标准输出设备打印多条消息行
- 使用标准 C 函数 printf() 将消息打印到标准输出设备
- 使用标准 C 函数 fprintf() 或标准函数 write() 将消息(或其他数据)写入已打开的文本或二进制文件